← Today I learned

My ZFS pool was suspended for 17 hours and nothing told me

At 2 a.m. on a Monday, about a day into its monthly scrub, the 4-bay USB enclosure that holds my 80 TB pool dropped off the USB bus and switched itself off. All four disks vanished at once, so ZFS did what it's designed to do: it suspended the pool. Every read and write stops until you tell it to resume.

Everything that touched the pool just hung: Plex's TV library, my status reports, the nightly backup replica. It stayed that way for about 17 hours, until I noticed and fixed it.

Why nothing told me

ZFS does notice. Its event daemon, ZED, sends a notice for exactly this kind of thing. But ZED sends email to root, and my ISP blocks outgoing mail on port 25. Those emails sat in the server's mail queue and never left the house.

Getting it back

Once the enclosure was powered back on and its disks were visible again:

zpool clear tank

The pool resumed, ZFS resilvered the little bit that had changed (194 MB), and the pool came back ONLINE.

The scary number

When the resilver finished, ZFS reported 32,557 data errors. That sounds like the end of the world. It wasn't.

zpool status -v showed they were reads that failed while the disks were gone: a handful of <metadata> entries and files in an old snapshot. The resilver repaired 0 bytes, every disk showed 0 checksum errors, and the list clears after a clean full scrub. If you ever see that number after an enclosure dropout, read the details before panicking.

The fix: send ZFS alerts somewhere I'll see them

ZED runs any executable in /etc/zfs/zed.d/ whose file name starts with the event's subclass. So one small script, plus a symlink for each event I care about, turns pool trouble into a phone notification through my self-hosted ntfy:

#!/bin/sh
# /etc/zfs/zed.d/homelab-ntfy.sh, linked as io_failure-, statechange-, removed-, deadman- and data-homelab-ntfy.sh
. "${ZED_ZEDLET_DIR}/zed-functions.sh"

case "${ZEVENT_SUBCLASS}" in
  io_failure)  prio=urgent; title="ZFS pool ${ZEVENT_POOL} is SUSPENDED" ;;
  statechange|removed)
    case "${ZEVENT_VDEV_STATE_STR}" in FAULTED|REMOVED|UNAVAIL|DEGRADED) ;; *) exit 0 ;; esac
    prio=high; title="ZFS disk ${ZEVENT_VDEV_STATE_STR} in ${ZEVENT_POOL}" ;;
  deadman)     prio=high; title="ZFS I/O stuck on ${ZEVENT_POOL}" ;;
  data)        prio=high; title="ZFS data errors on ${ZEVENT_POOL}" ;;
  *) exit 0 ;;
esac

# A failing pool can raise thousands of events; one alert per pool and kind every 10 minutes is plenty.
zed_rate_limit "${ZEVENT_POOL};${ZEVENT_SUBCLASS}" 600 || exit 0

curl -fsS -m 15 -H @/etc/ntfy-token.header -H "Title: $title" -H "Priority: $prio" \
  --data-binary "Check the enclosure, then: zpool clear ${ZEVENT_POOL}" https://ntfy.example/alerts
cd /etc/zfs/zed.d
for s in io_failure statechange removed deadman data; do ln -s homelab-ntfy.sh $s-homelab-ntfy.sh; done
systemctl restart zfs-zed

You can test it without breaking anything:

ZED_ZEDLET_DIR=/etc/zfs/zed.d ZEVENT_SUBCLASS=data ZEVENT_POOL=TEST /etc/zfs/zed.d/data-homelab-ntfy.sh

Things I also changed:

  • A pool health check every 5 minutes instead of hourly.
  • Timeouts on every zpool and zfs call in my scripts. A suspended pool makes those commands hang forever, and they can't be killed.

Lessons

  • USB enclosures are fine for bulk storage, but treat a dropout as when, not if. Check the enclosure's power setting (plain "on", not auto or sync) and plan alerts around it.
  • A scrub is the most sustained load those disks ever see, which is exactly when mine let go.
  • If your alerts depend on email, check that email can actually leave the house.