How to verify a burned CD or DVD image on Linux

There are multiple ways to verify CD or DVD burn in Linux.

=Using Graphical software=

=Method 1: Using X-CD-Roast)= After burning an image, within X-CD-Roast
 * Click Verify Tracks on the left side of the window.
 * Make sure the Read Device is the CD/DVD drive you are using, and the Image Directory is correct.
 * Select image you wish to verify, and click Verify selected tracks
 * A second window will popup, and compare the image to the CD/DVD
 * It may take some time to scan
 * It will show the results at end of scan

=Command line=


 * Create the following script
 * Make is executable
 * chmod 755 verifycd
 * Run the script
 * verifycd /dev/cdrom image.iso

Script
 * 1) !/bin/sh


 * 1) 	Usage:		verifycd CDROM_DEVICE ISO_IMAGE
 * 2) 	example:	verifycd /dev/cdrom image.iso
 * 3) References: http://www.troubleshooters.com/linux/coasterless.htm
 * 4)   http://howto.wikia.com/wiki/Howto_verify_a_burned_CD_or_DVD_image_on_Linux
 * 1) References: http://www.troubleshooters.com/linux/coasterless.htm
 * 2)   http://howto.wikia.com/wiki/Howto_verify_a_burned_CD_or_DVD_image_on_Linux

DEVICE=$1 IMAGE_FILE=$2
 * 1) Inputs

MD5SUM_ISO='md5sum-file.txt' MD5SUM_CD='md5sum-cdrom.txt'
 * 1) temp files

echo "Checking CD's block size, and count..." blocksize=`isoinfo -d -i $DEVICE | grep "^Logical block size is:" | cut -d " " -f 5` if test "$blocksize" = ""; then echo catdevice FATAL ERROR: Blank blocksize >&2 exit fi
 * 1) Checking cd's blocksize and count

blockcount=`isoinfo -d -i $DEVICE | grep "^Volume size is:" | cut -d " " -f 4` if test "$blockcount" = ""; then echo catdevice FATAL ERROR: Blank blockcount >&2 exit fi

echo "block size: $blocksize" echo "block count: $blockcount"

raw_read_command="dd if=$DEVICE bs=$blocksize count=$blockcount conv=notrunc,noerror"
 * 1) Command for reading disk

echo "Reading CD and creating check sum..." $raw_read_command | md5sum > $MD5SUM_CD echo "Reading ISO and creating check sum..." md5sum $IMAGE_FILE > $MD5SUM_ISO
 * 1) Getting checksums

echo "Comparing check sums..." cat $MD5SUM_ISO | while read CODE NAME; do    if [ -n "`cat $MD5SUM_CD | grep $CODE`" ]; then echo "Success: $NAME" else echo "Failure: $NAME" fi done
 * 1) Comparing md5 checksums

rm -f $MD5SUM_CD $MD5SUM_ISO
 * 1) Cleaning up

Script 2

The previous script may give false negative if the CD/DVD was not properly finished. This one should work even in such cases:


 * 1) !/usr/bin/bash

if [ $# -ne 2 ]; then echo "Syntax: $0 medium_device iso_file" exit 1 fi

dev="$1" iso="$2"

if [ ! -b "$dev" ]; then echo "Error: The first argument must be a block device." exit 2 fi

if [ ! -f "$iso" ]; then echo "Error: The second argument must be an ISO file." exit 3 fi

size="$(stat -c %s "$iso")"

echo "Verifying $size bytes..." cmp -n $size "$dev" "$iso"

if [ $? -eq 0 ]; then echo "The media and the ISO file are identical."; fi

=See Also=
 * X-CD-Roast
 * CDR/CDRW
 * DVDR/DVDRW

=Reference=
 * http://www.cpqlinux.com/cdrw.html

From HowTo Wiki, a Wikia wiki.