In the code below, change X into the path to the (iso-)image, you can check this by:
ls -AFl Documents/tails.ISO # X would be Documents/tails.ISO
And change Y into the right device identifier for the USB drive. You can check with lsblk
while it is not plugged in versus when it is plugged in to make sure you have the right device name (usually something like /dev/sdZ
).
The code to check whether what has been written to the USB drive corresponds to the image file used (in the bash shell!):
img='X' usb='Y'
[[ $(head -c $(stat -c '%s' "$img") "$usb" |sha256sum) = $(sha256sum <"$img") ]] &&
echo OK ||
echo ERROR
If you use a tool like GNU ddrescue (the package is often called gddrescue), you could write: ddrescue --force 'X' 'Y'
and it would automatically verify whether it was correctly written!
Note that by plugging the USB stick in and out, some partitions in the written image could get automatically mounted and thereby modified (the 'dirty bit') causing it to produce a completely different checksum!!
Is there any kind of checker that will check that the files on the bootable disk have integrity? How does one know if something got corrupted? Or if some viri or other stuff is in there in the OS?
That was a big problem on the WinXP OS system I was converting from.
– Niall Nov 08 '14 at 23:30check cd for defects
in the boot menu. – astrob0t Nov 08 '14 at 23:45It does bring up the question, if the USB image were to be corrupted by a viri, wouldn't it be possible for the malware to potentially fool the "check disc for defects" code, and report that all is well, even if it were to be infected with something?
– Niall Nov 09 '14 at 00:21check cd for defects
is nothing but a md5 compare of the individual files with the list of md5 values present in themd5sum.txt
file present in the cd. for better peace of mind, we can manually navigate to the usb folder and runmd5sum -c md5sum.txt
– astrob0t Nov 09 '14 at 00:29LXTerminal
(Lubuntu specific). You can find it via Menu -> Accessories -> LXTerminal or simply pressctrl+alt+t
to launch it – astrob0t Nov 09 '14 at 21:46g:
to switch to my USB drive, and then I typedmd5sum -c md5sum.txt
. However, it just gave me an error message saying'md5sum' is not recognized as an internal or external command, operable program or batch file.
– SarahofGaia Mar 19 '16 at 20:18md5sum
is an Ubuntu command, not a Windows command. If on windows, you can refer this article and see if it works for you. Comment back if you need more help. – astrob0t Mar 20 '16 at 07:04