You are not logged in.

#1 2021-12-14 17:09:11

Cvlc
Member
Registered: 2020-03-26
Posts: 295

[SOLVED-mostly] Snapper / Btrfs subvolumes

Hi !

I have separate but related questions about subvolumes and snapper, which I can't seem to solve with the wiki only.

My current layout (which is wrong) is  :

$ sudo btrfs subvolume list /
ID 256 gen 50529 top level 5 path @
ID 257 gen 50514 top level 5 path @home
ID 258 gen 50539 top level 5 path @var
ID 259 gen 50518 top level 5 path @snapshots
ID 263 gen 49860 top level 258 path @var/lib/portables
ID 264 gen 49858 top level 258 path @var/lib/machines
ID 265 gen 50540 top level 257 path @home/<user>.homedir
ID 529 gen 35459 top level 259 path @snapshots/@-2021-10-27-21:39
ID 563 gen 40165 top level 259 path @snapshots/<user>.homedir-2021-11-24-23:34
ID 564 gen 44163 top level 259 path @snapshots/@-2021-12-04-15:47
ID 583 gen 50520 top level 265 path @home/<user>.homedir/.snapshots
  1. I mistakenly created the @var snapshot during install, instead of ie. @var/log. How can I fix this on an installed system ? More specifically, how do I transfer /var/log to the new subvolume without breaking anything ?

  2. Creating a config for root with snapper is supposed to create a subvolume at /.snapshots. But @snapshots is already mounted there with existing manual snaphots. Will that wipe my already existing snapshots or create havoc in any way?

  3. When I created the "homedir" config, Snapper created @home/<user>.homedir/.snapshots. Should I leave it there or move it to @snapshots for consistency ? I cannot find an option for snapshot destination in the config file snapper created though..

I kind of regret going for a flat layout, it felt like this was what was recommended, but it seems overly complicated now.

Thanks !

[edit]
I've never managed to make any sense of that sentence in the wiki :

Note: The following layout is intended not to be used with snapper rollback, but is intended to mitigate inherent problems with restoring / with that command.

How can there be problems restoring / with snapper rollback if it is not used ?

Last edited by Cvlc (2021-12-19 23:54:59)

Offline

#2 2021-12-14 17:15:05

ratcheer
Member
Registered: 2011-10-09
Posts: 924

Re: [SOLVED-mostly] Snapper / Btrfs subvolumes

I prefer a flat layout, but I don't use Snapper, so I can't really advise on your other questions. With a true flat layout, you would not put snapshots under your / directory.

Offline

#3 2021-12-14 17:17:12

Cvlc
Member
Registered: 2020-03-26
Posts: 295

Re: [SOLVED-mostly] Snapper / Btrfs subvolumes

Thanks. Do you take snapshots manually then ?

Last edited by Cvlc (2021-12-14 17:35:52)

Offline

#4 2021-12-14 20:52:47

ratcheer
Member
Registered: 2011-10-09
Posts: 924

Re: [SOLVED-mostly] Snapper / Btrfs subvolumes

Yes. It is simple. I mount the btrfs root subvolume of each drive (which is not to be confused with Linux /). That is where my snapshots subdirectories reside. Then, I create one read-only snapshot of each subvolume into those snapshots directories. Then I incrementally send/receive the snapshots to my external backup drive. Then I unmount the btrfs root subvolumes.

When I ran Snapper on openSUSE, I really found it more troublesome to keep Snapper from eating up all of my storage than to run my backups, manually, as above.

Offline

#5 2021-12-14 21:22:04

Cvlc
Member
Registered: 2020-03-26
Posts: 295

Re: [SOLVED-mostly] Snapper / Btrfs subvolumes

Yeah, but I like the idea of taking automatic snapshots every few hours for when I go out of my way to do something stupid smile

To get back to the above questions :

  • for /var/log, can I create the subvolume, cp /var/log into it, then edit fstab accordingly, and do mount -a ? 

  • for the snapper root config, I indeed had to umount/delete the existing /.snapshot dir, create the config, delete the new subvolume, then remount ./snapshots

Offline

#6 2021-12-19 23:13:54

Cvlc
Member
Registered: 2020-03-26
Posts: 295

Re: [SOLVED-mostly] Snapper / Btrfs subvolumes

Leaving a solution for reference, I successfully did the following change :

subvolid=5
  |
  ├── @
  ├── @home
  ├── @snapshots
  └── @var

to the following nested subvolumes

subvolid=5
  |
  ├── @ -|
  |       ├── /var/cache
  |       ├── /var/log
  |       ├── /var/tmp
  |
  ├── @home
  └── @snapshots

Don't know if this is optimal, but here is what did it, after booting a live Arch ISO :

# mount /dev/mapper/root /mnt

# btrfs subvolume create /mnt/@/var/cache
# btrfs subvolume create /mnt/@/var/log
# btrfs subvolume create /mnt/@/var/tmp

# mv /mnt/@var/cache/* /mnt/@/var/cache/
# mv /mnt/@var/log/* /mnt/@/var/log/
# mv /mnt/@var/tmp/* /mnt/@/var/tmp/
# mv /mnt/@var/{everything except cache,log,tmp} /mnt/@/var/

# btrfs subvolume delete /mnt/@var # check it's empty
# nano /mnt/@/etc/fstab # comment or remove the @var line which was there

# umount /mnt
# reboot

Maybe I could have copied over the whole of /mnt/@var, but I didn't know if that would somehow overwrite the newly created nested subvolumes...
I'm pretty sure there's a nicer way by snapshotting @var to the new nested subvolumes, and then deleting redundant files, but I couldn't get it to work and always got a level wrong like /var/cache/cache.... so reverted to the above.

Thanks for the help

Offline

Board footer

Powered by FluxBB