burncd - verify burn

Gary W. Swearingen garys at opusnet.com
Mon Jul 25 17:37:30 GMT 2005


Brian Henning <brian.henning at gmail.com> writes:

> I would like to know a process to verify that I my cd burner has
> burned an ISO file correctly with burncd. I know I can take some
> precautions like checking the md5sum of the iso during a transfer from
> the Internet. I also read on the Internet that burncd does puts some
> extra padding at the end of the cd. I am not sure if that is true or
> not. Could someone tell me how to verify a cd burn?

Here's a crummy script I just used to burn and verify a CD, but I've
only tested it with the "cdrecord" setup.  Older versions of it worked
with "burncd" on older OS versions, but I can tell you that the reason
I'm using "cdrecord" is that my manual efforts to do this with
"burncd" on 5.4-RELEASE (and maybe 5.4-STABLE a couple weeks ago)
failed, because I couldn't "dd" a CD burned with "burncd". (IE, I
couldn't sucessfully "dd" /dev/acd0, while I could "dd" /dev/cd0).

(Search this for "diff" to find the "verify".  ISO images generally
get an extra two blocks of something on the CD "for run-out". See
"-isosize" description of "cdrecord" manpage.)

#!/bin/ksh -o posix

## mkisocd [-blank] -<speed> file_name
#
## This burns and compares a file to the beginning of the write-only CD (CD-R).
## This must be run by superuser.
#
#  Note that the CD burning software (burncd) often writes an ISO CD at least a block bigger than the file.
#  I'm not sure why. (It's not a hard disk file system block size thing.)

#BURNER=/usr/local/bin/readcd
BURNCD=/usr/sbin/burncd
CDRECORD=/usr/local/bin/cdrecord
BURNER=$BURNCD
BURNER=$CDRECORD

if [ "${1}" == -blank ]; then
    if [ ${BURNER} == ${BURNCD} ]; then
        BLANK="blank"
    else
        BLANK="blank=fast"
    fi
    shift
else
    BLANK=
fi
TEMP="${1#-}"
if [ "${TEMP}" != "$1" ]; then
    SPEED="${TEMP}"
    shift
else
    echo 'WARNING: nothing done; speed must be given as "-factor" (eg -16)'
    exit 1
fi

FILENAME="$1"

#DEBUG; echo "SPEED = '$SPEED', FILENAME = '$FILENAME'"
#exit

if [ ! -r "${FILENAME}" -o ! -f "${FILENAME}" ]; then
    echo "ERROR: The argument, \"${FILENAME}\", is not a readable regular file. Nothing done."
    exit 2
fi

## TBD REMOVE
##blocks=$(( $(ls -l "${FILENAME}" | awk '{print $5;}') / ${blockbytes} ))

blockbytes=2048  ## Block size of ISO CDs. Nothing else will work (esp, in dd command).
filebytes=$(stat -f "%z" "${FILENAME}")
fileblocks=$(( ${filebytes} / ${blockbytes} ))
if [ $(( ${fileblocks} * ${blockbytes} )) != ${filebytes} ]; then
    echo "ERROR: '${FILENAME}' is not a multiple of the CD blocksize, ${blockbytes}. Nothing done."
    exit 3
fi

echo "WARNING: About to burn this file (${filebytes} bytes, ${fileblocks} blocks) to CD."
ls -l "${FILENAME}"
echo -n "Ensure CD in burner and enter \"y\" to continue, else to abort: "

read
if [ "$REPLY" != "y" ]; then
    echo "You entered \"$REPLY\", so the command is aborting with nothing done."
    exit 4
fi

if [ ${BURNER} == ${BURNCD} ]; then
    DEV=/dev/acd0
    time burncd -f ${DEV} -s ${SPEED} ${BLANK} data "${FILENAME}" fixate
else
    DEV=/dev/cd0  ## cdrecord's default SCSI "dev" is in /usr/local/etc/<something>
    time cdrecord -v speed=${SPEED} ${BLANK} "${FILENAME}"
fi

if [ $? != 0 ]; then
    echo "ERROR: $BURNER failed. See above error message."
    exit 5
fi

beep 2&

sleep 2  ## ??

echo "NOTICE: Comparing \"${FILENAME}\" to the just-written CD. Please wait..."
if dd if=${DEV} count=${fileblocks} bs=${blockbytes} | diff - "${FILENAME}"; then
    echo "NOTICE: Comparison OK.  The CD seems OK."
else
    echo "ERROR: The CD and file differred."
fi

echo done

beep 3&

exit 0

# The End.


More information about the freebsd-questions mailing list