Ideas for using LVM+BTRFS clone and keeping up to date?

Notice: Page may contain affiliate links for which we may earn a small commission through services like Amazon Affiliates or Skimlinks.

AveryFreeman

consummate homelabber
Mar 17, 2017
413
54
28
42
Near Seattle
averyfreeman.com
So this is fun,

I just woke up to a clone job of my laptop being finished, it was kind of an experiment. It runs OpenSUSE, so it's got a BTRFS root and snapshots triggered by package manager.

I wanted to back it up so I could have a copy of the machine to run elsewhere, here's how I did it:

I attached an iSCSI LUN and ran

Code:
export ORIG=/dev/nvme2n1
export TARGET=/dev/disk/by-path/ip-192.168.1.45:3260-iscsi-iqn.2003-01.org.linux-iscsi.osuse-leap.x8664:sn.0000-lun-3

losetup --partscan --read-only --show --find $ORIG

partclone.dd -N -s /dev/loop12 -o $TARGET
Where /dev/loop12 is the read-only image of the $ORIG drive created to avoid changes while copying, and $TARGET is the path to the iSCSI LUN.

I detached the target and it didn't complain:

Code:
 iscsiadm -m node -T iqn.2003-01.org.linux-iscsi.osuse-leap.x8664:sn.0000 --portal 192.168.1.45 -u
It looks like it worked great

So now I have this iSCSI copy and I'm wondering if you guys have ideas for the ongoing struggle:

1) how to run it (I was just going to attach it to an ESXi VM, but would love to hear other ideas like making a container w/ X11 forwarding)

2) how to keep it up to date - this is going to be the interesting part

I was thinking I would avoid running any updates on the clone, but rather get a setup going where the BTRFS snapshots are sent after updates on the laptop. It has a separate ext4 home partition, so that shouldn't get in the way.

I'm not real familiar with LVM or BTRFS, but I'm guessing I can send BTRFS snapshots kind of like zfs? How would one go about doing something like that?

And would the LV present any challenges?

Here's the list of subvolumes attached:

Code:
btrfs subvol list /
ID 256 gen 35842 top level 5 path @
ID 257 gen 38580 top level 256 path @/var
ID 258 gen 38559 top level 256 path @/usr/local
ID 259 gen 38580 top level 256 path @/tmp
ID 260 gen 37105 top level 256 path @/srv
ID 261 gen 37922 top level 256 path @/root
ID 262 gen 38506 top level 256 path @/opt
ID 263 gen 37104 top level 256 path @/boot/grub2/x86_64-efi
ID 264 gen 37776 top level 256 path @/.snapshots
ID 270 gen 35842 top level 257 path @/var/lib/machines
ID 381 gen 36701 top level 257 path @/var/lib/docker/btrfs/subvolumes/9e04278fc86cc3299
aa8da183b16f9cb8f799db1ffecf56078958beefb92de70
. . . (more docker) . . . 
ID 674 gen 38567 top level 264 path @/.snapshots/350/snapshot
ID 699 gen 30785 top level 264 path @/.snapshots/375/snapshot
ID 700 gen 31431 top level 264 path @/.snapshots/376/snapshot
. . . (more snapshots) . . .
And here's lvdisplay:

Code:
# lvdisplay
File descriptor 36 (anon_inode:inotify) leaked on lvdisplay invocation. Parent PID 3662: bash
  --- Logical volume ---
  LV Path                /dev/system/swap
  LV Name                swap
  VG Name                system
  LV UUID                --
  LV Write Access        read/write
  LV Creation host, time install, 2022-01-01 09:22:07 -0800
  LV Status              available
  # open                 2
  LV Size                31.14 GiB
  Current LE             7972
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     1024
  Block device           254:1
  
  --- Logical volume ---
  LV Path                /dev/system/home
  LV Name                home
  VG Name                system
  LV UUID                --
  LV Write Access        read/write
  LV Creation host, time install, 2022-01-01 09:22:08 -0800
  LV Status              available
  # open                 1
  LV Size                286.86 GiB
  Current LE             73437
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     1024
  Block device           254:2
  
  --- Logical volume ---
  LV Path                /dev/system/root
  LV Name                root
  VG Name                system
  LV UUID                --
  LV Write Access        read/write
  LV Creation host, time install, 2022-01-01 09:22:33 -0800
  LV Status              available
  # open                 1
  LV Size                158.43 GiB
  Current LE             40559
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     1024
  Block device           254:0
Obviously I redacted the LV UUIDs, but I wanted to mention they are no longer identical (same on both orig and clone), in case that is something to be considered.

What would you do in this situation?