Run an md5 hash on a DVD or CD

Discussion in 'macOS' started by TechieJustin, Dec 12, 2009.

  1. TechieJustin macrumors 6502

    TechieJustin

    Joined:
    Nov 22, 2009
    Location:
    Pennsylvania, USA
    #1
    I downloaded the freeBSD isos and burned them to DVD.
    But, I have to confirm the burn was OK.
    How can I run an md5 on the actual resulting dvd? I ran the md5 on the images with no problem as seen below:

    Using md5sum from macports
    Justins-MacBook-Pro:SONY8G justin$ md5sum 8.0-RELEASE-ia64-dvd1.iso
    6b8df7fb34d5960ecf91a291926a1e6f 8.0-RELEASE-ia64-dvd1.iso

    and using the md5 command included with Snow Leopard
    Justins-MacBook-Pro:SONY8G justin$ md5 -r 8.0-RELEASE-ia64-dvd1.iso
    6b8df7fb34d5960ecf91a291926a1e6f 8.0-RELEASE-ia64-dvd1.iso

    Obviously both are identical.

    Now if I try to run md5 or md5sum on the drive this is what I get:

    Justins-MacBook-Pro:~ justin$ md5sum /dev/disk2md5sum: /dev/disk2: Not a regular file

    Using the md5 command included with SL:
    Justins-MacBook-Pro:~ justin$ md5 -r /dev/disk2
    d41d8cd98f00b204e9800998ecf8427e /dev/disk2
    The above is incorrect, the drive doesn't make a sound so it obviously isn't checking through all the bits on the disc.
    I'm not sure what its doing, but it sure isn't md5'ing the entire disc.


    I'm paranoid about the burn being a bit off - these discs are going to be sent to the middle of nowhere where the internet doesn't reach - they have to be perfect. I can't really go into more detail.
    Plan B is ordering the discs - but I would like to know this in case I have to send another disc out that doesn't have a pressed copy available - such as data.
     
  2. TechieJustin thread starter macrumors 6502

    TechieJustin

    Joined:
    Nov 22, 2009
    Location:
    Pennsylvania, USA
    #2
    I figured it out - unfortunately its useless.


    First I burned the image via diskutility

    (for some reason the ia64 install of FreeBSD is half the size of the AMD64 or i386.)

    Then one must unmount the media otherwise a device busy error will result.

    justin$ sudo umount /Volumes/"CD or DVD volume name"

    justin$ openssl md5 /dev/disk2
    then the drive starts purring like a good little Snow Leopard.
    At this point go get something to eat, make a few calls, work out - depending on h0w big the media is this can take a while.

    justin$ openssl md5 /dev/disk2
    MD5(/dev/disk2)= 1637d61002cb6ac97f814d6d052cc4a4

    justin$ openssl md5 8.0-RELEASE-ia64-dvd1.iso
    MD5(8.0-RELEASE-ia64-dvd1.iso)= 6b8df7fb34d5960ecf91a291926a1e6f


    They obviously don't match - but I know why.
    The md5 was performed on the entire disc - 4.7G - not just the relevant data.
     
  3. jbuk macrumors regular

    Joined:
    Jun 8, 2009
    #3
    I don't know what it makes a checksum of specifically, but highlight your disk in Disk Utility and then choose Images > Checksum > MD5 or Images > Checksum > MD5 Image Checksum. I don't know what the difference is, and you might need to enable the advanced formats in disk utility first, with
    Code:
    defaults write com.apple.DiskUtility advanced-image-options 1
    but that should help.
     
  4. TechieJustin thread starter macrumors 6502

    TechieJustin

    Joined:
    Nov 22, 2009
    Location:
    Pennsylvania, USA
    #4
    cds and dvds use 2k block sizes, and you have to cut it off at the end of the iso because it will run the md5 on the entire disc - including the random junk after your written data.
    I used the ia64 iso of FreeBSD because it was the smallest - I'm not going to use it for anything.

    justin$ sudo umount /dev/disk2
    Sometimes you have to unmount

    justin$ dd if=/dev/disk2 bs=2k | md5 -r
    since cds and dvds use 2k block sizes the bs-2k must be specified
    3794688+0 records in
    3794688+0 records out
    7771521024 bytes transferred in 2593.040306 secs (2997069 bytes/sec)
    e26826cc68281aa581cc181483bd232d

    Making the iso
    justin$ dd if=/dev/disk2 of=biggerdvd.iso bs=2k
    Same here - even when making the image the 2k block size must be specified.
    3794688+0 records in
    3794688+0 records out
    7771521024 bytes transferred in 2765.505716 secs (2810163 bytes/sec)

    running the md5 hash on the resulting iso - no bs=2k is needed since we're not reading from a block device
    justin$ md5 -r biggerdvd.iso
    e26826cc68281aa581cc181483bd232d biggerdvd.iso

    since the block size is 2k we have to divide 7,771,521,024 by 2,048 which results in 3,794,688 blocks
    dd if=/dev/disk2 bs=2k count=3794688 | md5 -r
     

Share This Page