Just wanted to make sure and ask if this is good enough.

set -e

echo "=== fstrim ==="
fstrim -av

echo "=== BTRFS scrub status before ==="
btrfs scrub status /

echo "=== BTRFS scrub start ==="
btrfs scrub start -B /

echo "=== BTRFS scrub status after ==="
btrfs scrub status /

echo "=== BTRFS balance (50%) ==="
btrfs balance start -dusage=50 /

echo "=== Done ==="```
  • talkingpumpkin
    link
    fedilink
    arrow-up
    3
    ·
    2 days ago

    fstrim is most probably already handled.

    If you are adding a btrfs disk to an existing install you might want to check if there’s a systemd unit that runs btrfs scrub: run systemctl list-units '*btrfs*' and see what it prints.

    For btrfs balance… I read that you generally don’t want to run it (it can be pretty IO intensive) unless you added/removed disks or are troubleshooting. My tumbleweed does have a service that boils down to running btrfs balance weekly though (with values far below your 50; see sources available at https://github.com/kdave/btrfsmaintenance)