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!
3 Likes
ruzko
(JD Ludvigsen)
November 16, 2022, 8:15pm
2
I wonder about this as well.
Can anyone chime in?
dalto
(dalto)
November 16, 2022, 8:41pm
3
scottytrees:
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.
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 β WantedBy=timers.target
2 Likes
firecat53
(Scott Hansen)
November 17, 2022, 1:07am
5
If you have multiple btrfs volumes, you can generalize the service file like:
# /etc/systemd/system/btrfs-scrub@.service
[Unit]
Description=Btrfs scrub on %f
Requires=%i.mount
After=%i.mount
[Service]
Nice=19
IOSchedulingClass=idle
KillSignal=SIGINT
ExecStart=btrfs scrub start -B %f
# /etc/systemd/system/btrfs-scrub@.timer
[Unit]
Description=Monthly Btrfs scrub on %f
[Timer]
OnCalendar=monthly
AccuracySec=7d
RandomizedDelaySec=7d
Persistent=true
[Install]
WantedBy=timers.target
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
2 Likes