1.\" SPDX-License-Identifier: MIT 2.\" 3.\" Copyright 2018 Antonio Russo <antonio.e.russo@gmail.com> 4.\" Copyright 2019 Kjeld Schouten-Lebbing <kjeld@schouten-lebbing.nl> 5.\" Copyright 2020 InsanePrawn <insane.prawny@gmail.com> 6.\" 7.\" Permission is hereby granted, free of charge, to any person obtaining 8.\" a copy of this software and associated documentation files (the 9.\" "Software"), to deal in the Software without restriction, including 10.\" without limitation the rights to use, copy, modify, merge, publish, 11.\" distribute, sublicense, and/or sell copies of the Software, and to 12.\" permit persons to whom the Software is furnished to do so, subject to 13.\" the following conditions: 14.\" 15.\" The above copyright notice and this permission notice shall be 16.\" included in all copies or substantial portions of the Software. 17.\" 18.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19.\" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21.\" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22.\" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23.\" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24.\" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25.\" 26.Dd May 31, 2021 27.Dt ZFS-MOUNT-GENERATOR 8 28.Os 29. 30.Sh NAME 31.Nm zfs-mount-generator 32.Nd generate systemd mount units for ZFS filesystems 33.Sh SYNOPSIS 34.Pa @systemdgeneratordir@/zfs-mount-generator 35. 36.Sh DESCRIPTION 37.Nm 38is a 39.Xr systemd.generator 7 40that generates native 41.Xr systemd.mount 5 42units for configured ZFS datasets. 43. 44.Ss Properties 45.Bl -tag -compact -width "org.openzfs.systemd:required-by=unit[ unit]…" 46.It Sy mountpoint Ns = 47.No Skipped if Sy legacy No or Sy none . 48. 49.It Sy canmount Ns = 50.No Skipped if Sy off . 51.No Skipped if only Sy noauto 52datasets exist for a given mountpoint and there's more than one. 53.No Datasets with Sy yes No take precedence over ones with Sy noauto No for the same mountpoint . 54.No Sets logical Em noauto No flag if Sy noauto . 55Encryption roots always generate 56.Sy zfs-load-key@ Ns Ar root Ns Sy .service , 57even if 58.Sy off . 59. 60.It Sy atime Ns = , Sy relatime Ns = , Sy devices Ns = , Sy exec Ns = , Sy readonly Ns = , Sy setuid Ns = , Sy nbmand Ns = 61Used to generate mount options equivalent to 62.Nm zfs Cm mount . 63. 64.It Sy encroot Ns = , Sy keylocation Ns = 65If the dataset is an encryption root, its mount unit will bind to 66.Sy zfs-load-key@ Ns Ar root Ns Sy .service , 67with additional dependencies as follows: 68.Bl -tag -compact -offset Ds -width "keylocation=https://URL (et al.)" 69.It Sy keylocation Ns = Ns Sy prompt 70None, uses 71.Xr systemd-ask-password 1 72.It Sy keylocation Ns = Ns Sy https:// Ns Ar URL Pq et al.\& 73.Sy Wants Ns = , Sy After Ns = : Pa network-online.target 74.It Sy keylocation Ns = Ns Sy file:// Ns < Ns Ar path Ns > 75.Sy RequiresMountsFor Ns = Ns Ar path 76.El 77. 78The service also uses the same 79.Sy Wants Ns = , 80.Sy After Ns = , 81.Sy Requires Ns = , No and 82.Sy RequiresMountsFor Ns = , 83as the mount unit. 84. 85.It Sy org.openzfs.systemd:requires Ns = Ns Pa path Ns Oo " " Ns Pa path Oc Ns … 86.No Sets Sy Requires Ns = for the mount- and key-loading unit. 87. 88.It Sy org.openzfs.systemd:requires-mounts-for Ns = Ns Pa path Ns Oo " " Ns Pa path Oc Ns … 89.No Sets Sy RequiresMountsFor Ns = for the mount- and key-loading unit. 90. 91.It Sy org.openzfs.systemd:before Ns = Ns Pa unit Ns Oo " " Ns Pa unit Oc Ns … 92.No Sets Sy Before Ns = for the mount unit. 93. 94.It Sy org.openzfs.systemd:after Ns = Ns Pa unit Ns Oo " " Ns Pa unit Oc Ns … 95.No Sets Sy After Ns = for the mount unit. 96. 97.It Sy org.openzfs.systemd:wanted-by Ns = Ns Pa unit Ns Oo " " Ns Pa unit Oc Ns … 98.No Sets logical Em noauto No flag (see below) . 99.No If not Sy none , No sets Sy WantedBy Ns = for the mount unit. 100.It Sy org.openzfs.systemd:required-by Ns = Ns Pa unit Ns Oo " " Ns Pa unit Oc Ns … 101.No Sets logical Em noauto No flag (see below) . 102.No If not Sy none , No sets Sy RequiredBy Ns = for the mount unit. 103. 104.It Sy org.openzfs.systemd:nofail Ns = Ns (unset) Ns | Ns Sy on Ns | Ns Sy off 105Waxes or wanes strength of default reverse dependencies of the mount unit, see 106below. 107. 108.It Sy org.openzfs.systemd:ignore Ns = Ns Sy on Ns | Ns Sy off 109.No Skip if Sy on . 110.No Defaults to Sy off . 111.El 112. 113.Ss Unit Ordering And Dependencies 114Additionally, unless the pool the dataset resides on 115is imported at generation time, both units gain 116.Sy Wants Ns = Ns Pa zfs-import.target 117and 118.Sy After Ns = Ns Pa zfs-import.target . 119.Pp 120Additionally, unless the logical 121.Em noauto 122flag is set, the mount unit gains a reverse-dependency for 123.Pa local-fs.target 124of strength 125.Bl -tag -compact -offset Ds -width "(unset)" 126.It (unset) 127.Sy WantedBy Ns = No + Sy Before Ns = 128.It Sy on 129.Sy WantedBy Ns = 130.It Sy off 131.Sy RequiredBy Ns = No + Sy Before Ns = 132.El 133. 134.Ss Cache File 135Because ZFS pools may not be available very early in the boot process, 136information on ZFS mountpoints must be stored separately. 137The output of 138.Dl Nm zfs Cm list Fl Ho Ar name , Ns Aq every property above in order 139for datasets that should be mounted by systemd should be kept at 140.Pa @sysconfdir@/zfs/zfs-list.cache/ Ns Ar poolname , 141and, if writeable, will be kept synchronized for the entire pool by the 142.Pa history_event-zfs-list-cacher.sh 143ZEDLET, if enabled 144.Pq see Xr zed 8 . 145. 146.Sh ENVIRONMENT 147If the 148.Sy ZFS_DEBUG 149environment variable is nonzero 150.Pq or unset and Pa /proc/cmdline No contains Qq Sy debug , 151print summary accounting information at the end. 152. 153.Sh EXAMPLES 154To begin, enable tracking for the pool: 155.Dl # Nm touch Pa @sysconfdir@/zfs/zfs-list.cache/ Ns Ar poolname 156Then enable the tracking ZEDLET: 157.Dl # Nm ln Fl s Pa @zfsexecdir@/zed.d/history_event-zfs-list-cacher.sh @sysconfdir@/zfs/zed.d 158.Dl # Nm systemctl Cm enable Pa zfs-zed.service 159.Dl # Nm systemctl Cm restart Pa zfs-zed.service 160.Pp 161If no history event is in the queue, 162inject one to ensure the ZEDLET runs to refresh the cache file 163by setting a monitored property somewhere on the pool: 164.Dl # Nm zfs Cm set Sy relatime Ns = Ns Sy off Ar poolname/dset 165.Dl # Nm zfs Cm inherit Sy relatime Ar poolname/dset 166.Pp 167To test the generator output: 168.Dl $ Nm mkdir Pa /tmp/zfs-mount-generator 169.Dl $ Nm @systemdgeneratordir@/zfs-mount-generator Pa /tmp/zfs-mount-generator 170. 171If the generated units are satisfactory, instruct 172.Nm systemd 173to re-run all generators: 174.Dl # Nm systemctl daemon-reload 175. 176.Sh SEE ALSO 177.Xr systemd.mount 5 , 178.Xr systemd.target 5 , 179.Xr zfs 5 , 180.Xr systemd.generator 7 , 181.Xr systemd.special 7 , 182.Xr zed 8 , 183.Xr zpool-events 8 184