# Method for verifying disk copy?



## Splatt (Aug 30, 2010)

Can any of you FreeBSD experts recommend a method for verifying that a disk copy (performed with dd) produced an exact copy of the source disk? I was thinking that maybe an MD5 hash of the disk would work, but I'm unsure how to do this (the md5 man page says it works on files).

I have need to do this with some FreeBSD systems, and want to be able to produce evidence that the copy didn't alter anything. Any suggestions would be appreciated.


----------



## UNIXgod (Aug 31, 2010)

You answered your own question. Yes md5 will create a hash code. check against the original and copy. if the numbers match then your evidence that you did a bit for bit copy is there.


----------



## wblock@ (Aug 31, 2010)

Getting an md5 of a disk is the same as dd-ing it to another disk, just pipe it to md5(1).

Hopefully you zeroed the target disk before the copy, or any extra data at the end of the disk will mess up the checksum.

If you've used the original disk since the copy, it won't match anyway: filesystem mount dates, access times, metadata changes.  mtree(8) might work.

There are better ways to duplicate a disk.


----------

