ZFS zpool scrub done right

What is "correct way" to do zpool scrub-ing? It looks to me that there at least two different ways to do scrubbing on TrueOS which should not be very different than vanilla FreeBSD.

I noticed that the /etc/periodic/daily directory contains a 800.scrub-zfs script but it looks like it is disabled by default. So I put something like this into the /etc/periodic.conf file which overrides defaults

Code:
daily_scrub_zfs_enable="YES"
daily_scrub_zfs_pools="tank storage"
daily_scrub_zfs_default_threshold="15"

On the another hand I noticed that FreeNAS is doing scrubbing through system /etc/crontab (user crontab would IMHO be another way to do this on vanilla FreeBSD)

Code:
00 00 * * 7 root PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/root/bin" /usr/local/sbin/scrub -t 15 zfsauton
 
I would suggest the "correct" method for FreeBSD would be the periodic scripts.
Note that you don't need daily_scrub_zfs_pools if you want it to scrub all pools.

The /usr/local/sbin/scrub script is specific to FreeNAS and does not exist on FreeBSD. Following correct folder layout, they have put their code under /usr/local, which is the location for 3rd party additions that are not part of FreeBSD base.

By the look of it, it's similar to the standard periodic script, they've just modified it so that if you're running a HA FreeNAS cluster, it doesn't try and scrub on both nodes (probably ties in with the fancy ixSystems TrueNAS kit, seeing as it's them that mainly develop FreeNAS these days)

Code:
# Do not try to run scrub on passive node
local failover="$(/usr/local/bin/python /usr/local/www/freenasUI/middleware/notifier.py failover_status 2> /dev/null)"
if [ "x${failover}" = "xBACKUP" ]; then
exit 0
fi

I don't think it would be worth manually adding a scrub command to crontab, or writing a script when there's already the periodic option. They've even gone to the trouble of making it run daily but providing a configuration option for the interval ( x days), rather than just making it a weekly or monthly periodic script. :)
 
Back
Top