diff options
| author | 2026-05-13 13:43:35 +0100 | |
|---|---|---|
| committer | 2026-05-13 13:43:35 +0100 | |
| commit | 14a6992a4ebe826266a1ea4320c34c0ac91932ee (patch) | |
| tree | 0dd1735409889b688dc9347032a109307cbd86f0 /etc/systemd/system/btrfs-balance@.timer | |
| parent | 22816819ffd5f3adb515dcea991cd1c3af368e36 (diff) | |
| download | dotfiles-14a6992a4ebe826266a1ea4320c34c0ac91932ee.tar.gz dotfiles-14a6992a4ebe826266a1ea4320c34c0ac91932ee.tar.bz2 dotfiles-14a6992a4ebe826266a1ea4320c34c0ac91932ee.zip | |
feat(systemd): monthly btrfs balance template
Template service+timer that runs `btrfs balance start -dusage=50
-musage=50 %f` once a month on the instance's mount path. Mirrors the
shape of the stock btrfs-scrub@.{service,timer} so the operational
model is identical: enable btrfs-balance@-.timer for /, btrfs-balance@\
x2dhome.timer for /home, etc.
Why a partial balance and not a full one: full `btrfs balance start`
rewrites every block group, which on a multi-TB volume takes hours and
can chew through enormous amounts of CSUM/free-space-tree work.
`-dusage=50 -musage=50` only consolidates block groups that are less
than half full, which is exactly the operation that reclaims space
'lost' to fragmentation after lots of small writes — the only practical
reason a healthy single-disk btrfs needs balancing at all.
`Nice=19 IOSchedulingClass=idle` keeps it out of the way of foreground
work; `KillSignal=SIGINT` (same as btrfs-scrub) lets a graceful Ctrl-C
checkpoint the operation cleanly. Persistent=true catches the run on
next boot if the machine was off when the timer fired.
Enabled in systemd-units/system.txt as btrfs-balance@-.timer (root
volume only — /home isn't a separate subvolume on this machine).
Diffstat (limited to 'etc/systemd/system/btrfs-balance@.timer')
| -rw-r--r-- | etc/systemd/system/btrfs-balance@.timer | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/etc/systemd/system/btrfs-balance@.timer b/etc/systemd/system/btrfs-balance@.timer new file mode 100644 index 0000000..91a009c --- /dev/null +++ b/etc/systemd/system/btrfs-balance@.timer @@ -0,0 +1,12 @@ +[Unit] +Description=Monthly btrfs balance on %f +Documentation=man:btrfs-balance(8) + +[Timer] +OnCalendar=monthly +AccuracySec=1d +Persistent=true +RandomizedDelaySec=1h + +[Install] +WantedBy=timers.target |
