Child pages
  • Verifying a CD or DVD
Skip to end of metadata
Go to start of metadata

On this page DVD is used to mean CD or DVD.

Checksumming

 All checksum examples are for MD5 sums.

TODO: add SHA1 sum examples

The usual way to verify a DVD is to generate a checksum from it and check that against the expected result.

If you know the checksum for the DVD itself this is simple.  For example ...

dd if=/dev/dvd | md5sum

The complication arises when the known checksum is for the .iso, not for the DVD itself.  When a DVD is created from a .iso, extra data known as "padding" is usually written after the end of the .iso data. Only the data on the DVD that came from the .iso must be used when generating a checksum to compare with the .iso's checksum.

This can be done two ways:

  • Get the information from the DVD itself. This can be done using the isoinfo command:

isoinfo -i <DVD device file> -d
[note blocksize and number of blocks]
dd if=<DVD device file> bs=<block size> count=<number of blocks> status=noxfer | md5sum

For example

isoinfo -i /dev/sr0 -d
[snip]

Logical block size is: 2048
Volume size is: 351894
[snip]
dd if=/dev/sr0 bs=2048 count=351894 status=noxfer | md5sum
bcee4c03b704a9b62988505b7d8f3069 -

  • Get the information from the .iso file.

==> If the .iso file is on a mounted file system:

stat --format=%s <path of .iso>

This can be embedded in the command to generate the checksum:

dd if=<DVD device file> | head -c $(stat --format=%s <path of .iso>) | md5sum

For example:

dd if=/dev/sr0 | head -c $(stat --format=%s ubuntu-12.04-alternate-i386.iso) \
    | md5sum

==> If the .iso file is available online:

wget <URL of .iso>

… then cancel the command as soon as it has displayed the size of the file.

For example:

wget http://releases.ubuntu.com/precise/ubuntu-12.04.2-alternate-i386.iso
[snip]
Length: 725921792 (692M) [application/x-iso9660-image]
[snip]
[Ctrl+c to cancel]
dd if=/dev/sr0 | head -c 725921792 | md5sum

Byte-by-byte comparison

If the .iso file is on a mounted file system then

cmp <DVD device file> <path of .iso>

If the command ends with "EOF on <path of .iso>" or with no output then the DVD is verified.

For example

cmp /dev/sr0 ubuntu-12.04-alternate-i386.iso
[no output]
echo $?  # Just checking
0

  • No labels