It seems that parted can force a partition scan (observed on a removable
USB disk), which temporaly clears the filesystem labels from lsblk
output. To prevent this, call udevadm settle to wait until all udev
events are processed before continuing.
This makes it non-interactive and prevents the script from silently
hanging when parted finds something weird, e.g.:
$ sudo rpi-clone /dev/sda
Warning: The driver descriptor says the physical block size is 2048 bytes, but Linux says it is 512 bytes.
This just hangs, because parted is waiting for an answer:
$ sudo parted -m /dev/sda unit s print
Warning: The driver descriptor says the physical block size is 2048 bytes, but Linux says it is 512 bytes.
Ignore/Cancel?
Instead of only setting FS labels on ext partitions when specified with
the --label-partitions option and leave all other partitions unlabeled,
this tries to copy the source filesystem labels to the destination where
possible.
Setting labels requires filesystem-specific commands or mkfs options, so
not all filesystems are supported. For changing labels on existing
partitions, only ext and fat partitions are supported. For mkfs a few
more are supported, though these are probably not used in practice.
This also refactors some of the code, introducing a `mkfs_label()` and
`change_label()` function to prevent having to duplicate the
filesystem-type checking code.
This fixes#100.
Now labels are retrieved for all destination partitions, there is no
longer any point in separately retrieving the destination root label,
just use the previously retrieved label.
Previously, e2label was used, but that only works for ext partitions.
Using lsblk allows showing the filesystem labels for all filesystems
supported by the kernel.