md5sum on CD

D. Hugh Redelmeier hugh-pmF8o41NoarQT0dZR+AlfA at public.gmane.org
Fri Nov 25 16:28:10 UTC 2005


| From: Moniz Family <john.moniz-rieW9WUcm8FFJ04o6PK0Fg at public.gmane.org>

| I just burned a Knoppix ISO immage and used the -pad option (-pad
| padsize=15s). I gather the checksum would be changed after using the pad
| option? It did on mine anyway.

The phrase "the checksum" isn't a well-defined term with respect to a
cd -- the "length" of a cd, treated as a file isn't at all clear.

The normal way of checksumming a file is to read the file until EOF
and sum all the bytes you got.  Unfortunately, reading a raw cd until
EOF gives an undefined number of bytes.  If all were well, it would
give you all the bytes you wrote, plus perhaps some more.  But with
the 2.6 driver, the end is, uh, messy.

Luckily, the ISO 9960 form of CDs contains a field saying how long
the content is.  The isosize(8) command will tell you how many
significant bytes there are in the CD.

Unfortunately, the sha1sum command does not let you specify a number
of bytes to checksum.

So you need to do something like this (UNTESTED!):

  dd if=/dev/cdrom bs=2k count=$((`isosize /dev/cdrom` / 2048)) | sha1sum

The dd pipes just the right amount of the cd to the sha1sum program.

If you do this, the checksum should be the same for the CD and the
.iso.  Assuming that the .iso file itself hasn't been padded with
extra zeros (note: my isopad program does pad that file, but it can
unpad it too).  If the file is padded, you might need to do this:

  dd if=x.iso bs=2k count=$((`isosize x.iso` / 2048)) | sha1sum

Summary: you want to checksum just the significant bytes in the .iso
file and the CD.  The isosize command will tell you the length; other
sources for this length might include padding.
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list