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!!