Use mountpoints instead of block devices so that RAIDs don't get angry
This commit is contained in:
parent
d4bdedb018
commit
6711efc131
1 changed files with 7 additions and 4 deletions
|
@ -1,16 +1,19 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Find all BTRFS formatted partitions
|
||||
# Find the mountpoint for all BTRFS formatted partitions
|
||||
PARTITIONS=()
|
||||
for i in $(lsblk -nrpo "name" -e 1,7,11); do
|
||||
if [[ "$(lsblk -no FSTYPE "$i")" == "btrfs" ]]; then
|
||||
PARTITIONS+=("$i")
|
||||
PARTITIONS+=("$(findmnt -v -y --real -f -o TARGET -n $i)")
|
||||
fi
|
||||
done
|
||||
|
||||
# Remove duplicates, semi-jankily
|
||||
PARTITIONS=($(echo ${PARTITIONS[@]} | tr ' ' '\n' | sort -u | tr '\n' ' '))
|
||||
|
||||
# Reallocate blocks that are less than 95% used
|
||||
for i in ${PARTITIONS[*]}; do
|
||||
for i in ${PARTITIONS[@]}; do
|
||||
{
|
||||
echo "Starting balance on $i"
|
||||
btrfs balance start -dusage=95 "$i"
|
||||
|
@ -22,7 +25,7 @@ done
|
|||
wait
|
||||
|
||||
# Scrub all partitions
|
||||
for i in ${PARTITIONS[*]}; do
|
||||
for i in ${PARTITIONS[@]}; do
|
||||
{
|
||||
echo "Starting scrub on $i"
|
||||
btrfs scrub start -B "$i"
|
||||
|
|
Loading…
Reference in a new issue