Tool to check that cloning was successful
Cloning from an image file, typically an iso file, to a USB drive is considered a robust process, but sometimes it fails. Maybe this is caused by problems with buffering when a big iso file is cloned to a pendrive with slow memory cells, maybe caused by flaky memory cells.
Anyway, I see that we need a convenient way to check that cloning was successful, so I created a small shellscript.
diff-image-drive
makes it easy to check by means of comparing the sha256sums.
Demo using the original version of the shellscript:
At first there is some previous content in the target device, an SSD connected via a USB to SATA adapter:
$ sudo diff-image-drive mantic-desktop-amd64.iso /dev/sdc
Comparing content of 'mantic-desktop-amd64.iso' and '/dev/sdc'
partprobe:
umount /dev/sdc*:
done - no partition mounted on /dev/sdc
calculating sha256sums ...
2,92GiB 0:00:18 [ 163MiB/s] [================================================================>] 100%
file: cdfaafb6be7b4b183b43bf395f7a1e12b14bcc6914c13ca8246a4cb00254ef6e -
2,92GiB 0:00:14 [ 203MiB/s] [================================================================>] 100%
device: ac65f5bb93207976cf59e4440147ffdda40e6e0ac3a3f964f525c0063660b51d -
content of iso/img file and device differ
After cloning from the mantic iso file to the target device:
$ sudo diff-image-drive mantic-desktop-amd64.iso /dev/sdc
Comparing content of 'mantic-desktop-amd64.iso' and '/dev/sdc'
partprobe:
Warning: Not all of the space available to /dev/sdc appears to be used, you can fix the GPT to use all of the space (an extra 462737388 blocks) or continue with the current setting?
umount /dev/sdc*:
done - no partition mounted on /dev/sdc
calculating sha256sums ...
2,92GiB 0:00:14 [ 208MiB/s] [================================================================>] 100%
file: cdfaafb6be7b4b183b43bf395f7a1e12b14bcc6914c13ca8246a4cb00254ef6e -
2,92GiB 0:00:14 [ 204MiB/s] [================================================================>] 100%
device: cdfaafb6be7b4b183b43bf395f7a1e12b14bcc6914c13ca8246a4cb00254ef6e -
content of iso/img file and device match
In this case you need not worry about the warning from partprobe. A drive cloned from an iso file does not care about what is behind the cloned field.
Screenshots using version 1.3 of the shellscript:
The color high-lighting is there also in the original version, but checking when skipping head/tail is new. This helps checking when a drive cloned from an Ubuntu iso file has been used (so that a 'writable' partition was created).

Checking directly after cloning.

Checking after the drive was booted into.
You can find more details via this post and the following posts to my thread at the Ubuntu Forums.