Another BTRFS basic question

Sorry if this was already answered. After many years with Ext4 I made the switch to BTRFS when re-installing EOS, and I must say that I could not find a clear answer to what seems (to me) a simple question: Do I need to actively manage my BTRFS installation with some periodic commands… or just leave it as it is ? (And if I need to… then WHAT to do ?)

My configuration is the one made by Calamares, with the addition of LUKS encryption.
I have one unique SSD drive with 2 partitions. A fat one for the boot, and the btrfs one for all the rest.

Here is my FSTAB

UUID=BC10-75F6 /boot/efi vfat umask=0077 0 2
/dev/mapper/luks-5b9dc459-3e79-4f25-ac40-e9cffd47170d / btrfs subvol=/@,defaults,noatime,space_cache,autodefrag 0 1
/dev/mapper/luks-5b9dc459-3e79-4f25-ac40-e9cffd47170d /home btrfs subvol=/@home,defaults,noatime,space_cache,autodefrag 0 2
/dev/mapper/luks-5b9dc459-3e79-4f25-ac40-e9cffd47170d /var/cache btrfs subvol=/@cache,defaults,noatime,space_cache,autodefrag 0 2
/dev/mapper/luks-5b9dc459-3e79-4f25-ac40-e9cffd47170d /var/log btrfs subvol=/@log,defaults,noatime,space_cache,autodefrag 0 2

Now, the system is running without issue since about 10 days, so I have nothing to “repair” (apart a warning when I shutdown, see below…). I just need to understand what is the best way to maintain the actual state.

I also have Timeshift performing snapshots at every boot, and they appear in my grub (with grub-btrfs)

My specific questions are those:

  1. Do I need to change, add or modify some parameters (as compress, ssd, etc…) or leave it as it is ?
  2. Do I need to perform some commands as : scrub, balance, (others?) and if yes, when is it advised to do so ?
  3. Is it recommended to modify my sub-volumes ?
  4. Last one: each time I shutdown or reboot I have the message “Warning: failed unmounting /home” appearing for 1 sec. It does not seems to affect the system, but… well… anything to do here ? (I have find data about issues related to mount a volume but not to unmount it).

And of course… anything other advice I didn’t think to ask about… Thanks in advance.

1 Like

It depends. ssd is for SSDs, compress is to compress files. If you have or want those things, then yes.

Apart from scrub, it depends. scrub should be done periodically to check the consistency of the filesystem. balance will need to be done regularly if you frequently create/delete snapshots, and otherwise can be mostly ignored unless you’re finding otherwise-unexplainable disk performance issues. Also keep in mind that a full balance is not normally required and that filtering on metadata and disk usage is a better default, e.g.:

btrfs filesystem balance start -dusage=85 -musage=85 "$_mount"

In what way? Subvolumes are essentially equivalent to partitions, so why would you change your partition layout?

Check the journal. Possibly a process is not exiting cleanly or within a sensible timeframe and is being killed or makes systemd think that unmounting has “failed”.

4 Likes

Possibly:

https://wiki.archlinux.org/title/Btrfs#SSD_TRIM

Also, you might want to enable

btrfs-scrub@.timer unit for monthly scrubbing the specified mountpoint.

https://wiki.archlinux.org/title/Btrfs#Scrub

2 Likes

We should really collect the needed pieces of information about using BTRFS and collect them inside a short informative WIKI page.

:thinking:

7 Likes

Thanks @jonathon and @pebcak , your advices are precious.and help me to better understand btrfs !

1 Like

Indeed, I would really appreciate this… and I think I will not be the only one !

What is about the default subvols created?

btrfsSubvolumes:
    - mountPoint: /
      subvolume: /@
    - mountPoint: /home
      subvolume: /@home
    - mountPoint: /var/cache
      subvolume: /@cache
    - mountPoint: /var/log
      subvolume: /@log

Would this not be good for most usecases? and easier to handle ?

btrfsSubvolumes:
    - mountPoint: /
      subvolume: /@
    - mountPoint: /home
      subvolume: /@home

The journal shows this error :

<username> : a password is required ; PWD=/home/<username> ; USER=root ; COMMAND=/usr/sbin/uptime

Any idea how to proceed to correct this ?

I would definitely keep @cache and @log. It should be transparent to most end users and there are benefits to both. Having a separate /var/cache has two benefits.

  • It keeps the cache out of your snapshots which is good because the cache has both no value and a high rate of change. In other words, it makes your snapshots use less disk space.
  • The second benefit is that if you boot off a read-only snapshot, it makes your system more functional since /var/cache will still be writable.

The reason for /var/log is both to keep the logs out of snapshots and allow you to be able to view the logs to see what went wrong after you restore a snapshot.

4 Likes

The /var/cache doesn’t need to be included in a snapshot.
The /var/log in it’s own subvolume can also be excluded from an snapshot of / thus it will not get overwritten when you restore from an snaphot.

I guess these are the reasons for the default setup.

3 Likes

I see so we should leave it like it is for the subvols, with a piece of brief information on why and some tutorial on how to setup snapshot usage and recovery solutions.
I do only some testing installs but personally not using BTRFS.
So any help to create the wiki is appreciated :wink:

2 Likes

Nope, that’s weird. Start a new thread. :sweat_smile:

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