Posted 09 February, 2021
So scrubbing ZFS: Giving ZFS a moment to sit down and think about its behavior. It should happen now and again, but if everything is going smooth sailing we tend to forget to do this; With the ever increasing amount of ZFS servers around, it tends to be a hassle, so this is a perfect candidate for automation ! Details on the scrubbing 🙂
I used : /opt/scrub.sh
#!/bin/sh -eu # you can stop/pause a scrub # using : zpool -p poolname # report logger "zfs" "cron scrub initiated" # Scrub all healthy pools. zpool list -H -o health,name 2>&1 | \ awk 'BEGIN {FS="\t"} {if ($1 ~ /^ONLINE/) print $2}' | \ while read pool do zpool scrub "$pool" done
The script is part of the Ubuntu package discussed here;
Don’t forget permissions : chmod 755 /opt/scrub.sh
in nano /etc/crontab
:
# * * * * * user-name command to be executed 0 0 1 */2 * root /opt/scrub.sh
This should scrub all the ZFS pools once every 2 months; Happy scrubbing 😉
If you enjoyed this article, please consider buying me a Dr Pepper.
Fuel the beast!
Buy me a Dr Pepper