|
21 | 21 | .\" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22 | 22 | .\" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23 | 23 | .\" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
24 |
| - |
25 |
| -.TH ZFS-MOUNT-GENERATOR 8 "Apr 19, 2021" OpenZFS |
26 |
| - |
27 |
| -.SH "NAME" |
28 |
| -zfs\-mount\-generator \- generates systemd mount units for ZFS |
29 |
| -.SH SYNOPSIS |
30 |
| -.B @systemdgeneratordir@/zfs\-mount\-generator |
31 |
| -.sp |
32 |
| -.SH DESCRIPTION |
33 |
| -zfs\-mount\-generator implements the \fBGenerators Specification\fP |
34 |
| -of |
35 |
| -.BR systemd (1), |
36 |
| -and is called during early boot to generate |
37 |
| -.BR systemd.mount (5) |
38 |
| -units for automatically mounted datasets. Mount ordering and dependencies |
39 |
| -are created for all tracked pools (see below). |
40 |
| - |
41 |
| -.SS ENCRYPTION KEYS |
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 |
47 |
| -.BR After , |
48 |
| -.BR Before |
49 |
| -and |
50 |
| -.BR Requires . |
51 |
| -All mount units of encrypted datasets add the key\-load service for their encryption root to their |
52 |
| -.BR Wants |
| 24 | +.\" |
| 25 | +.Dd May 31, 2021 |
| 26 | +.Dt ZFS-MOUNT-GENERATOR 8 |
| 27 | +.Os |
| 28 | +. |
| 29 | +.Sh NAME |
| 30 | +.Nm zfs-mount-generator |
| 31 | +.Nd generate systemd mount units for ZFS filesystems |
| 32 | +.Sh SYNOPSIS |
| 33 | +.Pa @systemdgeneratordir@/zfs-mount-generator |
| 34 | +. |
| 35 | +.Sh DESCRIPTION |
| 36 | +.Nm |
| 37 | +is a |
| 38 | +.Xr systemd.generator 7 |
| 39 | +that generates native |
| 40 | +.Xr systemd.mount 5 |
| 41 | +units for configured ZFS datasets. |
| 42 | +. |
| 43 | +.Ss Properties |
| 44 | +.Bl -tag -compact -width "org.openzfs.systemd:required-by=unit[ unit]…" |
| 45 | +.It Sy mountpoint Ns = |
| 46 | +.No Skipped if Sy legacy No or Sy none . |
| 47 | +. |
| 48 | +.It Sy canmount Ns = |
| 49 | +.No Skipped if Sy off . |
| 50 | +.No Skipped if only Sy noauto |
| 51 | +datasets exist for a given mountpoint and there's more than one. |
| 52 | +.No Datasets with Sy yes No take precedence over ones with Sy noauto No for the same mountpoint. |
| 53 | +.No Sets logical Em noauto No flag if Sy noauto . |
| 54 | +Encryption roots always generate |
| 55 | +.Sy zfs-load-key@ Ns Ar root Ns Sy .service , |
| 56 | +even if |
| 57 | +.Sy off . |
| 58 | +. |
| 59 | +.It Sy atime Ns = , Sy relatime Ns = , Sy devices Ns = , Sy exec Ns = , Sy readonly Ns = , Sy setuid Ns = , Sy nbmand Ns = |
| 60 | +Used to generate mount options equivalent to |
| 61 | +.Nm zfs Cm mount . |
| 62 | +. |
| 63 | +.It Sy encroot Ns = , Sy keylocation Ns = |
| 64 | +If the dataset is an encryption root, its mount unit will bind to |
| 65 | +.Sy zfs-load-key@ Ns Ar root Ns Sy .service , |
| 66 | +with additional dependencies as follows: |
| 67 | +.Bl -tag -compact -offset Ds -width "keylocation=https://URL (et al.)" |
| 68 | +.It Sy keylocation Ns = Ns Sy prompt |
| 69 | +None, uses |
| 70 | +.Xr systemd-ask-password 1 |
| 71 | +.It Sy keylocation Ns = Ns Sy https:// Ns Ar URL Pq et al.\& |
| 72 | +.Sy Wants Ns = , Sy After Ns = : Pa network-online.target |
| 73 | +.It Sy keylocation Ns = Ns Sy file:// Ns < Ns Ar path Ns > |
| 74 | +.Sy RequiresMountsFor Ns = Ns Ar path |
| 75 | +.El |
| 76 | +. |
| 77 | +The service also uses the same |
| 78 | +.Sy Wants Ns = , |
| 79 | +.Sy After Ns = , |
| 80 | +.Sy Requires Ns = , No and |
| 81 | +.Sy RequiresMountsFor Ns = , |
| 82 | +as the mount unit. |
| 83 | +. |
| 84 | +.It Sy org.openzfs.systemd:requires Ns = Ns Pa path Ns Oo " " Ns Pa path Oc Ns … |
| 85 | +.No Sets Sy Requires Ns = for the mount- and key-loading unit. |
| 86 | +. |
| 87 | +.It Sy org.openzfs.systemd:requires-mounts-for Ns = Ns Pa path Ns Oo " " Ns Pa path Oc Ns … |
| 88 | +.No Sets Sy RequiresMountsFor Ns = for the mount- and key-loading unit. |
| 89 | +. |
| 90 | +.It Sy org.openzfs.systemd:before Ns = Ns Pa unit Ns Oo " " Ns Pa unit Oc Ns … |
| 91 | +.No Sets Sy Before Ns = for the mount unit. |
| 92 | +. |
| 93 | +.It Sy org.openzfs.systemd:after Ns = Ns Pa unit Ns Oo " " Ns Pa unit Oc Ns … |
| 94 | +.No Sets Sy After Ns = for the mount unit. |
| 95 | +. |
| 96 | +.It Sy org.openzfs.systemd:wanted-by Ns = Ns Pa unit Ns Oo " " Ns Pa unit Oc Ns … |
| 97 | +.No Sets logical Em noauto No flag (see below). |
| 98 | +.No If not Sy none , No sets Sy WantedBy Ns = for the mount unit. |
| 99 | +.It Sy org.openzfs.systemd:required-by Ns = Ns Pa unit Ns Oo " " Ns Pa unit Oc Ns … |
| 100 | +.No Sets logical Em noauto No flag (see below). |
| 101 | +.No If not Sy none , No sets Sy RequiredBy Ns = for the mount unit. |
| 102 | +. |
| 103 | +.It Sy org.openzfs.systemd:nofail Ns = Ns (unset) Ns | Ns Sy on Ns | Ns Sy off |
| 104 | +Waxes or wanes strength of default reverse dependencies of the mount unit, see below. |
| 105 | +. |
| 106 | +.It Sy org.openzfs.systemd:ignore Ns = Ns Sy on Ns | Ns Sy off |
| 107 | +.No Skip if Sy on . |
| 108 | +.No Defaults to Sy off . |
| 109 | +.El |
| 110 | +. |
| 111 | +.Ss Unit Ordering And Dependencies |
| 112 | +Additionally, unless the pool the dataset resides on |
| 113 | +is imported at generation time, both units gain |
| 114 | +.Sy Wants Ns = Ns Pa zfs-import.target |
53 | 115 | and
|
54 |
| -.BR After . |
55 |
| -The service will not be |
56 |
| -.BR Want ed |
57 |
| -or |
58 |
| -.BR Require d |
59 |
| -by |
60 |
| -.BR local-fs.target |
61 |
| -directly, and so will only be started manually or as a dependency of a started mount unit. |
62 |
| - |
63 |
| -.SS UNIT ORDERING AND DEPENDENCIES |
64 |
| -mount unit's |
65 |
| -.BR Before |
66 |
| -\-> |
67 |
| -key\-load service (if any) |
68 |
| -\-> |
69 |
| -mount unit |
70 |
| -\-> |
71 |
| -mount unit's |
72 |
| -.BR After |
73 |
| - |
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. |
75 |
| - |
76 |
| -.SS CACHE FILE |
| 116 | +.Sy After Ns = Ns Pa zfs-import.target . |
| 117 | +.Pp |
| 118 | +Additionally, unless the logical |
| 119 | +.Em noauto |
| 120 | +flag is set, the mount unit gains a reverse-dependency for |
| 121 | +.Pa local-fs.target |
| 122 | +of strength |
| 123 | +.Bl -tag -compact -offset Ds -width "(unset)" |
| 124 | +.It (unset) |
| 125 | +.Sy WantedBy Ns = No + Sy Before Ns = |
| 126 | +.It Sy on |
| 127 | +.Sy WantedBy Ns = |
| 128 | +.It Sy off |
| 129 | +.Sy RequiredBy Ns = No + Sy Before Ns = |
| 130 | +.El |
| 131 | +. |
| 132 | +.Ss Cache File |
77 | 133 | 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 |
79 |
| -.PP |
80 |
| -.RS 4 |
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 |
82 |
| - |
83 |
| -.RE |
84 |
| -.PP |
85 |
| -for datasets that should be mounted by systemd, should be kept |
86 |
| -separate from the pool at |
87 |
| -.RI @sysconfdir@/zfs/zfs-list.cache/ POOLNAME . |
88 |
| -.PP |
89 |
| -The cache file, if writeable, will be kept synchronized with the pool |
90 |
| -state by the |
91 |
| -.I history_event-zfs-list-cacher.sh |
92 |
| -ZEDLET. |
93 |
| -.PP |
94 |
| -.sp |
95 |
| -.SS PROPERTIES |
96 |
| -The behavior of the generator script can be influenced by the following dataset properties: |
97 |
| -.sp |
98 |
| -.TP 4 |
99 |
| -.BR canmount = on | off | noauto |
100 |
| -If a dataset has |
101 |
| -.BR mountpoint |
102 |
| -set and |
103 |
| -.BR canmount |
104 |
| -is not |
105 |
| -.BR off , |
106 |
| -a mount unit will be generated. |
107 |
| -Additionally, if |
108 |
| -.BR canmount |
109 |
| -is |
110 |
| -.BR on , |
111 |
| -.BR local-fs.target |
112 |
| -will gain a dependency on the mount unit. |
113 |
| - |
114 |
| -This behavior is equal to the |
115 |
| -.BR auto |
116 |
| -and |
117 |
| -.BR noauto |
118 |
| -legacy mount options, see |
119 |
| -.BR systemd.mount (5). |
120 |
| - |
121 |
| -Encryption roots always generate a key-load service, even for |
122 |
| -.BR canmount=off . |
123 |
| -.TP 4 |
124 |
| -.BR org.openzfs.systemd:requires\-mounts\-for = \fIpath\fR... |
125 |
| -Space\-separated list of mountpoints to require to be mounted for this mount unit |
126 |
| -.TP 4 |
127 |
| -.BR org.openzfs.systemd:before = \fIunit\fR... |
128 |
| -The mount unit and associated key\-load service will be ordered before this space\-separated list of units. |
129 |
| -.TP 4 |
130 |
| -.BR org.openzfs.systemd:after = \fIunit\fR... |
131 |
| -The mount unit and associated key\-load service will be ordered after this space\-separated list of units. |
132 |
| -.TP 4 |
133 |
| -.BR org.openzfs.systemd:wanted\-by = \fIunit\fR... |
134 |
| -Space-separated list of units that will gain a |
135 |
| -.BR Wants |
136 |
| -dependency on this mount unit. |
137 |
| -Setting this property implies |
138 |
| -.BR noauto . |
139 |
| -.TP 4 |
140 |
| -.BR org.openzfs.systemd:required\-by = \fIunit\fR... |
141 |
| -Space-separated list of units that will gain a |
142 |
| -.BR Requires |
143 |
| -dependency on this mount unit. |
144 |
| -Setting this property implies |
145 |
| -.BR noauto . |
146 |
| -.TP 4 |
147 |
| -.BR org.openzfs.systemd:nofail = unset | on | off |
148 |
| -Toggles between a |
149 |
| -.BR Wants |
150 |
| -and |
151 |
| -.BR Requires |
152 |
| -type of dependency between the mount unit and |
153 |
| -.BR local-fs.target , |
154 |
| -if |
155 |
| -.BR noauto |
156 |
| -isn't set or implied. |
157 |
| - |
158 |
| -.BR on : |
159 |
| -Mount will be |
160 |
| -.BR WantedBy |
161 |
| -local-fs.target |
162 |
| - |
163 |
| -.BR off : |
164 |
| -Mount will be |
165 |
| -.BR Before |
166 |
| -and |
167 |
| -.BR RequiredBy |
168 |
| -local-fs.target |
169 |
| - |
170 |
| -.BR unset : |
171 |
| -Mount will be |
172 |
| -.BR Before |
173 |
| -and |
174 |
| -.BR WantedBy |
175 |
| -local-fs.target |
176 |
| -.TP 4 |
177 |
| -.BR org.openzfs.systemd:ignore = on | off |
178 |
| -If set to |
179 |
| -.BR on , |
180 |
| -do not generate a mount unit for this dataset. |
181 |
| - |
182 |
| -See also |
183 |
| -.BR systemd.mount (5) |
184 |
| - |
185 |
| -.PP |
186 |
| -.SH ENVIRONMENT |
| 134 | +information on ZFS mountpoints must be stored separately. |
| 135 | +The output of |
| 136 | +.Dl Nm zfs Cm list Fl Ho Ar name , Ns Aq every property above in order |
| 137 | +for datasets that should be mounted by systemd should be kept at |
| 138 | +.Pa @sysconfdir@/zfs/zfs-list.cache/ Ns Ar poolname , |
| 139 | +and, if writeable, will be kept synchronized for the entire pool by the |
| 140 | +.Pa history_event-zfs-list-cacher.sh |
| 141 | +ZEDLET, if enabled |
| 142 | +.Pq see Xr zed 8 . |
| 143 | +. |
| 144 | +.Sh ENVIRONMENT |
187 | 145 | The
|
188 |
| -.BR $ZFS_DEBUG |
189 |
| -environment variable, which can either be 0 (default), |
190 |
| -1 (print summary accounting information at the end), |
191 |
| -or at least 2 (print accounting information for each subprocess as it finishes). |
192 |
| - |
193 |
| -If not present, /proc/cmdline is additionally checked for |
194 |
| -.BR debug , |
195 |
| -in which case the debug level is set to 2. |
196 |
| - |
197 |
| -.SH EXAMPLE |
| 146 | +.Sy ZFS_DEBUG |
| 147 | +environment variable can either be |
| 148 | +.Sy 0 |
| 149 | +(default), |
| 150 | +.Sy 1 |
| 151 | +(print summary accounting information at the end), or at least |
| 152 | +.Sy 2 |
| 153 | +(print accounting information for each subprocess as it finishes). |
| 154 | +. |
| 155 | +If not present, |
| 156 | +.Pa /proc/cmdline |
| 157 | +is additionally checked for |
| 158 | +.Qq debug , |
| 159 | +in which case the debug level is set to |
| 160 | +.Sy 2 . |
| 161 | +. |
| 162 | +.Sh EXAMPLES |
198 | 163 | To begin, enable tracking for the pool:
|
199 |
| -.PP |
200 |
| -.RS 4 |
201 |
| -touch |
202 |
| -.RI @sysconfdir@/zfs/zfs-list.cache/ POOLNAME |
203 |
| -.RE |
204 |
| -.PP |
205 |
| -Then, enable the tracking ZEDLET: |
206 |
| -.PP |
207 |
| -.RS 4 |
208 |
| -ln -s "@zfsexecdir@/zed.d/history_event-zfs-list-cacher.sh" "@sysconfdir@/zfs/zed.d" |
209 |
| - |
210 |
| -systemctl enable zfs-zed.service |
211 |
| - |
212 |
| -systemctl restart zfs-zed.service |
213 |
| -.RE |
214 |
| -.PP |
215 |
| -Force the running of the ZEDLET by setting a monitored property, e.g. |
216 |
| -.BR canmount , |
217 |
| -for at least one dataset in the pool: |
218 |
| -.PP |
219 |
| -.RS 4 |
220 |
| -zfs set canmount=on |
221 |
| -.I DATASET |
222 |
| -.RE |
223 |
| -.PP |
224 |
| -This forces an update to the stale cache file. |
225 |
| - |
226 |
| -To test the generator output, run |
227 |
| -.PP |
228 |
| -.RS 4 |
229 |
| -@systemdgeneratordir@/zfs-mount-generator /tmp/zfs-mount-generator |
230 |
| -.RE |
231 |
| -.PP |
232 |
| -This will generate units and dependencies in |
233 |
| -.I /tmp/zfs-mount-generator |
234 |
| -for you to inspect them. The second and third argument are ignored. |
235 |
| - |
236 |
| -If you're satisfied with the generated units, instruct systemd to re-run all generators: |
237 |
| -.PP |
238 |
| -.RS 4 |
239 |
| -systemctl daemon-reload |
240 |
| -.RE |
241 |
| -.PP |
242 |
| - |
243 |
| -.sp |
244 |
| -.SH SEE ALSO |
245 |
| -.BR zfs (5) |
246 |
| -.BR zfs-events (5) |
247 |
| -.BR zed (8) |
248 |
| -.BR zpool (5) |
249 |
| -.BR systemd (1) |
250 |
| -.BR systemd.target (5) |
251 |
| -.BR systemd.special (7) |
252 |
| -.BR systemd.mount (7) |
| 164 | +.Dl # Nm touch Pa @sysconfdir@/zfs/zfs-list.cache/ Ns Ar poolname |
| 165 | +Then enable the tracking ZEDLET: |
| 166 | +.Dl # Nm ln Fl s Pa @zfsexecdir@/zed.d/history_event-zfs-list-cacher.sh @sysconfdir@/zfs/zed.d |
| 167 | +.Dl # Nm systemctl Cm enable Pa zfs-zed.service |
| 168 | +.Dl # Nm systemctl Cm restart Pa zfs-zed.service |
| 169 | +.Pp |
| 170 | +If no history event is in the queue, |
| 171 | +inject one to ensure the ZEDLET runs to refresh the cache file |
| 172 | +by setting a monitored property somewhere on the pool: |
| 173 | +.Dl # Nm zfs Cm set Sy relatime Ns = Ns Sy off Ar poolname/dset |
| 174 | +.Dl # Nm zfs Cm inherit Sy relatime Ar poolname/dset |
| 175 | +.Pp |
| 176 | +To test the generator output: |
| 177 | +.Dl $ Nm mkdir Pa /tmp/zfs-mount-generator |
| 178 | +.Dl $ Nm @systemdgeneratordir@/zfs-mount-generator Pa /tmp/zfs-mount-generator |
| 179 | +. |
| 180 | +If the generated units are satisfactory, instruct |
| 181 | +.Nm systemd |
| 182 | +to re-run all generators: |
| 183 | +.Dl # Nm systemctl daemon-reload |
| 184 | +. |
| 185 | +.Sh SEE ALSO |
| 186 | +.Xr systemd.mount 5 , |
| 187 | +.Xr systemd.target 5 , |
| 188 | +.Xr zfs 5 , |
| 189 | +.Xr zfs-events 5 , |
| 190 | +.Xr systemd.generator 7 , |
| 191 | +.Xr systemd.special 7 , |
| 192 | +.Xr zed 8 |
0 commit comments