Verifying CDs and DVDs with md5sum
27 December 2008 at 3:48 pm | In Guides, Linux | Leave a CommentTags: backup, Guide, Linux, md5sum, verification, verify
If you want to ensure the safety of your backups, it is critical to verify the data on a regular basis. With the advent of cheap CD-RW and DVD-RW drives, many people are now using CDs or DVDs as their primary backup medium. In this guide, I’ll show you how to verify the integrity of your CD or DVD backup set using a few simple command-line tools.
Verifying Individual Files
1. Checksum the original data using md5sum as follows. Open a terminal and navigate to the directory that contains the files you wish to backup:
cd ~/Documents/Pictures
Now we’ll md5sum all of the files in this directory and all subdirectories:
find * ! -type d -print0 | xargs -0 md5sum > md5sum.txt
There’s one problem with this command—it will checksum the output file (md5sum.txt). This causes a false checksum warning when you wish to verify the files. To remedy this, open md5sum.txt in a text editor and remove the line that refers to md5sum.txt. In the end, you should have a file that looks something like this:
9975c7ef5e33eb7b18a3b7a512a8d755 top100_080703/heic0702a.jpg
c0cdbfc6f4fa445f59af8de9fcc33951 planet_HD_209458b.png
38f50e2348c80fc2f125540e571c3f14 APOD/M42_hallasNr.jpg
2. Copy the files to CD or DVD. Make sure you also copy the md5sum.txt to the disc, so that you can use it to verify the backup later on. If you don’t copy the md5sum.txt file to the disc, keep it in a safe place and name it something like “checksum-backup-20081227-1.txt” so that you’ll remember which disc it corresponds with.
To verify the CD or DVD, open a terminal, navigate to your CD drive’s mounting point and mount the disc:
cd /media/cdrom
mount /media/cdrom
Now verify the contents with md5sum:
md5sum -c md5sum.txt
This will verify all of the files on the disc and output the results as follows:
top100_080703/heic0702a.jpg: OK
Transiting_planet_HD_209458b.png: OK
APOD/M42_hallasNr.jpg: OK
If at the end you don’t see anything else, that means all of your files were OK. Otherwise, you’ll get a message like this:
md5sum: WARNING: 5 of 134 computed checksums did NOT match
This means that some (5) of your files did not verify correctly and are probably corrupted. To narrow down the results to only the failed files, use the following:
md5sum -c md5sum.txt | grep -v 'OK$'
This will output all of the files that failed verification.
Verifying from an ISO File
If you have an ISO file that you’ve burned and you want to verify the disc, it’s very easy to do so.
1. Use isoinfo to find the block size and count of the ISO file (in our example it is called “name.iso”):
isoinfo -d -i name.iso
Look for these two lines, and write down the two values:
Logical block size is: 2048
Volume size is: 13656
2. Now find the md5sum of the disc (substitute /dev/dvd with the location of your CD drive):
dd if=/dev/dvd bs=block size from above count=volume size from above | md5sum
3. Finally compare the result with the md5sum of the ISO file:
md5sum name.iso
Make sure the result from step 3 matches the result of step 2. If they don’t match, that means your disc is either scratched, dirty, or corrupt.
No Comments Yet »
RSS feed for comments on this post. TrackBack URI
Leave a comment
Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.