I've got a physical burnt CD and the original ISO image of it. No reference checksum files were provided for the CD contents. How do I check the actual CD is correct (corresponds to the original image) and fully readable?
5 Answers
If you still have the ISO, you can compare them byte by byte using cmp
. It's a simple enough command and it exits on the first difference it finds, so it's considerably faster than making a checksum if there actually is an error early on.
cmp /dev/cdrom /path/cdrom.iso
Possible outcomes on success:
- no output: it's identical and all OK. You may append
&& echo OK
to the command if the lack of output confuses you. cmp: EOF on cdrom.iso
: it's identical but the cdrom has more bytes than your iso file. This is usually due to zero padding at the end of the cdrom. Since that does not matter in practice, it's still a success.
Possible outcomes on failure:
cmp: EOF on /dev/cdrom
: for some reason the data on your CDROM is incomplete. Maybe your ISO was too large to fit a real CD./dev/cdrom cdrom.iso differ: byte 18296321, line 71780
: there is some unexpected difference between your CDROM and your ISO image.

- 48,978
First, you rip your CD to a temporary file:
dd if=/dev/sr0 of=copy.iso
Then you check if copy.iso
and orig.iso
have the same size, for example with:
stat -c '%s %n' orig.iso copy.iso
If the size is identical, it's easy:
sha1sum orig.iso copy.iso
But I noticed that in certain cases the size can be slightly different because there are trailing zeroes in either the copy or the original image. For example, if copy.iso
is smaller than orig.iso
:
sha1sum copy.iso
head -c $(stat -c %s copy.iso) orig.iso | sha1sum
Of course you should also check that the trailing bytes are just zeroes:
od -j $(stat -c %s copy.iso) orig.iso
The first line, except for the offset, should be zeroes only. The second line should be an asterisk. The asterisk is to avoid showing consecutive identical lines.

- 103
-
+1 for checksums. This is usually the de facto standard for comparing files(or directories) and not caring about knowing the differences(as is the case with diff): more minimal. – nikitautiu Sep 11 '12 at 13:22
-
or you can do
head -c $(stat -c %s /path/to/master.iso) /dev/sr0 | sha1sum
to avoid needing to make an image of the burnt CD. – Hitechcomputergeek Dec 21 '16 at 21:57
If the ISO file is the same one used to burn the CD, then here are my two favourites:
diff /dev/sr0 /tmp/file.iso
Compares the recorded image against the image file. If you feel a bit more masochistic, you could try something like this:
sha1sum /dev/sr0 /tmp/file.iso
and compare the signatures. This one's more useful if you already have the SHA1 sum somewhere. Both commands will read the medium to the end.
If you want to do it the way @Marki555 suggests, you'll want to mount both optical drive and image first. Here's a complete script: (you can, of course, dispense with the sudo
if you're root — a bad idea, in general)
sudo mkdir /tmp/{a,b}
sudo mount /dev/sr0 /tmp/a -o ro # or whatever
sudo mount /tmp/file.iso /tmp/b -o loop,ro
diff -dur /tmp/{a,b}
sudo umount /tmp/a
sudo umount /tmp/b
sudo rmdir /tmp/{a,b}

- 19,157
You can check that CD is fully readable by using dd
(for example dd if=/dev/cdrom of=/dev/null
). But you can't compare it directly with an ISO image. Each software will create slightly different ISO file (maybe some different headers, or padding), although these different ISO images will all provide the same CD contents (directory structure, file attributes and file contents).
So you can only mount the CD, mount the ISO image and compare it at filesystem level by using some kind of directory comparison tool (sorry, I didn't use any yet on linux).

- 2,098
-
-
5Since the cd was burned from an already prepared iso image, there's nothing to be built differently when burning, so you can directly compare the cd with the iso image. – psusi May 28 '12 at 02:35
Brasero can do that: Tools -> Check integrity...

- 96
-
Brasero is a (Gnome) graphical application available in any Linux distribution. Install it and then go Edit -> Plugins and check File checksum (is checked by default). See here – Milan Kerslager Apr 21 '20 at 19:16
md5sum
yourself and compare, if you don't want to boot the CD/DVD. – Skylar Ittner Apr 28 '19 at 20:14