checking a burned CD against an ISO

D. Hugh Redelmeier hugh-pmF8o41NoarQT0dZR+AlfA at public.gmane.org
Tue May 29 17:38:13 UTC 2007


| From: Sy Ali <sy1234-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org>
| Date: Tue, 22 May 2007 23:55:47 -0400

Oops -- I'm a week late.

| Because of some odd issue with k3b not verifying a burned disk, I went
| ahead and explored a better way to compare the disk.

This is a longstanding annoyance with Linux.  Here's something I wrote
about it on the Fedora list (see the rest of the thread too):
  http://www.redhat.com/archives/fedora-list/2007-May/msg01261.html

- I don't use md5sum to check CDs if I have a .iso on the hard drive.
  I just use cmp(1).  An undocumented feature of GNU cmp is that it
  can be told how many bytes to compare (--bytes=).  This avoids the
  need for dd / head and a pipe.  Too bad md5sum doesn't have such a
  feature.

- when I burn CDs, I pad them (see the fedora message).  This prevents
  Linux's readahead getting spurious I/O errors.

- the isosize(8) command is handy for finding the size of the actual
  .iso structure (not including any padding)

| DISK_MD5=`dd if=$DEVICE | head -c $FILESIZE | md5sum`

Piping a whole CD or DVD can make a Linux box sluggish (I haven't
tried it in a while so this may have been fixed).  My superstitious
guess is that it pointlessly evicts useful stuff from the buffer cache
for data that is only going to be used once.  Piping it twice is
probably worse!

The dd can do the function of head.  You just have to frame it in
terms of bs= and count=.  CDs normally have a blocksize of 2048 so the
size ought to be a multiple of 2048; isosize will even do division for
you!  Untested:
	COUNT=`isosize -d 2048 $DEVICE`
	DISK_MD5=`dd if=$DEVICE bs=2048 count=$COUNT | md5sum`
(You can determine the blocksize via isosize if you wish to be more
careful.)

BTW, the dd you used ought to provoke the read-ahead problem, even
with padding.  It reads until "the end".  A dd with appropriate bs and
count will not get into trouble if there is padding.
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list