Setting up zpool scrub every 2 months

Posted 09 February, 2021

zfs on linux

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 😉


Show Comments (0)
© SvennD