5

I have a burnt dvd from an iso image. I have also sha256sum of the iso image. to compare hashes, I created an iso image from the dvd and executed sha256sum image.iso, but it differs from the hash of original image.

Is this a correct way to calculate hash of a DVD? If not, why doesn't it work?

Edit: Can someone explain the reason Aaron Miller provided in comment. Is there a way to make iso file with exactly the same options as the original iso?

2
  • 2
    The theory is correct, but does not account for differences between the options used in generating your ISO, and those used when creating the one from which you burned the DVD. I'm not sure whether or how it is possible to identify the specifics that went into the original ISO's creation, though. Jul 11, 2013 at 19:05
  • There is padding to a 16 sector boundary for ECC purposes. Check your created ISO to see if it is a bit larger than the original. Drive might have padded it when physically writing the data and then whatever you used to create the ISO form the disk didn't undo this effect.
    – Brian
    Jul 17, 2013 at 0:20

3 Answers 3

6

The only way I have found to do this is to hash the files themselves, not the images. Using a tool like Febooti Hash & CRC (Windows) or Quick Hash GUI you can just select all the files in question, right click, then record the hash. You can do the same thing from the command line with sha256sum too of course. After you burn those files to a disc browse to the files on the disc and check the hash as you did before. The hashes should match.

Additional thoughts:

You indicate your current process is to create an iso from the disc you want to check. I would argue this is an extra and unnecessary step. Just put the disc in and hash the files on the disc as I have suggested and compare them to the hash of the files that are on your original image. No need to create an iso first so this should be a lot faster.

4

UPDATE:

Is this a correct way to calculate hash of a DVD?

First, take a sha256sum of the DVD itself as done on this site:

... you’ve already burned the CD and now you’d like to go back and check it? As long as you have the sha1sum or md5sum it’s simple.

...

DVD-RW drive is /dev/hda

g33kgrrl@home ~/Desktop$ sha1sum /dev/hda

89164d79d84f483c3642f25507186e58bf5fc0d8 /dev/hda

While they use sha1sum, it should work the same for sha256sum. First, compare that with the hash of your original iso.

If not, why doesn't it work?

As this user points out:

in certain cases the size can be slightly different because there are trailing zeroes in either the copy or the original image

He provides some steps to find out if this is the case, quote:

For example, if copy.iso is smaller than orig.iso:

sha1sum copy.iso
head -c $(stat -c %s copy.iso) orig.iso

Of course you should also check that the trailing bytes are just zeroes:

od -j $(stat -c %s copy.iso) orig.iso

And finally back to your new question:

Is there a way to make iso file with exactly the same options as the original iso?

I have not yet found a way to do this. However, once you have the hashes of each step, you can at least see where the difference occurred. My guess is that the program that burns your ISO file performs some steps that are necessary for burning but that also modify the image somehow?

Somewhat out of the scope of this question, but it would be interesting to see if it is modified the same every time. In other words, burn multiple discs and see if there hashes are all the same?

Original answer:

Not sure if this satisfies your question (perhaps your existing application already performs this function)

But if you get the ImgBurn utility (windows utility, sorry) it has a feature to "verify" a disc using an ISO image.

My guess is that under the hood this performs some extra steps in order to achieve what you are trying to do. Shame that it isn't open source, or you could pull up the code and see exactly what is happening.

Perhaps there are other burn utilities that have similar functionality and are open source?

0

This worked for me (took about 20min to complete, though):

# dd if=/dev/sr0 |sha256sum
2
  • This looks like a case of UUOC, only instead of cat you used dd. That's why it took 20 minutes. Jan 25, 2017 at 9:28
  • Sorry. Don't know what "UUOC" is.
    – Steven
    Jan 25, 2017 at 23:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .