PDA

View Full Version : Option to check burning quality



satimis
16th April 2008, 05:19 PM
Hi folks,


Ubuntu 7.04 server amd64
cdrecord


I can't figure out what option shall be up to check the quality of burning at finish. OR it needs a script to check it. In the latter case please advise where can I find the script. TIA


B.R.
satimis

carpetfeller
16th April 2008, 05:50 PM
I found this script which will burn and verify your cd:


#!/bin/bash

## 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.




I would edit it to make it smaller, the important parts of this script for verifying are the stat and dd commands.

daneel971
16th April 2008, 09:30 PM
I can't figure out what option shall be up to check the quality of burning at finish.
Do you mean, something to check if the burning procees was good?
For a data cd/dvd, I create with cfv a file with the md5 hash of each file I'm going to burn, and after the burn I use again cfv to check the burned data.
For a DVD-Video, I compare the md5 of the original iso with the burned DVD.
Finally, you can perform a read test with dvdisaster (it works even from the command line, no need for gui if you don't like it).

satimis
17th April 2008, 03:36 AM
I found this script which will burn and verify your cd:


#!/bin/bash

## 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.

Hi carpetfeller,

Thanks for your script. Where shall be an ideal place keeping this script? Thanks




I would edit it to make it smaller, the important parts of this script for verifying are the stat and dd commands.
I would be appreciated if you can keep me posted of the revised script. TIA


B.R.
satimis

satimis
17th April 2008, 03:52 AM
Do you mean, something to check if the burning procees was good?

Hi daneel971,


I burn data/image.iso CD/DVD with command w/o problem. But how to check the finished CD/DVD after buring? I have been looking around on man cdrecord/growisofs unable to figure out an option for automatically checking the data/image.iso burned after finish. On k3b there is such an option. k3b is only front-end.




For a data cd/dvd, I create with cfv a file with the md5 hash of each file I'm going to burn, and after the burn I use again cfv to check the burned data.

Could you please provide more detail. Thanks




Finally, you can perform a read test with dvdisaster (it works even from the command line, no need for gui if you don't like it).
What did you mean "with dvdisater"? What command line shall I perform? TIA


B.R.
satimis

daneel971
17th April 2008, 05:50 AM
cfv is in the repos, and I like it because it supports a lot of hash algorythms, but there are other tools that do the same.
Say you have a directory (with or without subdirectories) with the files you want to burn. cd into it and run

cfv -C -r -t md5 -f myhash.md5 list-of-file-with-wildcards
This will create a file (or more, in case of subdirs) called myhash.md5 with all the md5 hashes of the files. Create the iso (including the file with the hashes) and burn it. Mount the cd/dvd, cd into the mountpoint and run

cfv -r
This will check your files.

You can install "dvdisaster" (it's in the repos): this program is not a simple "burn-checker", but you can use it so as well - use the option for reading the media in search of errors: it will scan the surface of the cd/dvd searching for unreadable spots. It's fast and reliable, and the option to create an error correction file is interesting.

If you need to compare an ISO with the burned cd/dvd compute the md5 of both and compare them

cfv -C -t md5 -f myiso.md5 file.iso
cfv -C -t md5 -f burnediso.md5 /dev/cdrecorder

compare the hashes in myiso.md5 and burnediso.md5

satimis
17th April 2008, 03:46 PM
cfv is in the repos, and I like it because it supports a lot of hash algorythms, but there are other tools that do the same.
Say you have a directory (with or without subdirectories) with the files you want to burn. cd into it and run

cfv -C -r -t md5 -f myhash.md5 list-of-file-with-wildcards
This will create a file (or more, in case of subdirs) called myhash.md5 with all the md5 hashes of the files. Create the iso (including the file with the hashes) and burn it. Mount the cd/dvd, cd into the mountpoint and run

cfv -r

This will check your files.

You can install "dvdisaster" (it's in the repos): this program is not a simple "burn-checker", but you can use it so as well - use the option for reading the media in search of errors: it will scan the surface of the cd/dvd searching for unreadable spots. It's fast and reliable, and the option to create an error correction file is interesting.

If you need to compare an ISO with the burned cd/dvd compute the md5 of both and compare them

cfv -C -t md5 -f myiso.md5 file.iso
cfv -C -t md5 -f burnediso.md5 /dev/cdrecorder

compare the hashes in myiso.md5 and burnediso.md5
Hi daneel971,


The 2 examples are exactly what I was looking for. Wonderful. Thanks again

On running;

cfv -r

whether a report will be generated? Or w/o report only popup warning on mistake?


B.R.
satimis

daneel971
17th April 2008, 04:52 PM
cfv -r
searches recursively for sfv/md5/sha1/crc etc. files and parses them: result of the test will be printed on standard output, that is in your terminal.
On read error, it will continue to the next file in the list; in the case of a "dev/sr0" file, it will exit with error.
Read errors or shasum mismatch errors will be reported.

satimis
18th April 2008, 01:15 AM
cfv -r
searches recursively for sfv/md5/sha1/crc etc. files and parses them: result of the test will be printed on standard output, that is in your terminal.
On read error, it will continue to the next file in the list; in the case of a "dev/sr0" file, it will exit with error.
Read errors or shasum mismatch errors will be reported.
Noted with thanks


B.R.
satimis