Setting up zpool scrub every 2 months
February 9, 2021

Setting up zpool scrub every 2 months

Posted on February 9, 2021  •  1 minutes  • 174 words  •  Suggest Changes

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/

#!/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
        zpool scrub "$pool"

The script is part of the Ubuntu package discussed here;

Don’t forget permissions : chmod 755 /opt/

in nano /etc/crontab :

# * * * * * user-name command to be executed

0 0 1 */2 * root /opt/

This should scrub all the ZFS pools once every 2 months; Happy scrubbing ๐Ÿ˜‰


If you enjoyed this website, consider buying me a Dr. Pepper

Buy me a Dr PepperBuy me a Dr Pepper