Howto use desktop user btrfsmaintenance package?

For a Fedora desktop user using one ssd, what should I use or configure?

*https://fedora.pkgs.org/35/fedora-x86_64/btrfsmaintenance-0.5-4.fc35.noarch.rpm.html

Scripts for btrfs maintenance tasks like periodic scrub, balance, trim or
defrag on selected mountpoints or directories.
This is a set of scripts supplementing the btrfs filesystem and aims to
automate a few maintenance tasks. This means the scrub, balance, trim or
defragmentation.
Each of the tasks can be turned on/off and configured independently. The
default config values were selected to fit the default installation profile
with btrfs on the root filesystem.
Overall tuning of the default values should give a good balance between
effects of the tasks and low impact of other work on the system. If this does
not fit your needs, please adjust the settings.

*GitHub - kdave/btrfsmaintenance: Scripts for btrfs maintenance tasks like periodic scrub, balance, trim or defrag on selected mountpoints or directories.

i tried the autodefrag (fstab) option and my system became very fast.

For me, fstrim.timer is enabled and it triggers once a week. In addition to that I have discard turned on on both filesystem and encrypted volume level.

Periodic scrub is also recommended, to ensure files on your filesystem all are “healthy”. With single device SSD you won’t be able to repair files if corruption occurs (unless you have multiple copies on the same device - block level), but at least you’ll know something is happening with the underlying device.

1 Like

btrfs autodefrag is looking at small writes less than 32K being inserted or appended to an existing file, and periodically just dirties all data extents (all the fragments) resulting in the btrfs kernel code to COW those extents somewhere else, mostly contigulously (but no guaranteed to be made of a single fragment). So it’s pretty simple. It was expressly designed for the desktop database use case, commonly used by web browsers. If you’re using larger databases, you’ll find things get much slower because an active database is constantly inserting or appending, and this just results in a lot of attempts by the code to defrag the file.

On SSD, it really depends on nature of the database file. I see some benefit of autodefrag on SATA SSDs for encrypted Signal database files. On NVMe, I don’t use autodefrag at all because fragmentation on these drives has a fairly low tracking penalty compared to SATA SSD or especially HDD. But you don’t need btrfs-maintenance package for autodefrag mount option, autodefrag is built into the kernel.

The btrfs-progs user space defragment has some differences, it’s only triggered on demand. The btrfs-maintenance package’s btrfs-defragment.timer and .service can be used to customize what is being defragmented and when. So if you want something more narrowed, like just your Signal app database directory, you can do that.

I use the generic fstrim.timer included and enabled by default on Fedora, not the btrfs-maintenance one.

btrfs-balance.timer you can optionally enable if you’re not interested in ever having or reporting what are at this point very rare and obscure out of space errors on btrfs. This utility runs a minimal data and metadata block group balance every once in a while, and essentially papers over some known edge cases in btrfs kernel code actively being worked on.

btrfs-scrub.timer is useful to enable, in particular for the multiple device case. While Btrfs will always verify checksums on every read, and can self-heal a bad copy if a good copy exists, a scrub will actively check every used block on the file system, both data and metadata. It will also do fixups if a good copy of that block is available (e.g. dup metadata or raid 1 data). To check the result of the most recent scrub use btrfs scrub status / If file data is corrupted, you’ll see in dmesg a complete path to file reference to the corrupt file.

3 Likes

Thank you for your reply, completely understandable. There is no need to use the package yet.