ZED(8)
π ZED β ZFS Event Daemon π
okay so bestie, welcome to the System Manager's Manual, section 8 π this is the whole vibe of the ZFS Event Daemon and I promise it's gonna be iconic.
β¨ NAME β¨
ZED β the ZFS Event Daemon, your fave little background gremlin π§
β¨ SYNOPSIS β¨
ZED [-fFhILMvVZ] [-d zedletdir] [-p pidfile] [-P path] [-s statefile]
[-j jobs] [-b buflen]
β¨ DESCRIPTION β¨
So like, the ZED (that's the ZFS Event Daemon bestie, keep up π ) monitors events generated by the ZFS kernel module. The moment a zevent (aka a ZFS Event) gets posted, ZED runs whatever ZEDLETs β yes that stands for ZFS Event Daemon Linkage for Executable Tasks, a whole mouthful, I know π β have been enabled for that zevent's class.
no cap, that's the entire job. she watches, she dispatches. main character energy fr fr π
β¨ OPTIONS β¨
-hβ shows you a lil summary of all the command-line options. ur cheat sheet π«Ά-Lβ displays the license info. legal girlies rise πΈ-Vβ displays version info. know ur era β¨-vβ be verbose. she will talk π¬-fβ force the daemon to run if at all possible: disables security checks and just throws caution to the wind. > not recommended for use in production, bestie, I'm so serious π-Fβ don't daemonize. she stays attached to the controlling terminal and logs to the standard I/O streams. clingy in the cutest way π-Mβ locks all current and future pages in the virtual memory address space. this may help the daemon stay responsive when the system is under heavy memory pressure. she's holding on and not letting go πͺ-Iβ requests that the daemon idle rather than exit when the kernel modules aren't loaded. processing of events will start, or resume, when the kernel modules are (re)loaded. heads up tho: under Linux the kernel modules cannot be unloaded while the daemon is running. she's got the door locked π-Zβ zeroes the daemon's state, which lets zevents still chillin' inside the kernel get reprocessed. fresh start era π-dzedletdir β read the enabled ZEDLETs from the directory you specify. π-ppidfile β write the daemon's process ID into the specified file. πͺͺ-Ppath β a custom$PATHfor zedlets to use. normally zedlets run in a locked-down environment with hardcoded paths to the ZFS commands ($ZFS,$ZPOOL,$ZED, β¦) and a hard-coded$PATHβ this is done for security reasons, periodt. BUT, the ZFS test suite uses a custom PATH for its ZFS commands and passes it to ZED with-P. so in short:-Pis only to be used by the ZFS test suite. > never use it in production! like, ever ever. π¨-sstatefile β write the daemon's state to the specified file. π-jjobs β allow at most jobs ZEDLETs to run concurrently, delaying execution of new ones until they finish. defaults to16. she's got a queue and she respects it ποΈ-bbuflen β cap kernel event buffer growth to buflen entries. this buffer grows when the daemon misses an event, but it results in unreclaimable memory use in the kernel π¬. a value of0removes the cap entirely. defaults to1048576.
β¨ ZEVENTS β¨
A zevent is made up of a list of nvpairs (name/value pairs). every single zevent contains an EID (Event IDentifier) that uniquely identifies it throughout the whole lifetime of the loaded ZFS kernel module. this EID is a monotonically increasing integer that resets to 1 every time the kernel module is loaded. π
Each zevent also carries a class string that identifies the type of event. and for brevity, a subclass string is defined that omits the leading components of the class string. there are additional nvpairs hanging around too, to give you the event details. π΅οΈ
The kernel keeps a list of recent zevents that you can view (along with their associated lists of nvpairs) using the zpool events -v command. go peek π
β¨ CONFIGURATION β¨
ZEDLETs that get invoked in response to zevents live in the enabled-zedlets directory (zedletdir). you can symlink them or copy them from the installed-zedlets directory β symlinks let you get automatic updates from the installed ZEDLETs, whereas copies preserve your local modifications. choose ur fighter π₯
As a security measure β since ownership change is a privileged operation β ZEDLETs must be owned by root. they must have execute permissions for the user, but they must not have write permissions for group or other. dotfiles are ignored, sorry hidden girlies π
ZEDLETs are named after the zevent class they should be invoked for. specifically, a ZEDLET gets invoked for a given zevent if either its class or subclass string is a prefix of its filename (and is followed by a non-alphabetic character). as a special case, the prefix all matches all zevents. and yes, multiple ZEDLETs may be invoked for a single zevent β it's a party π
β¨ ZEDLETS β¨
ZEDLETs are executables invoked by the ZED in response to a given zevent. they should be written under the presumption that they can be invoked concurrently, and they should use appropriate locking to access any shared resources. the one exception to this is "synchronous zedlets", which we get into later on this page π
Common variables used by ZEDLETs can be stored in the default rc file, which is sourced by scripts; those variables should be prefixed with ZED_.
The zevent nvpairs are passed to ZEDLETs as environment variables. each nvpair name is converted to an environment variable like this:
- it is prefixed with
ZEVENT_, - it is converted to uppercase, and
- each non-alphanumeric character is converted to an underscore.
Some additional environment variables have been defined to present certain nvpair values in a more convenient form. an incomplete list of zevent environment variables is as follows:
ZEVENT_EIDβ the Event IDentifier.ZEVENT_CLASSβ the zevent class string.ZEVENT_SUBCLASSβ the zevent subclass string.ZEVENT_TIMEβ the time at which the zevent was posted, as βseconds nanosecondsβ since the Epoch.ZEVENT_TIME_SECSβ the seconds component ofZEVENT_TIME.ZEVENT_TIME_NSECSβ the nanoseconds component ofZEVENT_TIME.ZEVENT_TIME_STRINGβ an almost-RFC3339-compliant string forZEVENT_TIME.
Additionally, these ZED & ZFS variables are defined:
ZED_PIDβ the daemon's process ID.ZED_ZEDLET_DIRβ the daemon's current enabled-zedlets directory.ZFS_ALIASβ the alias (βname-version-releaseβ) string of the ZFS distribution the daemon is part of.ZFS_VERSIONβ the ZFS version the daemon is part of.ZFS_RELEASEβ the ZFS release the daemon is part of.
ZEDLETs may need to call other ZFS commands. the installation paths of the following executables are defined as environment variables: ZDB, ZED, ZFS, ZINJECT, and ZPOOL. these variables may be overridden in the rc file. π οΈ
β¨ Synchronous ZEDLETS β¨
ZED's normal behavior is to spawn off zedlets in parallel and ignore their completion order. which means ZED can potentially have zedlets for event ID number 2 starting before zedlets for event ID number 1 have finished. most of the time this is fine, and honestly it actually helps when the system is getting absolutely hammered with hundreds of events. π₯
But sometimes you want your zedlets executed in sequence with the event ID. and that, bestie, is where synchronous zedlets come in. β¨
ZED will wait for all previously spawned zedlets to finish before running a synchronous zedlet. synchronous zedlets are guaranteed to be the only zedlet running. no other zedlets may run in parallel with a synchronous zedlet. users should be careful to only use synchronous zedlets when needed, since they decrease parallelism. π’
To make a zedlet synchronous, simply add a -sync- immediately following the event name in the zedlet's file name:
EVENT_NAME-sync-ZEDLETNAME.sh
For example, if you wanted a synchronous statechange script:
statechange-sync-myzedlet.sh
β¨ FILES β¨
/etc/zfs/zed.dβ the default directory for enabled ZEDLETs. π/etc/zfs/zed.d/zed.rcβ the default rc file for common variables used by ZEDLETs. π/usr/lib/zfs-linux/zed.dβ the default directory for installed ZEDLETs. π¦/run/zed.pidβ the default file containing the daemon's process ID. πͺͺ/run/zed.stateβ the default file containing the daemon's state. ποΈ
β¨ SIGNALS β¨
SIGHUPβ reconfigure the daemon and rescan the directory for enabled ZEDLETs. glow-up + refresh πSIGTERM,SIGINTβ terminate the daemon. bye bestie π
β¨ SEE ALSO β¨
zfs(8), zpool(8), zpool-events(8)
β¨ NOTES β¨
The ZED requires root privileges. π
Do not taunt the ZED. π«£
β¨ BUGS β¨
- ZEDLETs are unable to return state/status information to the kernel. π
- Internationalization support via gettext has not been added. π
OpenZFS Β· August 22, 2022 β and that's the whole page, bestie π mwah, go forth and daemon responsibly πβ¨π¦
π¦ where this page comes from
- ubuntu resolute: zfs-zed 2.4.1-1ubuntu5 Β· CDDL-1.0
- ubuntu resolute: zfs-zed 2.4.1-1ubuntu5.1 Β· CDDL-1.0
- ubuntu stonking: zfs-zed 2.4.4-1ubuntu4 Β· CDDL-1.0
- π the page's license: CDDL-1.0
- Copyright (C) 2013-2014 Lawrence Livermore National Security, LLC
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms