Default btrfs mount options and subvolume layout

I tried snapper-gui, and as I found out it doesn’t provide restore functionality. (Or it is hidden so well that the average user wouldn’t find it.)

I tried Timeshift GUI too, and in my opinion snapper GUI is more user-friendly.

But I guess it would be better to have the restore functionality accessible outside of these tools.
@Chrysostomus Could you develop a tool that checks, if the default subvolume or any other subvolume was booted, and if it’s not the default, it would display a systray icon with a toast? (with the text “To permanently restore your system to the currently running version, click here”) The system tray icon should remain accessible all the time when a non-default subvol is running.

Yes

No. I don’t have experience in doing systrays, and not all desktops have system trays anyway.

This is nearly the same layout that i do use nowadays. I had a few accidents with manjaro. So i had to rollback manually. I had to repair manjaro from LIVE-CD. I learned that a layout that is not flat gives a lot of trouble when you have to rollback permanently.
First it seams easy. but later i found that my snapshots where now taken in the “wrong” place. And even later i found that the old snapshots where not removed any more. To correct this i had to do a lot of reading on btrfs, cli-snapshoting(subvolumes), moving and deleting.

I wont suggest anything but a flat :point_up: btrfs-layout.

@ /
@home /home
@snapshots /.snapshots

additionally i do have

@home.snapshots /home/.snapshots
@nosnap /var/cache, /var/spool, /var/nosnap

At /var/nosnap are the virtual machines stored.

 mount |egrep btrfs                                                                                                                            [32]
/dev/sda2 on / type btrfs (rw,noatime,compress=zstd:3,ssd,space_cache,commit=300,subvolid=5959,subvol=/@)
/dev/sda2 on /.snapshots type btrfs (rw,relatime,compress=zstd:3,ssd,space_cache,commit=300,subvolid=3648,subvol=/@snapshots)
/dev/sda2 on /home type btrfs (rw,noatime,compress=zstd:3,ssd,space_cache,commit=300,subvolid=258,subvol=/@home)
/dev/sda2 on /var/nosnap type btrfs (rw,relatime,compress=zstd:3,ssd,space_cache,commit=300,subvolid=4455,subvol=/@nosnap)
/dev/sda2 on /var/spool type btrfs (rw,relatime,compress=zstd:3,ssd,space_cache,commit=300,subvolid=4455,subvol=/@nosnap)
/dev/sda2 on /var/cache type btrfs (rw,relatime,compress=zstd:3,ssd,space_cache,commit=300,subvolid=4455,subvol=/@nosnap)
/dev/sda2 on /home/.snapshots type btrfs (rw,relatime,compress=zstd:3,ssd,space_cache,commit=300,subvolid=5719,subvol=/@home.snapshots)
/dev/sda2 on /mnt/BTRFS_ROOT type btrfs (rw,relatime,compress=zstd:3,ssd,space_cache,commit=300,subvolid=5,subvol=/)

/mnt/BTRFS_ROOT is only used if i have to work with the btrfs filesystem itself. It is normally not mounted.

1 Like

How you got this ? manual partitioning while installing ? Can you make short guide what to change there and how ?

thx

I did this always after installing.
In my main-System i did this in the running system a few days after i had to rollback. When rolling back with a non-flat layout i found it to much work. So i changed my system afterwards.
In an new setup system on permanent USB-Stick i even installed first with ext4, then converted the filesystem to btrfs, and then setup a flat layout in btrfs. persistent manjaro usb with btrfs
On both machines i do automatic snapshots with snapper.

When changing the layout you have to watch grub.cfg and fstab. Yo do need both working to be able to rebbot. For safety you should have a live-CD. But i didn´t need it. You have to watch snapper, because snapper will not create new configs, when the subvolume/ dir /.snapshots or /home/.snapshots is already present. and it may be best to stop snapper while changing the layout :slight_smile:

I can´t create an real step by step howto, because i have no system to test the steps. My actual system is already converted. I am afraid that i do miss something an you get stuck in the middle of it. Maybe you could try this with an USB-Stick before you mess up your actual system. But when i have to do it the next time i will create a step-by-step you can follow. :thinking:
Tipp:
There is some safety in btrfs using subvolumes/snapshots. It is easy to make a readonly-snapshot before you start. When you mess something up, you are able to create a new writable snapshot of it, move it to /@ instead of the former /@ and define this snapshot as default. And you are saved.

cat /etc/fstab                                                 
PARTUUID=3ee1dfe1-19af-4102-945d-90d957d3c199	/         	btrfs     	rw,noatime,compress=zstd,commit=300,subvol=@	0 0
PARTUUID=3ee1dfe1-19af-4102-945d-90d957d3c199	/home     	btrfs     	rw,noatime,compress=zstd,commit=300,subvol=@home	0 0
PARTUUID=b1d3d562-88ff-4ac2-8326-9c5d82892379	/boot/efi 	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro	0 0
PARTUUID=3ee1dfe1-19af-4102-945d-90d957d3c199	/.snapshots	btrfs     	rw,relatime,compress=zstd,commit=300,subvol=@snapshots	0 0
PARTUUID=3ee1dfe1-19af-4102-945d-90d957d3c199	/home/.snapshots	btrfs     	rw,relatime,compress=zstd,commit=300,subvol=@home.snapshots	0 0
PARTUUID=3ee1dfe1-19af-4102-945d-90d957d3c199	/var/nosnap	btrfs   	rw,relatime,compress=zstd,commit=300,subvol=@nosnap	0 0
/var/nosnap/var/cache				/var/cache	none bind	0 0
/var/nosnap/var/spool				/var/spool	none bind	0 0
1 Like

Please keep “servers” in mind, some folks do use Manjaro.

On a server i would keep /, /home and /srv in separate btrsf-filesystems (when they can grow uncontrollably), and not just a subvolume. Maybe even on separate drives. Because:
When /srv (or /home) runs out of space it may strangle your system
If /srv will only grow in a controllable fashion (or you have lots of free space) /srv is a very good option for a subvolume. Maybe with:
@srv
@srv.snapshots

This topic dates from 2020.
I installed Manjaro twice from scratch, first time I selected wipe disk - btrfs - swapfile: no subvolume is created. Swapfile is on / (note this could break Timeshift, according to Manjaro wiki!).

Second time I selected “swap with hibernation”, again, no subvolume is created and there is no hibernation support. Worse, a swap partition is created, even though this is not recommended for SSDs and for BTRFS.

I know how to create a swapfile properly for BTRFS and to have it support hibernation (see this topic), but I am suprised Manjaro/Calamares does not take care of this by itself, especially after noticing this topic from last year?

It seems a lot of effort has been spend already.

When was this? Did you use automatic mode or manual partitioning? I haven’t tested the manual mode in a while, but with automatic partitioning it should definitely create a swapfile on a separate subvolume. If it doesn’t it’s a bug and needs to be fixed asap.

This was just last week. I did the same test a couple of times: 100% certain no swap subvolume is created. It is either a file on / or a partition.

I simply select wipe disk, select swap type and FS type.
I have not used manual partitioning.

For now, I simply select “no swap” and “BTRFS”.
After installation, I run the script (that I updated) from this topic:

This will calculate the amount of swap needed for hibernation, create a subvolume and create the swapfile, turn on swap and perform necessary tasks for hibernation to work.

1 Like

Thanks, I’ll look into this

@Chrysostomus I read that the latest Qonos release has optimised Btrfs subvolume configuration.

Swapfile is now created in its own root subvolume. Why?
The only reason to create a subvolume of it is because you need to exclude it from its parent subvolume (@). Isn’t that what nested subvolumes are for?

Also, Calamares is still misleading when selecting BTRFS. Because:

  1. You still have 2 options that don’t make sense: partitioning.
  2. There is no option to correctly setup hibernation. The one that exist uses partitioning. The whole idea of subvolumes is you don’t need a separate partition for swap.

If one wants BTRFS and hibernation, that only place containing the correct info for it is here:
[HowTo] Enable and configure hibernation with BTRFS the script in the first post.

Could the option for “swapfile (with hibernation)” be added and the partition options be disabled when BTRFS is selected? That would make more sense.

It is only a “design decision” to make a “nested subvolume” or a “root subvolume”.

  • But flat layouts are easier to maintain
  • And more people do understand that a subvolume in a flat layout is completely independent from all other subvolumes

Btrfs

https://wiki.manjaro.org/index.php/Btrfs

1 Like

Not sure if it is the right place question, but it is related to BTRFS and calamares, so fingers crossed.
I have just made a new VM to play around with manjaro BTRFS (my rig is running manjaro on ext4 now). I also have a notebook with arch & btrfs on it. I tried moving my @home around, and so I wanted to edit the fstab (/mnt/@/etc/fstab), and when I compared my arch and my VM fstab-s, I noticed that none of my mounts use the following baseline settings:
space_cache
subvolid
I wonder if the lack of former is optimal, and I wonder if the lack of the latter is significant

Thanks.

subvol=@… is better then subvolid

I don’t use space_cache

... /         	btrfs       rw,noatime,compress=zstd:9,commit=300,subvol=@	0 0
... /home     	btrfs     	rw,noatime,compress=zstd:9,commit=300,subvol=@home	0 0

You find best infos in https://btrfs.wiki.kernel.org/

As Andreas say’d you should use subvol=xyz mounts because later when you have done some rollbacks the subvolume id’s are now changed but not they subvolume names. With the use of subvolid you have on each rollback to update your fstab. The only usecase for subvolid i have is the mount of the btrfs root. I mount this root on /btrfs folder to get easier access to the btrfs filesystem for maintenance.

I even don’t use space_cache and ssd options because btrfs should automatical detect this. With one exception: on external attached SSDs (USB to SATA dongle) the system does not detect it right. Then i use sdd,space_cache, and only space_cache not they versions like space_cache=v2 and so on because this doesn’t work correctly.

I still don’t understand why Calamares still allows for improper configuration of swap (on partition) and faulty hibernation :frowning:

Thanks for the info, it’s long time ago as i have tested Timeshift, then one point of my above statement is irrelevant.

Another way i make rollbacks

sudo mv /btrfs/@ /btrfs/@snapshots/old_root
sudo btrfs su sn /btrfs/@snapshots/root/15/snapshot /btrfs/@

where /btrfs/@snpashots/root/15/snapshot is the currently booted ro-snapshot. This save the damaged subvolume, now as snapshot in @snapshots. You can even exchange @ from a running system (started from @), and reboot or remount into the new setup.

Last case i tried self and it seemed to work properly, but would not trust it eighter :slight_smile:
The nice thing with this way is that any setup/config of FSTAB, GRUB, initramfs and kernels that’s stored into a snapshots remains correctly after rollback of @. You need only to know that in FSTAB we have to work only with subvol=@ mounts, not subvolid=xxx mounts. After a genfstab >> /etc/fstab we have to edit these mounts. There is only one point to consider: any later changes on partition, UUIDs, mountpoints and so on are forbidden, because we break the system configuration stored in our snapshots.

A small script started on boot from a ro-snapshot, selected in GRUB, could do this Rollback automatical and reboot the machine. Like we can when GRUB start the UEFI Shell.
This script maybe ask the User if he wish to start the CLI or Desktop Environment or want to rollback the system and reboot. I think thats a small patch on grub-btrfs script.

But you’re right, the problem are the toolchain, in any case some small changes are needed to get a system which can be presented to common users, with small knowledge of BTRFS. But, in longer timescale the user have to learn BTRFS.

I remember my startup problems with BTRFS, the biggest one at beginning was: “how fu…ing should i setup my BTRFS layout ?”, “Have i to exclude /var or only partial like older suse setup with many subvolumes for /var ?” And on these question Manjaro Installer can give advise.

“Calamares can now handle swapfiles with btrfs automatically per user setting. It uses the swap subvolume”,

good to know, i use architect or easily clone my systems with rsync.

Last time i tried calamares i must overseen this feature, or is it new?


Welcome.

Out of curiosity:

Since this is your first post - which statement would that be?