Last active
July 31, 2019 11:36
-
-
Save ZsBT/b0236b94d5479473cffae9efe9222476 to your computer and use it in GitHub Desktop.
btrfs maintenance shell - functions only
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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