md5sum on CD

D. Hugh Redelmeier hugh-pmF8o41NoarQT0dZR+AlfA at public.gmane.org
Wed Nov 23 21:57:40 UTC 2005


| From: Moniz Family <john.moniz-rieW9WUcm8FFJ04o6PK0Fg at public.gmane.org>
| 
| I'm having some problems burning CDs and am trying to check whether it's the
| burner or the CDs.

You've gotten some good advice -- like using the right hash.

Checking on a file-by-file basis is not really good enough.  There are
things that are not inside files.  For example, metadata.  Also (I
think) boot records.

But there is another problem that you might well be hitting.

See, for example:
  https://www.redhat.com/archives/fedora-list/2005-March/msg02774.html
  https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=151088

Summary:

 The Linux IDE CD driver in 2.6 tries to read ahead, even past the end of the
 CD or DVD.  Even when the program issuing the original read request was only
 trying to read legitimate parts of the disc (albeit near the end).
 The result is spurious I/O errors and read failures.
 It does not seem that this driver bug is going to be fixed soon.


To work around this problem, I wrote the two shell scripts that I have 
attached.

- isopad: add enough padding to prevent ide-cd read-ahead getting
  into trouble (can also remove the padding)

- isoburn: burn and check a .iso.  Uses isopad.
  Warning: you may have to adjust the settings of the shell variables
  "drive", "device", and "speed" to match your environment.
-------------- next part --------------
#!/bin/sh

# isopad [+] [-] isofile...
#
# The Linux IDE CD driver in 2.6 tries to read ahead, even past the end of the
# CD or DVD.  Even when the program issuing the original read request was only
# trying to read legitimate parts of the disc (albeit near the end).
# The result is spurious I/O errors and read failures.
# It does not seem that this driver bug is going to be fixed soon.
#
# This program is intended to facilitate a workaround.  It can pad (or unpad)
# a .iso file so that, when it is burned, the resulting disc will allow
# reads past the end of the content to succeed.
#
# "+" means pad the following .iso files.
# "-" means remove all padding.
# neither means test file and iso sizes.
#
# To see how much readahead is enabled on a drive: hdparm -a /dev/hdc
#
# Why do the padding in place, rather than on a copy of the file?
# .iso files are usually quite large so copying takes a lot of time and space.
#
# Copyright 2005 D. Hugh Redelmeier
# License: GPL
# Version: Sat Jun 18 02:31:48 EDT 2005

# stop at the least sign of trouble
set -u -e

# op is "", "-", or "+": operation to be performed
op=""

for fn
do
	case "$fn"
	in
	"-h"|"--help")
		echo "Usage: $0 [-|+|] isofile..."
		;;
	"+"|"-")
		op="$fn"
		;;
	*)
		isosize -x "$fn"
		isz=`isosize "$fn"`
		fsz=`stat --format='%s' "$fn"`

		# conventional block size for CDs
		bs=2048

		# my guess at a sufficient amount of padding (in blocks)
		pb=64

		if [ $fsz -lt $isz ]
		then
			echo "$fn is shorter ($fsz) than it should be ($isz)" >&2
			exit 3
		elif [ ` expr $fsz % $bs ` -ne 0 ]
		then
			echo "$fn file size ($fsz) is not a multiple of $bs" >&2
			exit 4
		elif [ ` expr $isz % $bs ` -ne 0 ]
		then
			echo "$fn isosize ($isz) is not a multiple of $bs" >&2
			exit 5
		else
			case "$op" in
			"")
				if [ $fsz -eq $isz ]
				then
					echo "$fn: isosize == file size == $fsz"
				else
					echo "$fn: isosize $isz; file size $fsz"
				fi
				;;
			"+")
				echo "$fn: padding with $pb blocks of $bs zero bytes"
				dd if=/dev/zero bs=$bs count=$pb >>"$fn"
				;;
			"-")
				if [ $fsz -eq $isz ]
				then
					echo "$fn: already $fsz bytes"
				else
					echo "$fn: truncating from $fsz to $isz bytes"
					dd if=/dev/null of="$fn" seek=$isz bs=1
				fi
				;;
			esac
		fi
		;;
	esac
done
-------------- next part --------------
#!/bin/sh

# isoburn [-cd|-dvd] isofile...
#
# This recipe encapsulates DHR's procedure for burning from a .iso file.
#
# Copyright 2005 D. Hugh Redelmeier
# License: GPL
# Version: Wed Jun 22 10:35:24 EDT 2005

# cdrom drive
drive=/dev/cdwriter

# options for cdrecord
device=ATA:1,0,0
speed=8

medium="-cd"

# strict; show commands as executed
set -u -e -x

for iso
do
	case "$iso" in
	"-cd"|"-dvd")
		medium=$iso
		;;
	*)
		echo -n "press ENTER when you have loaded a new blank CD: "
		read junk

		isopad - "$iso"
		isopad + "$iso"
		case "$medium" in
		"-cd")
			time cdrecord -v dev=$device speed=$speed -dao driveropts=burnfree "$iso"
			;;
		"-dvd")
			# spare bits: -use-the-force-luke=tty
			time growisofs -Z "$drive"="$iso" -use-the-force-luke=notray -use-the-force-luke=dao
			;;
		esac
		isopad - "$iso"
		time cmp --bytes `isosize "$iso"` "$iso" $drive
		# because of -e, we only get here if the test passes
		echo "Test passed."
		eject $drive
		;;
	esac
done


More information about the Legacy mailing list