How to check if the ISO was written to the USB stick without errors

checksumfilesystemsusb

I followed these DebianEeePC HowTo InstallUsingStandardInstaller instructions at the Debian Wiki, to write a Debian ISO to my USB.

dd if=debian-*-netinst.iso of=/dev/sdX

Using sha1sum, I can check the checksums of my downloaded ISO file. How can I check the checksum of the USB stick device, to be sure that the USB stick does not have any problems and that the ISO was copied perfectly?

Best Answer

You can use cmp for checking if everything was copied fine:

$ cmp -n `stat -c '%s' debian-X-netinst.iso` debian-X-netinst.iso /dev/sdX

This solution does not explicitly compute the checksum of your /dev/sdX - but you don't need to do that because you have already done this for the source of the comparison (i.e. debian-X-netinst.iso).

Doing just a dd if=/dev/sdX | sha1sum may yield a mis-matching checksum just because you get trailing blocks (/dev/sdX is most likely larger than the iso-file).

Via cmp -n you make sure that no trailing bytes on your /dev/sdX are compared.

If you are paranoid about the quality of your USB mass storage device you call sync, eject it, re-insert it and then do the comparison - else all or some blocks may just come from the kernels VM (cache) - when in reality perhaps bits on the hardware are screwed up.

Related Question