Verify a burned install DVD

I downloaded the openSUSE 11.1 ISO image, did an md5sum check, and burned a DVD using k3b.

Depending upon the k3b version and the hardware, sometimes k3b fails to verify for me.

So how to verify an already burned DVD given the original ISO image?

I did some Googling and wrote this script using what I’d learned. The comments acknowledge the URLs I found. It does two disk reads in succession in slightly different ways just to be extra paranoid.

I hope it helps someone. I hope I haven’t messed up.


#!/bin/sh
#
# Use this when k3b barfs when verifying a burn of an ISO image.
#

if test -z "$1" || test -z "$2" ; then

    echo "Usage: $0 iso_image_file optical_disk_device"

else

    iso=$1
    dev=$2

    bytes=$(ls -l ${iso} | awk '{ print $5 }')
    extents=$(( ${bytes} / 2048 ))

    # http://www.g-loaded.eu/2006/10/07/verify-a-burned-cddvd-image-on-linux/
    echo "optical disk ->${dev}<- md5sum (bytes method):"
    sudo dd if=${dev} | head --bytes=${bytes} | md5sum

    # http://wiki.linuxquestions.org/wiki/Md5sum
    echo "optical disk ->${dev}<- md5sum (extents method):"
    sudo dd if=${dev} bs=2048 count=${extents} | md5sum

    echo "original ISO image ->${iso}<- md5sum:"
    cat ${iso} | md5sum

fi

#
# Done.
#


Sample output


# verify-iso openSUSE-11.1-DVD-x86_64.iso /dev/sr0
optical disk ->/dev/sr0<- md5sum (bytes method):
2afee1b8a87175e6dee2b8dbbd1ad8e8  -
optical disk ->/dev/sr0<- md5sum (extents method):
2afee1b8a87175e6dee2b8dbbd1ad8e8  -
original ISO image ->openSUSE-11.1-DVD-x86_64.iso<- md5sum:
2afee1b8a87175e6dee2b8dbbd1ad8e8  -


When you boot it, there’s a verification option.

You can also mount it, and see how rpm --checksig does on the disk contents.

Unfortunately there’s not been a neat way of mounting the disk and running a script near top level to do the same check, without booting from BIOS.

So thanks! That looks rather nice to have.

Changing the straight md5sum a bit might be a touch faster.

echo "original ISO image -&gt;${iso}&lt;- md5sum:"
md5sum &lt; ${iso}

FWIW I accidentally swapped the two URL comments … :shame: