-
-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keep filesystem labels #16
base: master
Are you sure you want to change the base?
Keep filesystem labels #16
Conversation
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.
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.
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 billw2#100.
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?
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.
As a side effect, this no longer assumes the rootfs is ext, which fixes incorrectly running |
Just spotted your PR, after my Pi didn't boot after a clone So I did the thing: git clone https://github.com/matthijskooijman/rpi-clone.git
cd rpi-clone
git checkout keep-fs-labels And finally ended with a
I didn't really think about rsync should be able to get things sorted, without having to copy everything over again. It managed to fix it in a few seconds, and everyting worked as expected. Thanks! Also, here's the result of the first clone, with the good old branch:
Thank you for making this! (Also mentioned in the old branch, where I noticed it first: billw2#122) @geerlingguy Let's get this into the very kind and friendly fork 😄 ! |
This makes some changes to display and preserve all filesystem labels rather than just for ext filesystems.
Displaying of labels should be supported for any filesystem supported by the kernel (using lsblk), while copying labels is supported for a limited set of filesystems (just ext and fat for existing filesystems, a few more for new filesystems).
See the commit messages for some more details.
These changes were previously submitted at billw2#101 and have been in use in my project since that PR was submitted four years ago. Now I've just rebased and reviewed them, the changes still applied without issue.
This also fixes #7.