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 ==="```


fstrimis 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: runsystemctl 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 runningbtrfs balanceweekly though (with values far below your 50; see sources available at https://github.com/kdave/btrfsmaintenance)