Skip to content

Instantly share code, notes, and snippets.

@Aaron-Macneill
Created August 27, 2018 12:34
Show Gist options
  • Save Aaron-Macneill/ada355e48ef3b108fdf352f6398b50b7 to your computer and use it in GitHub Desktop.
Save Aaron-Macneill/ada355e48ef3b108fdf352f6398b50b7 to your computer and use it in GitHub Desktop.
Bash bcache flush #bcache
#!/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