I have a simple question which so far I haven’t been able to find a simple answer for:
How do I clone my BTRFS root partition (all subvolumes) onto another BTRFS root partition (same size) on another disk, and make it bootable? This is to make a hot-swap backup disk.
(NOTE: I’ve done this before pre-BTRFS, but just discovered that with BTRFS, cpio and rsync aren’t sufficient anymore.)
The above advice will copy a whole disk of course and not just the partition. So for copying “only” the partition, the partition number should be added. Example:
dd if=/dev/sda1 of=/dev/sdb1 bs=1048576
And of course you must do this (as root) from a system that is not using (let alone being booted from) either of those partitions. Use e.g. a rescue system or other live system.
you might find this thread interesting, we where discussing how to do this, stratacast1 [17th January 2017, 04:47 PM] eventually uses the btrfs replace command (1 single command - automatically modifies fstab etc!), a second viewer also confirms the method.
I don’t really want to use dd, because it results in 1) duplicate UUIDs preventing simultaneous mounting/use, and 2) takes a long time (I’d already read this thread).
2) btrfs replace
This sounds closer to what I need, but as arvidjaar indicated, it’s unacceptable for building a “hot backup” (Writing to the source disk is unacceptable. It cannot write to the source partition; that’s the master copy!) It’s also not clear whether it replicates the subvolume structure of the partition.
**QUESTION?: **Does anyone know of a way to mirror a BTRFS root file system (including subvolumes) 1) without modifying the source partition, and 2) in such a way that source and dest can both be mounted?
(Just FYI, the reason I’m barking up this tree is I installed OpenSUSE 42.2 on a server at home, and the root partition is BTRFS and has *21 subvolumes! *Ordinary partition mirroring tricks (rsync, cpio, etc.) just don’t cut it. So far, it seems like letting OpenSUSE 42.2 use BTRFS on the root partition may not have been a good idea…)
Well use dd but change the boot to use by-id rather then UUID. This symbology uses the disk ID thus keeps cloned partition separate since there is no chance for duplicate symbols on partitions in the boot process with the cloned partitions.
You must NEVER present original and cloned btrfs at the same time. It has absolutely nothing to do with what link in user space you use to access individual device.
to educate my ignorance, can btrfs send receive not be used for this? (since it sends diffs, it would be absurdly fast if it matched your requirements)