Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
    
Do you mean to check the data on the CD right after it was burned ? Because most burning software tools have an option to check written data (ex Nero). –  Silviu May 27 '12 at 18:57
    
I know but I need to to do the check not right after the burning procedure but after some time (after the burning program was already closed), maybe even on a different PC. As far as I know Nero doesn't offer to initiate a verification procedure independently of a burning procedure - it's verification facility is only an add-on for burning and can happen only right after the burning. What I want is to insert a CD, choose an ISO file and click to verify... Another constraint is that I wan't to do this under Linux as I suspect my Windows CD/IDE driver is not ok. –  Ivan May 27 '12 at 19:12
    
That's really difficult , are you burning a bootable CD or pure data ? –  warl0ck May 28 '12 at 13:42
    
A bootable CD.. –  Ivan May 28 '12 at 20:01
add comment

3 Answers

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}
share|improve this answer
1  
cmp [-l] is better suited for binary files. Diff works best on text. –  derobert Sep 11 '12 at 15:21
add comment

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

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.

share|improve this answer
    
+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. –  vitiv Sep 11 '12 at 13:22
add comment

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).

share|improve this answer
    
diff -r will compare the directory contents recursively. –  Kevin May 27 '12 at 20:37
1  
Since 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 2:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.