rpi-clone icon indicating copy to clipboard operation
rpi-clone copied to clipboard

Keep filesystem labels

Open matthijskooijman opened this issue 4 years ago • 4 comments

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.

matthijskooijman avatar Jul 14 '20 12:07 matthijskooijman

This allowed me to clone Ubuntu 21.10, which I was unable to do previously. Thanks!

bodiya avatar Dec 15 '21 04:12 bodiya

I've added two more commits just now:

  1. To add --script to the parted commandline, to prevent rpi-clone locking up when parted asks a question. This is not strictly required to the main change of this PR, but because it touches the same code, putting this in a separate PR just adds conflicts for no real gain.
  2. To use udevadm settle after running parted, which could in some circumstances prevent labels from being read by triggering a partition scan (which temporarily hides labels and other info from lsblk).

matthijskooijman avatar Mar 15 '22 22:03 matthijskooijman

I have used this code to make a bootable clone of Ubuntu 21.10 thank you.

I did run into another problem however. If I leave the clone attached to the USB drive, the pi actually boots from the clone and not the original!

When I try to do an incremental update: ./rpi-clone sdb I get an error message:

Destination disk sdb is the booted disk. Cannot clone!

I verified that indeed the pi always boots from the sd card clone attached to the USB rather than the card attached directly to the pi's sd card slot.

I also verified that my pi is set to boot from SD but it seems that doesn't know which SD to boot from:

BOOT_ORDER=0x1 which means SD CARD: 0x1 | SD CARD | SD card (or eMMC on Compute Module 4). https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#raspberry-pi-4-bootloader-configuration

@eddiem5 ran into the same problem here: https://github.com/billw2/rpi-clone/issues/106 but @robustini solution was to use an old version of rpi-clone which will not work as I need your code changes.

Is there anyway around this so I can update my clone with incremental updates?

ioogithub avatar Apr 21 '22 00:04 ioogithub

I also verified that my pi is set to boot from SD but it seems that doesn't know which SD to boot from:

I'm pretty sure that the rpi will boot from its internal SD when configured like this, the rpi boot code probably doesn't even know that your USB card reader is an SD card (it's just "mass storage").

What I suspect might be happening, is that the old and new root filesystems have kept the same (PART)UUID, and the initrd is started from the real SD card, which then looks for the root filesystem based on a UUID, finds both the original and the clone and then picks the wrong one. There is code to fix this by changing and updating the PARTUUID, but maybe your Ubuntu is using UUID (filesystem UUID) rather than PARTUUID (partition UUID), which is not supported yet. If so, #140 might be helpful for you.

Also, I think that none of this is really related to this particular PR (I actually think things would have worked the same with an unpatched master), so if this probably persists, it might be better to open up a new issue rather than continuing this discussion here.

matthijskooijman avatar Apr 21 '22 10:04 matthijskooijman

I've resubmitted this PR in a more actively maintained fork: https://github.com/geerlingguy/rpi-clone/pull/16

matthijskooijman avatar Apr 05 '24 08:04 matthijskooijman