Copyright 2018 Antonio Russo <antonio.e.russo@gmail.com>
Copyright 2019 Kjeld Schouten-Lebbing <kjeld@schouten-lebbing.nl>
Copyright 2020 InsanePrawn <insane.prawny@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
zfs list -H -o name,mountpoint,canmount,atime,relatime,devices,exec,readonly,setuid,nbmand,encroot,keylocation,org.openzfs.systemd:requires,org.openzfs.systemd:requires-mounts-for,org.openzfs.systemd:before,org.openzfs.systemd:after,org.openzfs.systemd:wanted-by,org.openzfs.systemd:required-by,org.openzfs.systemd:nofail,org.openzfs.systemd:ignore
for datasets that should be mounted by systemd, should be kept separate from the pool, at
@sysconfdir@/zfs/zfs-list.cache/ POOLNAME .
The cache file, if writeable, will be kept synchronized with the pool state by the ZEDLET
4 canmount = on | off | noauto If a dataset has mountpoint set and canmount is not off , a mount unit will be generated. Additionally, if canmount is on , local-fs.target will gain a dependency on the mount unit. This behavior is equal to the auto and noauto legacy mount options, see systemd.mount (5). Encryption roots always generate a key-load service, even for canmount=off .
4 org.openzfs.systemd:requires-mounts-for = path... Space-separated list of mountpoints to require to be mounted for this mount unit
4 org.openzfs.systemd:before = unit... The mount unit and associated key-load service will be ordered before this space-separated list of units.
4 org.openzfs.systemd:after = unit... The mount unit and associated key-load service will be ordered after this space-separated list of units.
4 org.openzfs.systemd:wanted-by = unit... Space-separated list of units that will gain a Wants dependency on this mount unit. Setting this property implies noauto .
4 org.openzfs.systemd:required-by = unit... Space-separated list of units that will gain a Requires dependency on this mount unit. Setting this property implies noauto .
4 org.openzfs.systemd:nofail = unset | on | off Toggles between a Wants and Requires type of dependency between the mount unit and local-fs.target , if noauto isn't set or implied. on : Mount will be WantedBy local-fs.target off : Mount will be Before and RequiredBy local-fs.target unset : Mount will be Before and WantedBy local-fs.target
4 org.openzfs.systemd:ignore = on | off If set to on , do not generate a mount unit for this dataset.
See also systemd.mount (5)
touch @sysconfdir@/zfs/zfs-list.cache/ POOLNAME
Then, enable the tracking ZEDLET:
ln -s "@zfsexecdir@/zed.d/history_event-zfs-list-cacher.sh" "@sysconfdir@/zfs/zed.d" systemctl enable zfs-zed.service systemctl restart zfs-zed.service
Force the running of the ZEDLET by setting a monitored property, e.g. canmount , for at least one dataset in the pool:
zfs set canmount=on DATASET
This forces an update to the stale cache file. To test the generator output, run
@systemdgeneratordir@/zfs-mount-generator /tmp/zfs-mount-generator . .
This will generate units and dependencies in /tmp/zfs-mount-generator for you to inspect them. The second and third argument are ignored. If you're satisfied with the generated units, instruct systemd to re-run all generators:
systemctl daemon-reload