2 .\" Copyright 2018 Antonio Russo <antonio.e.russo@gmail.com>
3 .\" Copyright 2019 Kjeld Schouten-Lebbing <kjeld@schouten-lebbing.nl>
4 .\" Copyright 2020 InsanePrawn <insane.prawny@gmail.com>
6 .\" Permission is hereby granted, free of charge, to any person obtaining
7 .\" a copy of this software and associated documentation files (the
8 .\" "Software"), to deal in the Software without restriction, including
9 .\" without limitation the rights to use, copy, modify, merge, publish,
10 .\" distribute, sublicense, and/or sell copies of the Software, and to
11 .\" permit persons to whom the Software is furnished to do so, subject to
12 .\" the following conditions:
14 .\" The above copyright notice and this permission notice shall be
15 .\" included in all copies or substantial portions of the Software.
17 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 .\" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 .\" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 .\" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 .\" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 .\" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 .TH "ZFS\-MOUNT\-GENERATOR" "8" "2020-01-19" "ZFS" "zfs-mount-generator" "\""
28 zfs\-mount\-generator \- generates systemd mount units for ZFS
30 .B @systemdgeneratordir@/zfs\-mount\-generator
33 zfs\-mount\-generator implements the \fBGenerators Specification\fP
36 and is called during early boot to generate
38 units for automatically mounted datasets. Mount ordering and dependencies
39 are created for all tracked pools (see below).
42 If the dataset is an encryption root, a service that loads the associated key (either from file or through a
43 .BR systemd\-ask\-password (1)
44 prompt) will be created. This service
45 . BR RequiresMountsFor
46 the path of the key (if file-based) and also copies the mount unit's
51 All mount units of encrypted datasets add the key\-load service for their encryption root to their
55 The service will not be
61 directly, and so will only be started manually or as a dependency of a started mount unit.
63 .SS UNIT ORDERING AND DEPENDENCIES
67 key\-load service (if any)
74 It is worth nothing that when a mount unit is activated, it activates all available mount units for parent paths to its mountpoint, i.e. activating the mount unit for /tmp/foo/1/2/3 automatically activates all available mount units for /tmp, /tmp/foo, /tmp/foo/1, and /tmp/foo/1/2. This is true for any combination of mount units from any sources, not just ZFS.
77 Because ZFS pools may not be available very early in the boot process,
78 information on ZFS mountpoints must be stored separately. The output of the command
81 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
85 for datasets that should be mounted by systemd, should be kept
86 separate from the pool, at
89 .RI @sysconfdir@/zfs/zfs-list.cache/ POOLNAME
93 The cache file, if writeable, will be kept synchronized with the pool
97 history_event-zfs-list-cacher.sh .
102 The behavior of the generator script can be influenced by the following dataset properties:
105 .BR canmount = on | off | noauto
112 a mount unit will be generated.
118 will gain a dependency on the mount unit.
120 This behavior is equal to the
124 legacy mount options, see
125 .BR systemd.mount (5).
127 Encryption roots always generate a key-load service, even for
130 .BR org.openzfs.systemd:requires\-mounts\-for = \fIpath\fR...
131 Space\-separated list of mountpoints to require to be mounted for this mount unit
133 .BR org.openzfs.systemd:before = \fIunit\fR...
134 The mount unit and associated key\-load service will be ordered before this space\-separated list of units.
136 .BR org.openzfs.systemd:after = \fIunit\fR...
137 The mount unit and associated key\-load service will be ordered after this space\-separated list of units.
139 .BR org.openzfs.systemd:wanted\-by = \fIunit\fR...
140 Space-separated list of units that will gain a
142 dependency on this mount unit.
143 Setting this property implies
146 .BR org.openzfs.systemd:required\-by = \fIunit\fR...
147 Space-separated list of units that will gain a
149 dependency on this mount unit.
150 Setting this property implies
153 .BR org.openzfs.systemd:nofail = unset | on | off
158 type of dependency between the mount unit and
159 .BR local-fs.target ,
162 isn't set or implied.
183 .BR org.openzfs.systemd:ignore = on | off
186 do not generate a mount unit for this dataset.
190 .BR systemd.mount (5)
194 To begin, enable tracking for the pool:
198 .RI @sysconfdir@/zfs/zfs-list.cache/ POOLNAME
201 Then, enable the tracking ZEDLET:
204 ln -s "@zfsexecdir@/zed.d/history_event-zfs-list-cacher.sh" "@sysconfdir@/zfs/zed.d"
206 systemctl enable zfs-zed.service
208 systemctl restart zfs-zed.service
211 Force the running of the ZEDLET by setting a monitored property, e.g.
213 for at least one dataset in the pool:
220 This forces an update to the stale cache file.
222 To test the generator output, run
225 @systemdgeneratordir@/zfs-mount-generator /tmp/zfs-mount-generator . .
228 This will generate units and dependencies in
229 .I /tmp/zfs-mount-generator
230 for you to inspect them. The second and third argument are ignored.
232 If you're satisfied with the generated units, instruct systemd to re-run all generators:
235 systemctl daemon-reload
246 .BR systemd.target (5)
247 .BR systemd.special (7)
248 .BR systemd.mount (7)