Wikia

How To Wiki

How to verify a burned CD or DVD image on Linux

Talk0
1,870pages on
this wiki

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

Using Graphical softwareEdit

Method 1: Using X-CD-Roast)Edit

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 lineEdit

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

Script

#!/bin/sh

######################################
#	Usage:		verifycd CDROM_DEVICE ISO_IMAGE
# 	example:	verifycd /dev/cdrom image.iso
#
# References: http://www.troubleshooters.com/linux/coasterless.htm
#   http://howto.wikia.com/wiki/Howto_verify_a_burned_CD_or_DVD_image_on_Linux


# Inputs
DEVICE=$1
IMAGE_FILE=$2

# temp files
MD5SUM_ISO='md5sum-file.txt'
MD5SUM_CD='md5sum-cdrom.txt'

# Checking cd's blocksize and count
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

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"

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

#Getting checksums
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

# Comparing md5 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

#Cleaning up
rm -f $MD5SUM_CD $MD5SUM_ISO 

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:

#!/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 AlsoEdit

ReferenceEdit

Around Wikia's network

Random Wiki