Using terminal (or scripting) to get CRC-32 checksum on images and DVDs

Hello,

I will be mass checking CRC-32 checksums between physical DVDs and DMG images. Normally I use disk utility to do this. I want to try to automate this.

Is there any way to script this? Is there a unix command for this? Is there a way to use applescript to find out the CRC value?

I know some DVD burning software can check this, but I am using this as a double check.

Thanks

Intel, Mac OS X (10.6.2)

Posted on Mar 8, 2010 3:12 AM

Reply
6 replies

Mar 8, 2010 4:43 AM in response to xexers

In terminal, type:

crc32 /path/to/file

... where /path/to/file is the path to your file or device. It should be noted that a DMG and a DVD or CD are different formats so they should have different CRC32 values. An ISO image and a disk should have the same CRC32.

You can also go one better and use the MD5 checksum. The command is, astonishingly enough, 'md5'.

In AppleScript, it's perhaps easiest thing to do is use 'do shell script' to call crc32 or md5.

Mar 8, 2010 7:38 AM in response to xexers

You can't calculate checksums of directories, only of files. It wouldn't make sense to make a checksum of a directory since it's not clear in what order you'd evaluate the contents: by date, by name, depth first, breadth first, etc.

If evaluating a whole DVD at once, then you'd calculate the checksum on the DVD device, not the directory where it's mounted. For example:

crc32 /dev/disk2s2

(note that you need to unmount, but not eject, the disk before you do that)... That gives you the CRC32 of the session, and 'crc32 /dev/disk2' would give you the value for the whole disk.

Mar 8, 2010 12:42 PM in response to xexers

In Terminal:

sudo umount /Volumes/something

... which only works if nothing has files open on 'something'. In Disk Utility, select the mounted partition and click the Unmount button on the toolbar.

OS X assigns the CD/DVD drive a device in /dev when a disk is inserted. If /dev/disk1 is the last disk before inserting the disk, then inserting a CD or DVD will make it create /dev/disk2. There's also a similar /dev/rdisk2 which is the "RAW" disk. You can see what it's mounted as using 'mount' in the terminal:

$ mount
/dev/disk0s2 on / (hfs, local, journaled)
devfs on /dev (devfs, local, nobrowse)
map -hosts on /net (autofs, nosuid, automounted, nobrowse)
map auto_home on /home (autofs, automounted, nobrowse)
/dev/disk1s2 on /Volumes/Backup (hfs, local, nodev, nosuid, journaled)
*/dev/disk2 on /Volumes/SalesData (cd9660, local, nodev, nosuid, read-only, noowners)*

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Using terminal (or scripting) to get CRC-32 checksum on images and DVDs

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.