Created
August 27, 2018 12:34
-
-
Save Aaron-Macneill/ada355e48ef3b108fdf352f6398b50b7 to your computer and use it in GitHub Desktop.
Bash bcache flush #bcache
This file contains 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 | |
if [ "$EUID" -ne 0 ] | |
then echo "Please run as root" | |
exit | |
fi | |
trap finish EXIT | |
get_dirty () { | |
echo $(cat /sys/block/bcache0/bcache/dirty_data) | |
} | |
set_percent () { | |
echo $1 > /sys/block/bcache0/bcache/writeback_percent | |
} | |
finish () { | |
set_percent 10 | |
echo "Complete" | |
} | |
DIRTY=$( get_dirty ) | |
set_percent 0 | |
until [ $DIRTY = "0.0k" ]; do | |
DIRTY=$( get_dirty ) | |
echo $DIRTY | |
sleep 10 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment