Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is there a command that compares a floppy disk image (e.g. a .iso file) to the actual contents of the floppy the image was written on (e.g. /dev/fd0)?

share|improve this question
add comment

3 Answers

up vote 6 down vote accepted

A floppy device file is a file. Any command that reads files will work on it.

cmp /dev/fd0 image.fat

Pass the -l option if you want a list of all differing bytes; for human consumption, this is mostly useful in the form

cmp -l /dev/fd0 image.fat | wc -l

to know how many bytes differ. Run cmp -s /dev/fd0 image.fat if you don't want any output, just a return status of 0 if the two files are identical and 1 if they're different.

This compares the images byte by byte. If the floppy and the image contain files and you only want to compare the files and not the metadata (file dates, etc.) nor the empty space, mount the floppy and the image and compare the directory trees.

share|improve this answer
    
I like my answer better just because it manages to use bash's black <(...)-magic ;o) –  jippie Nov 25 '12 at 21:27
add comment

Because a floppy device is effectively seen as a file, you can also compare hashes (like SHA1 or MD5) of the floppy device (/dev/fd0) and of the disk image.

share|improve this answer
add comment

I don't have a floppy disk any more to check, but I'd guess:

diff <( dd if=/dev/fd0 ) floppy.img

the <( dd ..... ) reads the contents of the floppy and acts as if it is a file to diff. Then diff compares it to the file.

share|improve this answer
2  
cmp is a drop-in replacement for diff in this particular case. Kudos to Gilles for the cmp hint. –  jippie Nov 25 '12 at 21:07
    
<(dd if=dev/fd0) is an awfully complicated way of writing /dev/fd0`. Are you sure you didn't mean to write diff <( cat /dev/fd0 | dd if=- | tee /dev/fd/3 3>&1 | tr a-z a-z | tail -n +1) floppy.img? And on top of that diff tends not to cope with binary data well, cmp is the right tool here. –  Gilles Nov 25 '12 at 21:38
    
@Gilles: you forgot the spaces I put in <( dd if=/dev/fd0 ). But OK, you made your point; I just wasn't sure if a plain /dev/fd0 would read from the device rather than checking the device node itself. That's why I added the black magic <( ... ). –  jippie Nov 25 '12 at 21:45
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.