Open matthijskooijman opened 3 months ago
As a side effect, this no longer assumes the rootfs is ext, which fixes incorrectly running e2label
on non-ext rootfs (e.g. f2fs as reported in #7).
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 sudo ./rpi-clone sda
.
Booted disk: mmcblk0 127.9GB Destination disk: sda 500.1GB
---------------------------------------------------------------------------
Part Size FS Label Part Size FS Label
1 /boot/firmware 512.0M fat32 bootfs 1 512.0M fat32 --
2 root 118.6G ext4 rootfs 2 465.3G ext4 --
---------------------------------------------------------------------------
== SYNC mmcblk0 file systems to sda ==
/boot/firmware (63.0M used) : SYNC to sda1 (512.0M size)
/ (102.9G used) : SYNC to sda2 (465.3G size)
---------------------------------------------------------------------------
Run setup script : no.
Verbose mode : no.
-----------------------:
Ok to proceed with the clone? (yes/no): yes
Syncing file systems (can take a long time)
Syncing mounted partitions:
e2label /dev/sda2 rootfs
Mounting /dev/sda2 on /mnt/clone
mount: (hint) your fstab has been modified, but systemd still uses
the old version; use 'systemctl daemon-reload' to reload.
=> rsync // /mnt/clone with-root-excludes ...
fatlabel /dev/sda1 bootfs
fatlabel: warning - lowercase labels might not work properly on some systems
Mounting /dev/sda1 on /mnt/clone/boot/firmware
mount: (hint) your fstab has been modified, but systemd still uses
the old version; use 'systemctl daemon-reload' to reload.
=> rsync /boot/firmware/ /mnt/clone/boot/firmware ...
Editing /mnt/clone/boot/firmware/cmdline.txt PARTUUID to use 41300809
Editing /mnt/clone/etc/fstab PARTUUID to use 41300809
===============================
Done with clone to /dev/sda
Start - 21:41:31 End - 21:41:59 Elapsed Time - 0:28
Cloned partitions are mounted on /mnt/clone for inspection or customizing.
Hit Enter when ready to unmount the /dev/sda partitions ...
unmounting /mnt/clone/boot/firmware
unmounting /mnt/clone
===============================
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!
Thank you for making this! (Also mentioned in the old branch, where I noticed it first: https://github.com/billw2/rpi-clone/issues/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 https://github.com/billw2/rpi-clone/pull/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.