How to validate a DVD against an ISO
The following command compares the contents of two binary files, and print the offset of the first differing byte. Replace /dev/dvd
by the path to the DVD device (/dev/cdrom
, /dev/scd0
, /dev/hdc
, …).
cmp /dev/dvd /path/to/foo.iso
I'm not sure if all DVDs contain an indication of where the data ends (I think some CDs don't); you can limit the comparison to the size of the image file.
ls -l /path/to/foo.iso # copy the file size, e.g. 123456789 bytes
cmp -n 123456789 /dev/dvd /path/to/foo.iso
You can also compute a checksum for the image file, compute a checksum for the disk, and check that they match. This is slower for a single comparison, but faster if you need to compare many disks against one image, and allows the image and the disk to be on different computers. To detect accidental corruption, md5sum
is perfectly suitable.
md5sum /path/to/foo.iso
md5sum /dev/dvd # if the size can be determined; otherwise:
head -c 123456789 /dev/dvd | md5sum
Since the question is not OS-specific and Windows users may find their way here, I’ll suggest that a relatively easy way to accomplish this on Windows is to mount the ISO (OSFMount is particularly good), then compare (e.g., with WinMerge) the CD/DVD drive root with the mounted volume root:
winmerge d:\ e:\
Here are the correct steps to verify 256sum of the iso before and after burning.
determine iso sha256sum..
$ sha256sum ubuntu-5.10-dvd-i386.iso
e41c0631f6f2c138a417b59bcb880fce
then determine size of iso in bytes...
$ wc -c ubuntu-5.10-dvd-i386.iso
3048179712
then dd your cd/dvd drive |then count the first bits of each file to sum |then read its sha256sum
$ dd if=/dev/sr0 | head -c 3048179712 | sha256sum
e41c0631f6f2c138a417b59bcb880fce
Substitute /dev/sr0 with /dev/cdrom or other drive name depending on system.
For a better DD experience and to view dd's progress in real-time without having to write a script, use dcfldd the forensic dd (dcfldd can port to 2 different outputs as well.)
sudo apt-get install dcfldd
(shamelessly stolen from an article on unbutu.com)