Keep filesystem labels #101

Open
matthijskooijman wants to merge 5 commits from matthijskooijman/keep-fs-labels into master

5 Commits

Author SHA1 Message Date
Matthijs Kooijman
0ca374dcd8 Run udevadm settle after running parted
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.
2022-03-16 12:08:19 +01:00
Matthijs Kooijman
2f062a9589 Run parted with --script
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?
2022-03-15 22:35:09 +01:00
Matthijs Kooijman
3441dace22 Preserve existing FS labels where possible
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.
2020-07-14 14:42:04 +02:00
Matthijs Kooijman
74eb6a7572 Use previously retrieved destination root FS label
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.
2020-07-14 14:41:07 +02:00
Matthijs Kooijman
06abdd47ff Use lsblk to show all FS labels
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.
2020-07-14 14:40:26 +02:00