Rolling back btrfs subvolume with child subvolumes

btrfssnapshot

Is there a canonical way of rolling back to a subvolume snapshot that has child subvolumes. So for example, this is my btrfs volume layout:

ID 257 gen 59802 top level 5 path __active
ID 258 gen 59784 top level 5 path __snapshot
ID 259 gen 59802 top level 257 path home
ID 260 gen 36538 top level 257 path opt
ID 261 gen 59802 top level 257 path var

So you can see that home, opt, and var are child subvolumes of __active. If I snapshot __active such that this is my new layout:

ID 257 gen 59802 top level 5 path __active
ID 258 gen 59784 top level 5 path __snapshot
ID 259 gen 59802 top level 257 path home
ID 260 gen 36538 top level 257 path opt
ID 261 gen 59802 top level 257 path var
ID 416 gen 59784 top level 258 path __snapshot/__active

If I want to roll back to the snapshot of __active, is there a way to reattach home, opt, and var to the new __active?

Best Answer

If you mean with reattaching that your btrfs subvolume list would show:

ID 257 gen 59802 top level 5 path __active
ID 258 gen 59784 top level 5 path __snapshot
ID 259 gen 59802 top level 416 path home
ID 260 gen 36538 top level 416 path opt
ID 261 gen 59802 top level 416 path var
ID 416 gen 59784 top level 258 path __snapshot/__active

then no there is now way to do that with the btrfs-progs.

Sub-volumes can only be deleted if all the child-subvolumes (created with btrfs subvolume create ...) are empty, however this is not true for snapshots (which are created with btrfs subvolume snapshot .... Snapshots can always be deleted and so if you could move them, there would be a problem with removing the snapshot.

Although both child subvolumes and snapshots appear in the same tree structure, and even share the btrfs subvolume delete .. command, they don't act the same.

Related Question