Like smartd, Debian installs btrfsmaintenance in a disabled state.

One day, when consensus on the most useful and safe default
configuration has been reached, maintenance operations will be
automatically enabled.  It also seems wise to wait until
btrfsmaintenance supports something like upower, so that these IO and
CPU intensive jobs can be paused if a system switches to battery, or
deferred until AC power is available.  At present btrfsmaintenance is
not power-state aware on either laptops or servers with
uninterruptible power supplies.

Configuration is found at /etc/default/btrfsmaintenance

To activate the configuration, run the following command:

  systemctl restart btrfsmaintenance-refresh.service

Alternatively, to automatically execute btrfsmaintenance-refresh
whenever /etc/default/btrfsmaintenance has been edited run:

  systemctl enable btrfsmaintenance-refresh.watch

Finally, enable systemd timers:

  systemctl enable btrfs-balance.timer  # [1]
  systemctl enable btrfs-defrag.timer   # [2]
  systemctl enable btrfs-scrub.timer    # [3]
  systemctl enable btrfs-trim.timer     # [4]

[1] This rewrites all data that is not excluded by a filter.  Periodic
    balancing is not useful, nor recommended, for the vast majority of
    workloads.  If a corner case is found where balancing is useful,
    this case (with steps to reproduce) should be reported upstream.
[2] See wiki.debian.org/Btrfs for issues with defrag eg: out of space errors,
    complications when using snapshots, fewer more fine-grained paths are
    better, etc.  This is also workload-dependent.  Directories with logs,
    databases, and VM images benefit the most.
[3] Recommended; however, battery life will be reduced during a scrub.
[4] Prefer fstrim.timer to this option and leave btrfs-trim.timer disabled,
    in case fstrim.timer is someday enabled by default for non-rotational
    disks.

For the time being, users who forgo systemd can enable roughly
equivalent behaviour by running the following script directly:

  /usr/share/btrfsmaintenance/btrfsmaintenance-refresh-cron.sh

To enable this on every boot, add it to /etc/rc.local.  To refresh
configuration every hour, run:

  cd /etc/cron.hourly
  ln -s ../../usr/share/btrfsmaintenance/btrfsmaintenance-refresh-cron.sh ./

Btrfsmaintenance must not be configured to use both the systemd and
cron methods (see upstream README).

 -- Nicholas D Steeves <sten@debian.org>, Tue, 15 Aug 2023 16:26:39 -0400
