Linux and Nagios‎ > ‎

Using MD5SUM to verify a DD image with the Original

posted 5 Aug 2012, 03:53 by Tristan Self
Firstly you create an image of a disk using dd. 

Say in this example you have a second harddisk on your comuter called: /dev/sdb you want to make a dd image of it and then verify it is identical to the source disk.

Step 1
Create the MD5 hash of the source disk as it is now.
# md5sum /dev/sdb > sdb.md5

Step 2
Create an image of the disk using dd, this will pickup all the disk contents, including any partitions within it and store it in the file "dev-sdb.dd."
# dd if=/dev/sdb of=/var/local/images/dev-sdb.dd conv=noerror,sync bs=4096

Step 3
Now create a MD5 has of the image file you just created.
# md5sum /var/local/images/dev-sdb.dd > sdb-img.md5

Step 4
Now verify the two are similar or not by comparing the two hashes using:
# cat *.md5
(This will display the two hashes one above the other, if the hash is different you source disk and image are not the same, however if they are both the same you have an exact copy.