Solution to checksum error and md5 sum error in Brasero, K3B and other burning software

If you happen to be one of those people who burn lot of iso's like we do through our RequestCD program then you would most probably have come across the dreaded checksum errors or md5sum errors. We used to get a lot of these and interestingly we found that we get consistent md5 checksum errors with certain iso images. We were almost sure that this had nothing to do with actual burning errors since they happened only for certain iso images. After hours of scouring the internet we found out the real culprit behind these errors and a way to really work around these phony error messages and actually verify if the iso was written correctly. We burn using either Brasero or K3B but this information can be applied to other cd/dvd burning software as well.

Of course we used to get checksum errors once in a while due to actual burning errors but the ones that were occurring for specific iso's did not really result in toasters. We were able to boot off these cds/dvds and perform full installations of the GNU Linux distros in them. Yes, this does not really prove that there were no errors in the actual writing process, but this got us suspicious. From our research online we got the following information

1) The burners burn in blocks of 32kB each.
2) When iso's are not exact multiples of 32kB they pad the iso's with 0's when they write them.
3) The burning software calculates the MD5 checksum on the original, unpadded iso image
4) The MD5 sum calculated after burning includes the padded zeros and will not match the original MD5 sum calculated on the iso if the size of the original iso was not a multiple of 32kB.

So we found our culprit. It is a limitation in the hardware device that causes these phony errors. Now we had to work around these errors. We found that by using the isoinfo command on the written media we could find the actual length of the data written on to the cd/dvd. Using this actual length and by raw reading using dd and piping to md5sum we were able to see that checksums calculated in this manner on cds and dvds written from the problematic iso's match those taken of the original isos.

Once we figured out this solution we scripted the whole process and created two scripts 'isomd5' and 'isosha1' to calculate the md5 and sha1 sums of the actual data written onto cds and dvds. We now use these to double check cds and dvds that are reported to have errors by K3B or Brasero. We have tested this script on Ubuntu 8.04 but this should work on any other GNU/Linux distro as well.

#!/bin/bash
filename=$1;
blocksize=`isoinfo -d -i $filename|grep "Logical block size is:"|sed 's/Logical block size is: //'`;
blockcount=`isoinfo -d -i $filename|grep "Volume size is:"|sed 's/Volume size is: //'`;
sha1checksum=`dd if=$filename bs=$blocksize count=$blockcount 2>/dev/null|sha1sum`;
echo -n -e $sha1checksum$filename\n|sed "s/\ *-/\ \ /"

Copy and save the above to /usr/local/bin/isosha1. Put your CD/DVD into your drive, say /dev/sdb. Calculate the checksum by running
isosha1 /dev/sdb

#!/bin/bash
filename=$1;
blocksize=`isoinfo -d -i $filename|grep "Logical block size is:"|sed 's/Logical block size is: //'`;
blockcount=`isoinfo -d -i $filename|grep "Volume size is:"|sed 's/Volume size is: //'`;
md5checksum=`dd if=$filename bs=$blocksize count=$blockcount 2>/dev/null|md5sum`;
echo -n -e "$md5checksum$filename\n"|sed "s/\ *-/\ \ /"

Copy and save the above to /usr/local/bin/isomd5. Put your CD/DVD into your drive, say /dev/sdb. Calculate the checksum by running
isomd5 /dev/sdb

Now the checksums generated using these scripts will match the checksums calculated on the original iso's.

Well not quite. Sometimes when the original creators of such isos come across this phony error situation they pad the iso with zeros before releasing the isos. Now the md5sum(or sha1sum) on the iso will match the md5 (or sha1) on the CD or DVD. The problem here is that, sometimes the creators of the isos forget to update the published md5sum (or sha1sum) with the new checksum calculated after padding the iso with the zeros. This would result in a situation where a checksum on the iso file will never match the published checksum. However in such cases if we run the iso through the isomd5 or the isosha1 scripts we will be able to generate the same checksum as was published at the creators site.

So the complete procedure to ensure that your cd's and dvd's are correct are as follows

1) Download iso and checksum from publishers website.
2) Calculate checksum on the downloaded iso and verify against the downloaded checksum.
3) If there is a mismatch in the checksum re-calucate the checksum using the isomd5 or isosha1 scripts.
4) If the re-calculated checksum also does not match the published checksum you have a corrupt download. Re-download or fix your corrupt iso using torrent.
5) Once the iso has been verified burn the iso using your favortite burning software.
6) If the software reports checksum errors after burning, re-calculate the checksum using the isomd5 or isosha1 scripts and verify against first the published checksums and if they don't match, then against the isomd5 or isosha1 checksums on the iso.
7) If one of the above matches the media was indeed burned successfully, if none matches you have run out of luck, you have a toaster :-).

Comments

Thanks!

Thanks much -- 'isomd5' saved my evening!

Why compute a checksum

Why go to all the trouble of calculating a md5 or sha1 checksum to see whether the burned disc has the same information as the original .iso file? It is less computationally intense and quicker simply to compare the two images byte-by-byte. Here is a simple script that I have been using for the past several years:


#!/bin/bash
# isocmp
# compare image on burned {cd,dvd} with its source file
# size=$(isosize -d 2048 $2)
# don't use isosize, in case the image is not really iso9660

case $# in
2) ;;
*) echo "usage: $0 /dev/cdrom /source/file.iso"; exit 2;;
esac
# get size of file in bytes. note ls -lL in case it's a symlink
size=$(ls -lL "$2" | gawk '{print $5}')

# do the real work here, compare device file and source file byte by byte
cmp --silent --bytes=$size $1 "$2"

# report result
case $? in
0) echo "good"; exit 0;;
*) echo "bad"; exit 1;;
esac

Thanks for sharing the script

Thank you for sharing the script. Yes you are right - it is faster to do a byte by byte comparison of an iso with a written disc. However the specific use-case which requires the iso-md5 strategy is where the md5 or the sha1 of the downloaded iso does not match the md5sum or sha1sum provided at the download site. That could happen if the checksums were calculated without the zero padding. But when that happens it would help to do the isomd5 strategy the first time to verify the downloaded iso and then your isocmp script would help to verify the written iso.

Anoop John

Thank you very much. I was

Thank you very much. I was tearing my hair out in frustration trying to figure out why my DVD md5 didn't match my iso's. You are a lifesaving genius.

awesome!

thank you!

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options