
250
|
Chapter 11: Backing Up Data
Verifying the Recording
After you’ve recorded a CD or DVD, it’s a good idea to verify that the recording
reads back correctly. The media may be defective, or the computer may have been
bumped during the recording, causing the laser to be moved out of the groove.
The correct way to verify a recording is to either compare the sectors recorded with
the sectors on the hard disk or generate checksums of those sectors and compare
them. Both methods must be used only with the actual data sectors, not the padding
sectors. The following bash shell script makes this verification easy when the origi-
nal ISO image file is available:
#!/bin/bash
if [[ $# -lt 1 ]] ; then
echo "usage: isomd5 <file_or_device> ..." 1>&2
exit 1
fi
for name in "$@" ; do
isoinfo -di "${name}" 1>/dev/null || exit 1
done
for name in "$@" ; do
count=( $( isoinfo -di "${name}" \
| egrep "^Volume size is: " ) )
count="${count[3]}"
bsize=( $( isoinfo -di "${name}" \
| egrep "^Logical block size is: " ) )
bsize="${bsize[4]}"
md5=$( dd \
if="${name}" \
ibs="${bsize}" \
obs=4096 count="${size}" \
2>/tmp/isomd5.$$.err \
| md5sum )
if [[ $? != 0 ]] ; then
cat /tmp/isomd5.$$.err
rm -f /tmp/isomd5.$$.err
exit 1
fi
rm -f /tmp/isomd5.$$.err
echo "${md5:0:32}" "" "${name}"
done
This script works by obtaining the number of sectors used by the ISO filesystem in
the image file. It limits the number of sectors read