Can an integrity check be run against a USB boot disk?

Is there a way to perform an integrity check on a ready-to-use USB boot disk?

I just made a Lubuntu 14.04.01 boot USB, and have not been able to figure out how to run an integrity check on it. I can't find any .iso file to run an MD5sum hash against.


Solution 1:

You can find the md5sum of an Ubuntu iso here.

The above md5 value is the checksum of the entire disk, not of the individual files.

When you prepare a bootable USB, the files from the iso file are copied over to the USB and the bootloder of the USB is overwritten, thus making it bootable. You see here, a single file(for ex, lubuntu 14.04.1 x64 iso) with a md5 sum(a5f97cd6a9f171c70cf816de8728f13b) is now destroyed and multiple files are present in the USB instead. So you don't have an iso anymore to compare the original lubuntu iso's md5 sum to.

If you want to check the integrity of each of the individuals files, then you need to boot from the USB and then select check cd for defects from the boot menu. There's a file ms5sum.txt in each ubuntu iso which contains the md5sum of each individual file in the iso. The check cd for defects option verifies the md5sum of each file with the md5 list present in the iso.

From LiveWireBT's answer, just navigating into the usb drive and running md5sum -c md5sum.txt should perform a consistency check of the individual files.

Solution 2:

Hashes of individual files contained in the ISO image are stored in the root folder as md5sum.txt.

Running md5sum -c md5sum.txt in the same folder should perform a consistency check.

Solution 3:

My answer is based on Lucas's answer in Unix and Linux StackExchange. To check the integrity of a usb boot disk, first find the size of the iso image with

 stat -c '%s' imagename.iso 

This will output an image size which you can enter in place of <imagesize> in the command below. The next command sends (through a pipe) all bytes corresponding to the size of the image to the md5sum command :

sudo head -c <imagesize> /dev/sdb1 | md5sum

You can compare this with the md5sum of your .iso file.

md5sum imagename.iso

If md5sums are different then there was an issue while copying the data. If md5sums are the same, you have successfully checked data integrity on your usb disk!

Note on locating your usb device under /dev/

For the command above, you need to know the name of your usb device such as /dev/sdbX, not the mount point (such as /media/usbX). You can find out by looking at the column Filesystem, in the output of df. For example my usb device appears as /dev/sdb1 in the output of

df