How to enable scrub and balance timers?

Greetings Fedora community,

I recently installed Fedora 36 and had a few questions regarding btrs maintenance. I was using EndeavourOS Gnome before this and on my old Arch-based setup I used a package from the AUR called btrfsmaintenance that more or less ran on it’s own once installed. I see this package is also in the Fedora repos too which is nice, but reading about btrfsmaintenance on Fedora, it seems the consensus is better not to use it, but rather timers for scrubbing and balancing. I’m curious if anyone can tell me what exactly the commands I need to activate systemd timers for these two? Is it a good idea to use both or just one of them? I know fstrm timer is on by default and I do have an SSD in my Acer laptop. I have a very simple setup, just one SSD in my laptop.

Here’s my /etc/fstab details below if that’s helpful:

UUID=06fb8d29-d255-4b98-aa4f-a3fa0416ede9 /                       btrfs   subvol=root,compress=zstd:1 0 0
UUID=a5c65a7b-d274-4d97-9a5b-38aa8817829f /boot                   ext4    defaults        1 2
UUID=CC4E-4FA7          /boot/efi               vfat    umask=0077,shortname=winnt 0 2
UUID=06fb8d29-d255-4b98-aa4f-a3fa0416ede9 /home                   btrfs   subvol=home,compress=zstd:1 0 0

Appreciate any help!


I wonder about this as well.
Can anyone chime in?

There is no significant difference btrfsmaintenance on Arch and btrfsmaintenance on Fedora.

btrfsmaintenance also uses timers. However, it adds a bunch of convenient funcitionality so you don’t have to enable them one at a time for each filesystem and/or subvolume.

I can’t imagine why the β€œconsensus” would be to not use btrfsmaintenance.

1 Like

I just wrote my own systemd service and timer. E.g.:

       β”‚ File: btrfs-scrub.service
   1   β”‚ [Unit]
   2   β”‚ Description=Runs the btrfs scrub on the root mount point periodically
   3   β”‚ 
   4   β”‚ [Service]
   5   β”‚ Type=simple
   6   β”‚ ExecStart=/usr/sbin/btrfs scrub start -B /

       β”‚ File: btrfs-scrub.timer
   1   β”‚ [Unit]
   2   β”‚ Description=Runs the btrfs scrub on the root mount point periodically
   3   β”‚ 
   4   β”‚ [Timer]
   5   β”‚ OnCalendar=monthly
   6   β”‚ AccuracySec=12h
   7   β”‚ Persistent=true
   8   β”‚ 
   9   β”‚ [Install]
  10   β”‚

If you have multiple btrfs volumes, you can generalize the service file like:

#    /etc/systemd/system/btrfs-scrub@.service
Description=Btrfs scrub on %f

ExecStart=btrfs scrub start -B %f
# /etc/systemd/system/btrfs-scrub@.timer
Description=Monthly Btrfs scrub on %f



And then enable with (different disks mounted at /, /home and /mnt/backup):

# systemctl enable --now btrfs-scrub@-.timer
# systemctl enable --now btrfs-scrub@home.timer
# systemctl enable --now btrfs-scrub@mnt-backup.timer