Here is a shell script that will check the md5 hash of a burned disk and compare it to the hash of an iso image. Copy and paste it into your favorite text editor and save it as eg. hashcdrom.sh.
#Compares the checksums of an iso9660 image and a burned disk. #This script is released into the public domain by it's author. if [ -n "$BASH" ]; then shopt -s expand_aliases fi if [ -n "$FILE" ]; then FILE="$FILE" else FILE=`basename $0` fi if [ -n "$CHECKSUM" ]; then alias CHECKSUM="$CHECKSUM" elif which md5deep &> /dev/null; then alias CHECKSUM='md5deep -e' else alias CHECKSUM='md5sum' fi if [ -n "$2" ]; then DISKDEVICE="$2" else DISKDEVICE='/dev/cdrom' fi if [ -n "$1" ]; then CSUM1=$(CHECKSUM "$1" | grep --only-matching -m 1 '^[0-9a-f]*') echo 'checksum for input image:' $CSUM1 SIZE=$(stat -c '%s' "$1"); BLOCKS=$(expr $SIZE / 2048); CSUM2=$(dd if="$DISKDEVICE" bs=2048 count=$BLOCKS 2> /dev/null | CHECKSUM | grep --only-matching -m 1 '^[0-9a-f]*') echo 'checksum for output disk:' $CSUM2 if [ "$CSUM1" = "$CSUM2" ]; then echo 'verification successful!' else echo 'verification failed!' fi else echo '' echo 'Usage:' echo ' '$FILE' /path/to/iso [/path/to/cd/drive]' echo '' fi
Now open a terminal and type
sh /path/to/hashcdrom.sh /path/to/ubuntu-8.10-desktop-i386.iso /dev/mycdromdevice
Note that if your cdrom device is /dev/cdrom, you can omit that parameter.
It should print out something like
checksum for input image: 24ea1163ea6c9f5dae77de8c49ee7c03 checksum for output disk: 24ea1163ea6c9f5dae77de8c49ee7c03 verification successful!
If you verified that the iso image is okay (above), than you need not check the hash against UbuntuHashes.
This script has some nifty features. For example, if md5deep is installed (sudo aptitude install md5deep), it will use it to print out some progress information, such as how many bytes copied. You can also make it use different hashing algorithms such as sha256 and whirlpool by setting the CHECKSUM environment variable to the command you want to use to create the hash:
export CHECKSUM='whirlpooldeep -e' sh /path/to/hashcdrom.sh /path/to/ubuntu-8.10-desktop-i386.iso /dev/mycdromdevice
This shell script depends on certain features found only in GNU grep, so it probably will not work on systems that do not ship the GNU utilities.
A method using wodim instead of dd
readom dev=/dev/scd0 sectors=0-352113 f=- |md5sum
where 352113 is result of dividing size of iso file in bytes by 2048.
Check the files on the CD
The MD5 hashes for every file on the CD are listed in a file called md5sum.txt. You can use this file to check the integrity of all the files on the CD.
-
cd /media/cdrom md5sum -c md5sum.txt | grep -v "OK$"
This will automatically check every file against the MD5 hashes stored in the file and outputs any failures. (Again, you may need to change cdrom, depending on your system). Beware, it can take a long time so don't worry if your terminal seems to have hung; provided the CD drive is still accessing, it is probably still working. It should not output anything if it there were no errors, and an error message if a file failed the check. The grep command option -v "OK$" filters out all of the files that pass the check, because there are usually a lot of them.
Success?
Congratulations, you now have a verified Ubuntu CD. Go ahead and use it (or play frisbee with it if you want).