Skip to content

Instantly share code, notes, and snippets.

@ZsBT
Last active July 31, 2019 11:36
Show Gist options
  • Save ZsBT/b0236b94d5479473cffae9efe9222476 to your computer and use it in GitHub Desktop.
Save ZsBT/b0236b94d5479473cffae9efe9222476 to your computer and use it in GitHub Desktop.
btrfs maintenance shell - functions only
#!/bin/bash
#
# BTRFS maintenance
# scrub or balance all btrfs fs present on system
#
scrub() {
for device in $(mount -t btrfs | cut -d ' ' -f 1 |sort -u) ;do
echo "scrub $device"
btrfs scrub start -B -c 3 -n 9 -d $device || exit 1
done
}
balance() {
for fs in $(mount -t btrfs | cut -f 3 -d ' ');do
echo "balance $fs"
nice ionice -c 3 btrfs bal start -dusage=30 -dlimit=30 -musage=30 -mlimit=30 $fs || exit 2
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment