You are not logged in.

#1 2023-08-17 06:31:30

slepy8
Member
Registered: 2023-05-06
Posts: 9

Understanding BTRFS - recovering from snapshots of @ subvolume

I'm trying to understand subvolumes and snapshoting.

I fstab I have this:

UUID    /    btrfs    rw,noatime,defaults,subvol=@    0    1
UUID    /home    btrfs    rw,noatime,defaults,subvol=@home    0    0
UUID    /boot/efi    vfat ........

I've created some files, created snapshots, deleted some files to test how it works.
List of subvolumes looks like this:

btrfs subvolume list /

ID 256 gen 372 top level 5 path @
ID 257 gen 307 top level 5 path @home
ID 263 ...top level 257 path @home/home-snapshot-1 
ID 265 ...top level 257 path @home/home-snapshot-2
ID 267 ...top level 257 path @home/home-snapshot-3
ID 269 ...top level 256 path root-snapshot-1
ID 270 ...top level 256 path root-snapshot-2

I looked into snapshot dierctories and all data are there.

When I mount @home snapshot using subvolid=xxx in /etc/fstab everything works like a charm.
/home directory goes back to particular snapshot.

But if I do the same with / . I always end up with the same state as it is now.
Even if snapshot directory has deleted data in it, after mounting this snapshot with fstab it's not there.
My conclusion:
- snapshots are done properly.
- mounting is not done properly.

What am I doing wrong here?

Offline

#2 2023-08-17 14:44:59

willemw
Member
Registered: 2013-02-19
Posts: 116

Re: Understanding BTRFS - recovering from snapshots of @ subvolume

Could this be boot related? Are you still booting into the old subvolume for / with Grub for example?

Offline

#3 2023-08-17 18:07:31

dulhaver
Member
Registered: 2023-08-17
Posts: 14

Re: Understanding BTRFS - recovering from snapshots of @ subvolume

slepy8 wrote:

I'm trying to understand subvolumes and snapshoting.

...
When I mount @home snapshot using subvolid=xxx in /etc/fstab everything works like a charm.
/home directory goes back to particular snapshot.

out of curiosity ... can you specify how exactly you do this? Is it an extra argument (if that is the correct term) in the fstab for /home, like

UUID    /home    btrfs    rw,noatime,defaults,subvol=@home,subvolid=xxx    0    0

Offline

#4 2023-08-17 19:23:56

slepy8
Member
Registered: 2023-05-06
Posts: 9

Re: Understanding BTRFS - recovering from snapshots of @ subvolume

dulhaver wrote:

out of curiosity ... can you specify how exactly you do this? Is it an extra argument (if that is the correct term) in the fstab for /home, like

UUID    /home    btrfs    rw,noatime,defaults,subvol=@home,subvolid=xxx    0    0

I tried using subvol=x with subvolid=xxx
and only subvolid=xxx

Both methods worked for @home
For @ worked none.

Offline

#5 2023-08-17 19:40:43

slepy8
Member
Registered: 2023-05-06
Posts: 9

Re: Understanding BTRFS - recovering from snapshots of @ subvolume

willemw wrote:

Could this be boot related? Are you still booting into the old subvolume for / with Grub for example?

I'm not an Arch Terminator.
Not shure where exactly to look for. Should I consider informations in /etc/grub.d/41_snapshots-btrfs ??

Offline

#6 2023-08-17 20:23:56

willemw
Member
Registered: 2013-02-19
Posts: 116

Re: Understanding BTRFS - recovering from snapshots of @ subvolume

Is Grub your bootloader? You could check the generated /boot/grub/grub.cfg file and look for "rootflags=subvol" to see which subvolume Grub is booting into.

Offline

#7 2023-08-18 05:02:35

willemw
Member
Registered: 2013-02-19
Posts: 116

Re: Understanding BTRFS - recovering from snapshots of @ subvolume

/etc/grub.d/41_snapshots-btrfs is owned by package grub-btrfs. I don't use that tool, but on its home page it mentions: "Automatically generate grub.cfg if you use the provided Systemd/ OpenRC service". Maybe you need to enabled that.

Offline

Board footer

Powered by FluxBB