bin/150228: [PATCH] /etc/periodic/daily/800.scrub-zfs errors with faulted zpools

Josh Paetzel jpaetzel at
Thu Sep 2 15:40:07 UTC 2010

>Number:         150228
>Category:       bin
>Synopsis:       [PATCH] /etc/periodic/daily/800.scrub-zfs errors with faulted zpools
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Sep 02 15:40:06 UTC 2010
>Originator:     Josh Paetzel
>Release:        9.0-CURRENT
FreeBSD 9.0-CURRENT FreeBSD 9.0-CURRENT #2: Mon Jul 12 22:22:49 CDT 2010     jpaetzel at  amd64
800.scrub-zfs is a periodic script you can enable to perform periodic scrubs of ZFS filesystems.  If you have faulted zpools the script generates sh errors due to some of the zpool commands generating no output.

Faulted zpools can happen for reasons other than hardware failure, for example if you use ZFS on removable devices when they are unplugged zpool status will show them as faulted.
Put ZFS on a removable device, export and detach it from the system.
# echo 'daily_scrub_zfs_enable="YES"' >> /etc/periodic.conf
# /etc/periodic/daily/800.scrub-zfs
Apply attached patch

Patch attached with submission follows:

Index: 800.scrub-zfs
--- 800.scrub-zfs	(revision 212149)
+++ 800.scrub-zfs	(working copy)
@@ -1,6 +1,6 @@
-# $FreeBSD$
+# $FreeBSD: src/etc/periodic/daily/800.scrub-zfs,v 1.1 2010/06/15 08:58:16 netchild Exp $
 # If there is a global system configuration file, suck it in.
@@ -24,13 +24,17 @@
 	for pool in ${daily_scrub_zfs_pools}; do
 		# sanity check
-		zpool list ${pool} >/dev/null 2>&1
+		_status=`zpool list ${pool} | sed -n -e '$p'` >/dev/null 2>&1
 		if [ $? -ne 0 ]; then
 			echo "   WARNING: pool '${pool}' specified in"
 			echo "            '/etc/periodic.conf:daily_scrub_zfs_pools'"
 			echo "            does not exist"
+		if echo ${_status} | grep FAULTED >/dev/null 2>&1; then
+			echo "Skipping faulted pool: ${pool}"
+			continue
+		fi
 		# successful only if there is at least one pool to scrub


More information about the freebsd-bugs mailing list