Raw Block Devices Comparison

block-deviceddhard-disk

Is there a utility (or some shell magic) that allows me to compare two block devices?

Details: I have one large (0.5 TB) RAID device that I've backed up to a slightly larger SATA device using dd. The device has several partitions on it, however I copy from the 'parent' device and not the partitioned device nodes (e.g., I copy /dev/hda and not /dev/hda1 for example).

I would like to verify that backup is good/correct.

I have thought about running md5sum across each device, however that won't give me an accurate result as the second device is slightly larger than the first and thus the extra bytes will change the hash.

Best Answer

I would use the command

cmp /dev/hda /dev/hdb

it will stop at the first differing byte, writing out its offset, or on EOF on the shorter one.

Related Question