Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I want to compare the content of two disk images. (For example two disk images with gutsy n edgy) Is there a straight forward command for it in Unix?

share|improve this question

migrated from stackoverflow.com Mar 3 '11 at 5:34

This question came from our site for professional and enthusiast programmers.

add comment

2 Answers 2

rsync --delete -n -aPc /disk1/ /disk2/

This will not copy any files to disk2 nor delete and files from disk1 thanks to the -n, but it will show you any files which differ between the two filesystems.

share|improve this answer
1  
The question isn't clear but you may have to mount that image before you can compare (if it is an iso) –  trent Mar 3 '11 at 6:52
    
But i suppose for this to work my disk images would have to be mounted. Without mounting and simply having it as X.img files can i make a comparison? How about creating a hash value and comparing? –  user73304 Mar 6 '11 at 16:13
    
Yes, you could do md5sum foo.iso bar.iso –  Steven Mar 6 '11 at 16:47
    
@Steven: Hashes are vulnerable to hash collision. You could just diff img1.img img2.img if you want to be sure the images are identical. One disadvantage is that this won't report how the images are different... –  Borealid Mar 6 '11 at 20:04
    
If you're going to worry about md5 collisions on iso files, you should worry about collisions with rsync (which uses md5 along with a checksum). –  Steven Mar 6 '11 at 22:22
show 2 more comments

To compare disk images byte-for-byte and list all the differing bytes, you can run

cmp -l /path/to/first.img /path/to/second.img

This will compare everything, including any unoccupied space. If these are filesystem images and you want to do a file-against-file comparison, you need to mount them, then use a file comparison tool such as diff or rsync.

share|improve this answer
add comment

Your Answer

 
discard

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