Ummm yeah, so be a bit cautious with cloning file systems. It will mean duplicate UUIDs and it will be ambiguous to the kernel which file system you want it to mount if the two drives are kept visible to the kernel following cloning. I’m not a super big fan of cloning except for data recovery purposes where you clone a drive, and put one of the copies in a safe place on a shelf. Duplicate fs UUIDs are bound to cause confusion either the kernel or human or both.
(a) just reinstall instead of cloning, and then rsync user data over to the new home or whatever.
(b) a better “clone” is something like
tar -acf bootefi.tar boot/
Now you have a copy of all the files in
/boot/efi in bootefi.tar located in the root directory, which means it’s on the Btrfs volume. Assume vda1 for ESP, vda2 for boot, vda3 for btrfs. And vdb is the new drive, with vdb1, vdb2, vdb3 partitions created already, but no formatting.
btrfs replace start /dev/vda3 /dev/vdb3 /
This is a live migrate vda3 to vdb3 for the Btrfs file system mounted at /. And in another shell you can do other things:
mkdosfs -n EFI /dev/vdb1
## update /etc/fstab with the new UUIDs for vdb
tar -xf bootefi.tar
In this case everything has its own unique fs UUID and you don’t need to worry about confusion. You will have to update the
efibootmgr to reflect the new fs UUIDs. So it’s not anywhere near as straightforward as just reinstalling. But no downtime, and quite fast because only in-use blocks are copied.
NOTE: Once this replace process completes, the original device (the one being replaced) has its magic wiped. This is not exactly a “clone” when the original goes bye bye. You can restore the magic but then Btrfs can’t tell the difference between the otherwise two exact copies - and that’s asking for confusion. What you probably want for cloning Btrfs is either: Btrfs send/receive to make “clones” of snapshots onto another device. You can use Btrfs on the receive side to get an exact copy of that snapshot. Or you can use any file system with the
btrfs send -f option.
For those who want to replicate an entire single Btrfs volume, all subvolumes and snapshots, then you want the seed device method. This is also quite fast. The “sprout” (the copy) gets its own fs UUID so there’s no confusion which is which.