CFT: periodic scrubbing of ZFS pools

Pawel Jakub Dawidek pjd at
Sun Jun 13 09:47:13 UTC 2010

On Thu, Jun 10, 2010 at 04:26:29PM +0200, Alexander Leidinger wrote:
> Hi,
> as there seems to be interest in a periodic script to scrub zpools, I  
> modified my monthly-POC into a daily script with parameters for which  
> pools to scrub, how many days between scrubs (even different per pool,  
> if required), and several error checks (non-existing pool specified,  
> scrub in progress).
> You can find it at
> Please put it into /etc/periodic/daily and test it. Possible  
> periodic.conf variables are:
>  daily_scrub_zfs_enable="YES"
>  daily_scrub_zfs_pools="name1 name2 name3" # all if unset or empty
>  daily scrub_zfs_default_threshold="<number_of_days>" # default: 30
>  daily_scrub_zfs_<POOLNAME>_threshold="<number_of_days>"
> If there is no specific threshold for a pool (= days between scrubs),  
> the default threshold is used.

Patch looks good.

The only minor issue I found is that in:

	_last_scrub=$(zpool history ${pool} | grep scrub | tail -1 |\
		cut -d ' ' -f 1)

grep is definitely too weak. If there is a pool or even dataset with
'scrub' word in it, it will be confused. Also when someone stops the
scrub it will be stored in history as 'zpool scrub -s <pool>'.
I proposed something like this:

	egrep '^[0-9\.\:\-]{19} zpool scrub '${pool}'$'

Currently there is no way to tell if 'zpool scrub -s' stopped a scrub or
if there was no scrub running. In newer versions of ZFS, it has a
property which tells when the last scrub finished. Once we update ZFS we
could take advantage of it.

All in all, with better grep I'd like to see it committed.

Pawel Jakub Dawidek             
pjd at                 
FreeBSD committer                         Am I Evil? Yes, I Am!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url :

More information about the freebsd-fs mailing list