Is there a correct way to install with BTRFS?

First, I have a working system with EOS. So no real problems but I don’t know if I have things installed correctly with respect to btrfs. When I installed I wiped everything out and chose the default for btrfs with no swap. I later implemented swap on zram. I ended up with an fstab that looks like:

UUID=CF54-F181                            /boot/efi      vfat    defaults,noatime 0 2
UUID=fab39bc8-9e93-4759-945f-758257c0aeb4 /              btrfs   subvol=/@,defaults,noatime,compress=zstd 0 0
UUID=fab39bc8-9e93-4759-945f-758257c0aeb4 /home          btrfs   subvol=/@home,defaults,noatime,compress=zstd 0 0
UUID=fab39bc8-9e93-4759-945f-758257c0aeb4 /.snapshots    btrfs   subvol=/@snapshots,defaults,noatime,compress=zstd 0 0
UUID=fab39bc8-9e93-4759-945f-758257c0aeb4 /var/cache     btrfs   subvol=/@cache,defaults,noatime,compress=zstd 0 0
UUID=fab39bc8-9e93-4759-945f-758257c0aeb4 /var/log       btrfs   subvol=/@log,defaults,noatime,compress=zstd 0 0

I made sure I did not have any subvolid= options.
I followed the Archlinux wiki on snapper to set my subvol for @snapshots and then the recommended way of installing snapper.
I also installed grub-btrfs and snap-pac.

I really don’t understand why snapper can’t be installed without the @snapshots subvol being created first and it’s not clear why you have to unmount /.snapshots and the rm /.snapshots before configuring snapper, then deleted the subvol it creates during configuration. I’d love a clear explanation of that.

I know that you can just install eos with btrfs, then install snapper and a AUR btrfs-assistant and use that to configure snapper and manage all you taking and restoring of snapshots using that tool for both /root and /home.

So what is really missing between this 2 methods? Is it related to being about to use grub to boot into a ro snapshot?

There’s also the debate about not using snapper rollback while booting into one of your ro snapshots to restore. I see a lot of instructions on the web to follow but not enough explanation as to why. Being a computer engineer for 50 years makes me want to know why.

Thanks for any answers ahead of time.

BTW if it helps below are my subvol list and default subvol:

btrfs su get-default /
ID 697 gen 10013 top level 258 path @snapshots/238/snapshot
btrfs su list /
ID 258 gen 23439 top level 5 path @snapshots
ID 259 gen 23237 top level 5 path @cache
ID 260 gen 23542 top level 5 path @log
ID 266 gen 23438 top level 662 path @home/.snapshots
ID 276 gen 261 top level 258 path @snapshots/8/snapshot
ID 277 gen 263 top level 266 path @home/.snapshots/4/snapshot
ID 662 gen 23542 top level 5 path @home
ID 663 gen 9873 top level 266 path @home/.snapshots/131/snapshot
ID 695 gen 23541 top level 5 path @
ID 697 gen 10013 top level 258 path @snapshots/238/snapshot
ID 698 gen 10027 top level 266 path @home/.snapshots/133/snapshot
ID 723 gen 11445 top level 266 path @home/.snapshots/146/snapshot
ID 724 gen 11445 top level 258 path @snapshots/251/snapshot
ID 771 gen 14121 top level 266 path @home/.snapshots/170/snapshot
ID 772 gen 14122 top level 258 path @snapshots/275/snapshot
ID 819 gen 15873 top level 266 path @home/.snapshots/194/snapshot
ID 820 gen 15873 top level 258 path @snapshots/299/snapshot
ID 867 gen 17417 top level 266 path @home/.snapshots/218/snapshot
ID 868 gen 17417 top level 258 path @snapshots/323/snapshot
ID 919 gen 19648 top level 266 path @home/.snapshots/242/snapshot
ID 920 gen 19649 top level 258 path @snapshots/351/snapshot
ID 967 gen 21156 top level 266 path @home/.snapshots/266/snapshot
ID 968 gen 21156 top level 258 path @snapshots/375/snapshot
ID 1015 gen 22698 top level 266 path @home/.snapshots/290/snapshot
ID 1016 gen 22699 top level 258 path @snapshots/399/snapshot
ID 1025 gen 22983 top level 266 path @home/.snapshots/295/snapshot
ID 1026 gen 22983 top level 258 path @snapshots/404/snapshot
ID 1027 gen 23044 top level 266 path @home/.snapshots/296/snapshot
ID 1028 gen 23044 top level 258 path @snapshots/405/snapshot
ID 1029 gen 23101 top level 266 path @home/.snapshots/297/snapshot
ID 1030 gen 23101 top level 258 path @snapshots/406/snapshot
ID 1031 gen 23159 top level 266 path @home/.snapshots/298/snapshot
ID 1032 gen 23159 top level 258 path @snapshots/407/snapshot
ID 1033 gen 23216 top level 266 path @home/.snapshots/299/snapshot
ID 1034 gen 23216 top level 258 path @snapshots/408/snapshot
ID 1035 gen 23223 top level 258 path @snapshots/409/snapshot
ID 1036 gen 23226 top level 258 path @snapshots/410/snapshot
ID 1037 gen 23229 top level 258 path @snapshots/411/snapshot
ID 1038 gen 23230 top level 258 path @snapshots/412/snapshot
ID 1039 gen 23292 top level 266 path @home/.snapshots/300/snapshot
ID 1040 gen 23292 top level 258 path @snapshots/413/snapshot
ID 1041 gen 23351 top level 266 path @home/.snapshots/301/snapshot
ID 1042 gen 23351 top level 258 path @snapshots/414/snapshot
ID 1043 gen 23438 top level 266 path @home/.snapshots/302/snapshot
ID 1044 gen 23438 top level 258 path @snapshots/415/snapshot

It doesn’t have to work that way. The Arch wiki is a community maintained reference. It isn’t a definitive answer to every question.

As for the reason one might want to do it that way, it stops the nested /.snapshots from existing so when you rollback the snapshot for / you don’t have to then also deal with moving the nested .snapshots subvolume.

That is an advantage but there are disadvantages as well:

  • It is a non-standard solution that requires acrobatics that you described above whenever you create a / Snapper config because Snapper will fail to create a config if something exists at .snapshots.
  • You need a different process to restore / than for every other subvolume you might want to restore.
  • From an automation standpoint, it makes it harder to determine which subvolume the snapshots inside @snapshots belongs to.

No, in either case you can boot into RO snapshots by using the grub-btrfs-overlay hook.

First, it is important to understand that Snapper is built for Suse. As it result we need to understand how Suse uses Btrfs. Suse uses a nested subvolume structure where by default / is mounted at the root of the partition, aka subvolid 5. All the other subvols are nested underneath /. However, they boot off the default subvolume, not a specific subvolume.

So, what snapper rollback does for / is it sets the default subvolume to a snapshot and sets it r/w. Said differently, it doesn’t restore the snapshot, it makes it so you start using that snapshot as your new /.

Sounds great except for two things:

  • Most other distros don’t configure btrfs that way.
  • You end up in a situation where you are booting off a snapshot and writing live data to it. This isn’t a problem per se, but you should be careful when cleaning up those snapshots.

So, that seems awkward. In your case, what does that mean? It depends. What is in your kernel options? If it looks like your fstab, that does nothing because you are specifically mounting @ on /. If it doesn’t then you are now booting off that snapshot.

Additionally, if you mount your btrfs filesystem without specifying a subvolume, you are now mounting one of your snapshots.


Thanks that was helpful. I think my system looks the way it does because I followed a you-tubers example and it more or less did:

mv @ @.broken
btrfs su sn @snapshots/238/snapshot @

For some strange reason the example did some tricks to “clean up snapper”

snapper -c root --ambit classic rollback 238
btrfs su set-default 238 /

No idea why but you see what I’m left with. This PC is a test machine I use for software development and testing. So I rebuild it every few weeks. So next time I’ll try more or less what I’ve been doing on my RPI4’s with EOS ARM, snapper, and btrfs-assistant.

Thanks again for taking the time to educate an old fool.

1 Like

On an old Macbook Pro, I installed EOS Plasma. This time I was not doing things the Arch way. I installed snapper, grub-btrfs, snap-pac, and btrfs-assistant. I also install update-grub so I can forget which distro I’m on.

I use btrfs-assistant to configure snapper’s configs: root and home.

Just using btrfs-assistant I can restore to snapshots prior to some software I installed. That works, but there are remnants in the menu for the software removed by the restore unless I also restore a home snapshots prior to the software install.

So what puzzles me is the Default for / is always Level=5. And the ID for @ is a new number. Also the ID that was the number of the snapshot I restored from no longer exist.

So what does btrfs-assistant do with the old snapshots. It seems to move the snapshots used in the restore to a new snapshot and also moves @ to a new snapshot?

The root of the btrfs filesystem will always be subvolid 5. That is a btrfs convention.

The reason that the ID for @ changes is because it is a different subvol after the restore.

The ID number from the snapshot you restore from should still exist because Btrfs Assistant doesn’t touch it. The source snapshot should be exactly the same before and after the restore.

Here is what it does. It works with any subvolume name but to keep things simple I am going to assume you are restoring to @.

  • First it moves @ to a new name. Essentially this becomes a backup of the thing you are about to restore.
  • Next it takes a snapshot of the snapshot you are restoring and installs it as @
  • Lastly, it looks for any nested subvolumes in the backup of @ and moves them into the new @

Okay, thanks. So I have a handle on using btrfs-assistant to manage all of this with the help of snap-pac and grub-btrfs.

So if I have case where the system will not boot past the grub menu and I have to boot a ro known-good snapshots, what is the process since the system is now running a ro filesystem?

What seems to work is just start btrfs-assistant and go to the snapper tab and then the restore tab and select the same number as the one of the known-good snapshot that I booted from. Then restore. That seems to work and after I’m rebooted, I can restore the matching home snapshot.

It depends on your DM/DE. Some will support booting off a RO snapshot with some nuisance errors. If that works for you, that should be enough to boot off the RO snapshot, do the restore and then reboot into the newly restored system.

If your system can’t properly boot from a RO snapshot, then you should add grub-btrfs-overlayfs to the HOOKS section in /etc/mkinitcpio.conf. Then run sudo grub-mkconfig -o /boot/grub/grub.cfg. Then reboot. Any snapshots you take after that point will be bootable even if they are RO because there will be a writable overlay sitting on top.

Since I’m using Endearour OS in this case, the /var/log being in separate subvols allows it to boot ro snapshots as far as I know. I may play with the overlay method just to learn something.


Jim A

What DE are you using?

KDE Plasma mostly

Yeah, sddm/plasma is one of the few DM/DE combinations that works with RO snapshots.

The hooks for overlays worked well also. I know I had issues with xfce4 DE, some strange things related to wifi when booted ro. I’ll play with the overlays there.

1 Like

Don’t forget they only apply to new snapshots.

Right. I’ll include overlays on other DEs from the start.

Since grub-btrfs has a systemd path function for grub-btrfs.path and normally I’ve just enabled it but in the past my snapshots subvol was at level 5 not under @/. So do I need to enable a path or edit it?

In my use case I generally take snapshots and update-grub often, particularly before a big upgrade that I want to have the ability to restore from.

You can use the included path unit but it will throw errors due it’s structure.

I usually recommend replacing it with this one by placing a file with the following contents at /etc/systemd/system/grub-btrfs.path

Description=Monitors for new snapshots



Then enable it with:

sudo systemctl daemon-reload
sudo systemctl enable --now grub-btrfs.path

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.