1 <?xml version='
1.0'
?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC
"-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
6 SPDX-License-Identifier: LGPL-2.1+
9 <refentry id=
"systemd.mount">
11 <title>systemd.mount
</title>
12 <productname>systemd
</productname>
16 <refentrytitle>systemd.mount
</refentrytitle>
17 <manvolnum>5</manvolnum>
21 <refname>systemd.mount
</refname>
22 <refpurpose>Mount unit configuration
</refpurpose>
26 <para><filename><replaceable>mount
</replaceable>.mount
</filename></para>
30 <title>Description
</title>
32 <para>A unit configuration file whose name ends in
33 <literal>.mount
</literal> encodes information about a file system
34 mount point controlled and supervised by systemd.
</para>
36 <para>This man page lists the configuration options specific to
38 <citerefentry><refentrytitle>systemd.unit
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
39 for the common options of all unit configuration files. The common
40 configuration items are configured in the generic [Unit] and
41 [Install] sections. The mount specific configuration options are
42 configured in the [Mount] section.
</para>
44 <para>Additional options are listed in
45 <citerefentry><refentrytitle>systemd.exec
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
46 which define the execution environment the
47 <citerefentry project='man-pages'
><refentrytitle>mount
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
48 program is executed in, and in
49 <citerefentry><refentrytitle>systemd.kill
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
50 which define the way the processes are terminated, and in
51 <citerefentry><refentrytitle>systemd.resource-control
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
52 which configure resource control settings for the processes of the
55 <para>Note that the options
<varname>User=
</varname> and
56 <varname>Group=
</varname> are not useful for mount units.
57 systemd passes two parameters to
58 <citerefentry project='man-pages'
><refentrytitle>mount
</refentrytitle><manvolnum>8</manvolnum></citerefentry>;
59 the values of
<varname>What=
</varname> and
<varname>Where=
</varname>.
60 When invoked in this way,
61 <citerefentry project='man-pages'
><refentrytitle>mount
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
62 does not read any options from
<filename>/etc/fstab
</filename>, and
63 must be run as UID
0.
</para>
65 <para>Mount units must be named after the mount point directories they control. Example: the mount point
<filename
66 noindex='true'
>/home/lennart
</filename> must be configured in a unit file
<filename>home-lennart.mount
</filename>.
67 For details about the escaping logic used to convert a file system path to a unit name, see
68 <citerefentry><refentrytitle>systemd.unit
</refentrytitle><manvolnum>5</manvolnum></citerefentry>. Note that mount
69 units cannot be templated, nor is possible to add multiple names to a mount unit by creating additional symlinks to
72 <para>Optionally, a mount unit may be accompanied by an automount
73 unit, to allow on-demand or parallelized mounting. See
74 <citerefentry><refentrytitle>systemd.automount
</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
</para>
76 <para>Mount points created at runtime (independently of unit files
77 or
<filename>/etc/fstab
</filename>) will be monitored by systemd
78 and appear like any other mount unit in systemd. See
79 <filename>/proc/self/mountinfo
</filename> description in
80 <citerefentry project='man-pages'
><refentrytitle>proc
</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
83 <para>Some file systems have special semantics as API file systems
84 for kernel-to-userspace and userspace-to-userspace interfaces. Some
85 of them may not be changed via mount units, and cannot be
86 disabled. For a longer discussion see
<ulink
87 url=
"https://www.freedesktop.org/wiki/Software/systemd/APIFileSystems">API
88 File Systems
</ulink>.
</para>
92 <title>Automatic Dependencies
</title>
95 <title>Implicit Dependencies
</title>
97 <para>The following dependencies are implicitly added:
</para>
100 <listitem><para>If a mount unit is beneath another mount unit in the file
101 system hierarchy, both a requirement dependency and an ordering
102 dependency between both units are created automatically.
</para></listitem>
104 <listitem><para>Block device backed file systems automatically gain
105 <varname>BindsTo=
</varname> and
<varname>After=
</varname> type
106 dependencies on the device unit encapsulating the block
107 device (see below).
</para></listitem>
109 <listitem><para>If traditional file system quota is enabled for a mount
110 unit, automatic
<varname>Wants=
</varname> and
111 <varname>Before=
</varname> dependencies on
112 <filename>systemd-quotacheck.service
</filename> and
113 <filename>quotaon.service
</filename> are added.
</para></listitem>
115 <listitem><para>Additional implicit dependencies may be added as result of
116 execution and resource control parameters as documented in
117 <citerefentry><refentrytitle>systemd.exec
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
119 <citerefentry><refentrytitle>systemd.resource-control
</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
125 <title>Default Dependencies
</title>
127 <para>The following dependencies are added unless
<varname>DefaultDependencies=no
</varname> is set:
</para>
130 <listitem><para>All mount units acquire automatic
<varname>Before=
</varname> and
<varname>Conflicts=
</varname> on
131 <filename>umount.target
</filename> in order to be stopped during shutdown.
</para></listitem>
133 <listitem><para>Mount units referring to local file systems automatically gain
134 an
<varname>After=
</varname> dependency on
<filename>local-fs-pre.target
</filename>.
</para></listitem>
136 <listitem><para>Network mount units
137 automatically acquire
<varname>After=
</varname> dependencies on
<filename>remote-fs-pre.target
</filename>,
138 <filename>network.target
</filename> and
<filename>network-online.target
</filename>. Towards the latter a
139 <varname>Wants=
</varname> unit is added as well.
</para></listitem>
142 <para>Mount units referring to local and network file systems are distinguished by their file system type
143 specification. In some cases this is not sufficient (for example network block device based mounts, such as
144 iSCSI), in which case
<option>_netdev
</option> may be added to the mount option string of the unit, which forces
145 systemd to consider the mount unit a network mount.
</para>
150 <title><filename>fstab
</filename></title>
152 <para>Mount units may either be configured via unit files, or via
153 <filename>/etc/fstab
</filename> (see
154 <citerefentry project='man-pages'
><refentrytitle>fstab
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
155 for details). Mounts listed in
<filename>/etc/fstab
</filename>
156 will be converted into native units dynamically at boot and when
157 the configuration of the system manager is reloaded. In general,
158 configuring mount points through
<filename>/etc/fstab
</filename>
159 is the preferred approach. See
160 <citerefentry><refentrytitle>systemd-fstab-generator
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
161 for details about the conversion.
</para>
163 <para>The NFS mount option
<option>bg
</option> for NFS background mounts
164 as documented in
<citerefentry project='man-pages'
><refentrytitle>nfs
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
165 is detected by
<command>systemd-fstab-generator
</command> and the options
166 are transformed so that systemd fulfills the job-control implications of
167 that option. Specifically
<command>systemd-fstab-generator
</command> acts
168 as though
<literal>x-systemd.mount-timout=infinity,retry=
10000</literal> was
169 prepended to the option list, and
<literal>fg,nofail
</literal> was appended.
170 Depending on specific requirements, it may be appropriate to provide some of
171 these options explicitly, or to make use of the
172 <literal>x-systemd.automount
</literal> option described below instead
173 of using
<literal>bg
</literal>.
</para>
175 <para>When reading
<filename>/etc/fstab
</filename> a few special
176 mount options are understood by systemd which influence how
177 dependencies are created for mount points. systemd will create a
178 dependency of type
<varname>Wants=
</varname> or
179 <option>Requires
</option> (see option
<option>nofail
</option>
180 below), from either
<filename>local-fs.target
</filename> or
181 <filename>remote-fs.target
</filename>, depending whether the file
182 system is local or remote.
</para>
184 <variablelist class='fstab-options'
>
187 <term><option>x-systemd.requires=
</option></term>
189 <listitem><para>Configures a
<varname>Requires=
</varname> and
190 an
<varname>After=
</varname> dependency between the created
191 mount unit and another systemd unit, such as a device or mount
192 unit. The argument should be a unit name, or an absolute path
193 to a device node or mount point. This option may be specified
194 more than once. This option is particularly useful for mount
195 point declarations that need an additional device to be around
196 (such as an external journal device for journal file systems)
197 or an additional mount to be in place (such as an overlay file
198 system that merges multiple mount points). See
199 <varname>After=
</varname> and
<varname>Requires=
</varname> in
200 <citerefentry><refentrytitle>systemd.unit
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
201 for details.
</para></listitem>
205 <term><option>x-systemd.before=
</option></term>
206 <term><option>x-systemd.after=
</option></term>
208 <listitem><para>Configures a
<varname>Before=
</varname>
209 dependency or
<varname>After=
</varname> between the created
210 mount unit and another systemd unit, such as a mount unit.
211 The argument should be a unit name or an absolute path
212 to a mount point. This option may be specified more than once.
213 This option is particularly useful for mount point declarations
214 with
<option>nofail
</option> option that are mounted
215 asynchronously but need to be mounted before or after some unit
216 start, for example, before
<filename>local-fs.target
</filename>
218 See
<varname>Before=
</varname> and
<varname>After=
</varname> in
219 <citerefentry><refentrytitle>systemd.unit
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
220 for details.
</para></listitem>
224 <term><option>x-systemd.requires-mounts-for=
</option></term>
226 <listitem><para>Configures a
227 <varname>RequiresMountsFor=
</varname> dependency between the
228 created mount unit and other mount units. The argument must be
229 an absolute path. This option may be specified more than once.
230 See
<varname>RequiresMountsFor=
</varname> in
231 <citerefentry><refentrytitle>systemd.unit
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
232 for details.
</para></listitem>
236 <term><option>x-systemd.device-bound
</option></term>
238 <listitem><para>The block device backed file system will be upgraded
239 to
<varname>BindsTo=
</varname> dependency. This option is only useful
240 when mounting file systems manually with
241 <citerefentry project='man-pages'
><refentrytitle>mount
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
242 as the default dependency in this case is
<varname>Requires=
</varname>.
243 This option is already implied by entries in
<filename>/etc/fstab
</filename>
249 <term><option>x-systemd.automount
</option></term>
251 <listitem><para>An automount unit will be created for the file
253 <citerefentry><refentrytitle>systemd.automount
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
254 for details.
</para></listitem>
258 <term><option>x-systemd.idle-timeout=
</option></term>
260 <listitem><para>Configures the idle timeout of the
261 automount unit. See
<varname>TimeoutIdleSec=
</varname> in
262 <citerefentry><refentrytitle>systemd.automount
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
263 for details.
</para></listitem>
267 <term><option>x-systemd.device-timeout=
</option></term>
269 <listitem><para>Configure how long systemd should wait for a
270 device to show up before giving up on an entry from
271 <filename>/etc/fstab
</filename>. Specify a time in seconds or
272 explicitly append a unit such as
<literal>s
</literal>,
273 <literal>min
</literal>,
<literal>h
</literal>,
274 <literal>ms
</literal>.
</para>
276 <para>Note that this option can only be used in
277 <filename>/etc/fstab
</filename>, and will be
278 ignored when part of the
<varname>Options=
</varname>
279 setting in a unit file.
</para>
284 <term><option>x-systemd.mount-timeout=
</option></term>
286 <listitem><para>Configure how long systemd should wait for the
287 mount command to finish before giving up on an entry from
288 <filename>/etc/fstab
</filename>. Specify a time in seconds or
289 explicitly append a unit such as
<literal>s
</literal>,
290 <literal>min
</literal>,
<literal>h
</literal>,
291 <literal>ms
</literal>.
</para>
293 <para>Note that this option can only be used in
294 <filename>/etc/fstab
</filename>, and will be
295 ignored when part of the
<varname>Options=
</varname>
296 setting in a unit file.
</para>
298 <para>See
<varname>TimeoutSec=
</varname> below for
304 <term><option>x-systemd.makefs
</option></term>
306 <listitem><para>The file system or swap structure will be initialized
307 on the device. If the device is not
"empty", i.e. it contains any signature,
308 the operation will be skipped. It is hence expected that this option
309 remains set even after the device has been initalized.
</para>
311 <para>Note that this option can only be used in
312 <filename>/etc/fstab
</filename>, and will be ignored when part of the
313 <varname>Options=
</varname> setting in a unit file.
</para>
316 <citerefentry><refentrytitle>systemd-makefs@.service
</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
319 <para><citerefentry project='man-pages'
><refentrytitle>wipefs
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
320 may be used to remove any signatures from a block device to force
321 <option>x-systemd.makefs
</option> to reinitialize the device.
</para>
326 <term><option>x-systemd.growfs
</option></term>
328 <listitem><para>The file system will be grown to occupy the full block
329 device. If the file system is already at maximum size, no action will
330 be performed. It is hence expected that this option remains set even after
331 the file system has been grown. Only certain file system types are supported,
333 <citerefentry><refentrytitle>systemd-makefs@.service
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
336 <para>Note that this option can only be used in
337 <filename>/etc/fstab
</filename>, and will be ignored when part of the
338 <varname>Options=
</varname> setting in a unit file.
</para></listitem>
342 <term><option>_netdev
</option></term>
344 <listitem><para>Normally the file system type is used to determine if a
345 mount is a
"network mount", i.e. if it should only be started after the
346 network is available. Using this option overrides this detection and
347 specifies that the mount requires network.
</para>
349 <para>Network mount units are ordered between
<filename>remote-fs-pre.target
</filename>
350 and
<filename>remote-fs.target
</filename>, instead of
351 <filename>local-fs-pre.target
</filename> and
<filename>local-fs.target
</filename>.
352 They also pull in
<filename>network-online.target
</filename> and are ordered after
353 it and
<filename>network.target
</filename>.
</para>
358 <term><option>noauto
</option></term>
359 <term><option>auto
</option></term>
361 <listitem><para>With
<option>noauto
</option>, the mount unit will not be added as a dependency for
362 <filename>local-fs.target
</filename> or
<filename>remote-fs.target
</filename>. This means that it will not be
363 mounted automatically during boot, unless it is pulled in by some other unit. The
<option>auto
</option> option
364 has the opposite meaning and is the default. Note that the
<option>noauto
</option> option has an effect on the
365 mount unit itself only — if
<option>x-systemd.automount
</option> is used (see above), then the matching
366 automount unit will still be pulled in by these targets.
</para>
371 <term><option>nofail
</option></term>
373 <listitem><para>With
<option>nofail
</option>, this mount will be only wanted, not required, by
374 <filename>local-fs.target
</filename> or
<filename>remote-fs.target
</filename>. Moreover the mount unit is not
375 ordered before these target units. This means that the boot will continue without waiting for the mount unit
376 and regardless whether the mount point can be mounted successfully.
</para>
381 <term><option>x-initrd.mount
</option></term>
383 <listitem><para>An additional filesystem to be mounted in the
384 initramfs. See
<filename>initrd-fs.target
</filename>
386 <citerefentry><refentrytitle>systemd.special
</refentrytitle><manvolnum>7</manvolnum></citerefentry>.
391 <para>If a mount point is configured in both
392 <filename>/etc/fstab
</filename> and a unit file that is stored
393 below
<filename>/usr
</filename>, the former will take precedence.
394 If the unit file is stored below
<filename>/etc
</filename>, it
395 will take precedence. This means: native unit files take
396 precedence over traditional configuration files, but this is
397 superseded by the rule that configuration in
398 <filename>/etc
</filename> will always take precedence over
399 configuration in
<filename>/usr
</filename>.
</para>
403 <title>Options
</title>
405 <para>Mount files must include a [Mount] section, which carries
406 information about the file system mount points it supervises. A
407 number of options that may be used in this section are shared with
408 other unit types. These options are documented in
409 <citerefentry><refentrytitle>systemd.exec
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
411 <citerefentry><refentrytitle>systemd.kill
</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
412 The options specific to the [Mount] section of mount units are the
415 <variablelist class='unit-directives'
>
418 <term><varname>What=
</varname></term>
419 <listitem><para>Takes an absolute path of a device node, file or other resource to mount. See
<citerefentry
420 project='man-pages'
><refentrytitle>mount
</refentrytitle><manvolnum>8</manvolnum></citerefentry> for details. If
421 this refers to a device node, a dependency on the respective device unit is automatically created. (See
422 <citerefentry><refentrytitle>systemd.device
</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more
423 information.) This option is mandatory. Note that the usual specifier expansion is applied to this setting,
424 literal percent characters should hence be written as
<literal>%%
</literal>.
</para></listitem>
428 <term><varname>Where=
</varname></term>
429 <listitem><para>Takes an absolute path of a directory for the
430 mount point; in particular, the destination cannot be a symbolic
431 link. If the mount point does not exist at the time of
432 mounting, it is created. This string must be reflected in the
433 unit filename. (See above.) This option is
434 mandatory.
</para></listitem>
438 <term><varname>Type=
</varname></term>
439 <listitem><para>Takes a string for the file system type. See
440 <citerefentry project='man-pages'
><refentrytitle>mount
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
441 for details. This setting is optional.
</para></listitem>
445 <term><varname>Options=
</varname></term>
447 <listitem><para>Mount options to use when mounting. This takes a comma-separated list of options. This setting
448 is optional. Note that the usual specifier expansion is applied to this setting, literal percent characters
449 should hence be written as
<literal>%%
</literal>.
</para></listitem>
453 <term><varname>SloppyOptions=
</varname></term>
455 <listitem><para>Takes a boolean argument. If true, parsing of
456 the options specified in
<varname>Options=
</varname> is
457 relaxed, and unknown mount options are tolerated. This
459 <citerefentry project='man-pages'
><refentrytitle>mount
</refentrytitle><manvolnum>8</manvolnum></citerefentry>'s
460 <parameter>-s
</parameter> switch. Defaults to
461 off.
</para></listitem>
465 <term><varname>LazyUnmount=
</varname></term>
467 <listitem><para>Takes a boolean argument. If true, detach the
468 filesystem from the filesystem hierarchy at time of the unmount
469 operation, and clean up all references to the filesystem as
470 soon as they are not busy anymore.
471 This corresponds with
472 <citerefentry project='man-pages'
><refentrytitle>umount
</refentrytitle><manvolnum>8</manvolnum></citerefentry>'s
473 <parameter>-l
</parameter> switch. Defaults to
474 off.
</para></listitem>
478 <term><varname>ForceUnmount=
</varname></term>
480 <listitem><para>Takes a boolean argument. If true, force an
481 unmount (in case of an unreachable NFS system).
482 This corresponds with
483 <citerefentry project='man-pages'
><refentrytitle>umount
</refentrytitle><manvolnum>8</manvolnum></citerefentry>'s
484 <parameter>-f
</parameter> switch. Defaults to
485 off.
</para></listitem>
489 <term><varname>DirectoryMode=
</varname></term>
490 <listitem><para>Directories of mount points (and any parent
491 directories) are automatically created if needed. This option
492 specifies the file system access mode used when creating these
493 directories. Takes an access mode in octal notation. Defaults
494 to
0755.
</para></listitem>
498 <term><varname>TimeoutSec=
</varname></term>
499 <listitem><para>Configures the time to wait for the mount
500 command to finish. If a command does not exit within the
501 configured time, the mount will be considered failed and be
502 shut down again. All commands still running will be terminated
503 forcibly via
<constant>SIGTERM
</constant>, and after another
504 delay of this time with
<constant>SIGKILL
</constant>. (See
505 <option>KillMode=
</option> in
506 <citerefentry><refentrytitle>systemd.kill
</refentrytitle><manvolnum>5</manvolnum></citerefentry>.)
507 Takes a unit-less value in seconds, or a time span value such
508 as
"5min 20s". Pass
0 to disable the timeout logic. The
509 default value is set from the manager configuration file's
510 <varname>DefaultTimeoutStartSec=
</varname>
511 variable.
</para></listitem>
516 <citerefentry><refentrytitle>systemd.exec
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
518 <citerefentry><refentrytitle>systemd.kill
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
519 for more settings.
</para>
523 <title>See Also
</title>
525 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
526 <citerefentry><refentrytitle>systemctl
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
527 <citerefentry><refentrytitle>systemd.unit
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
528 <citerefentry><refentrytitle>systemd.exec
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
529 <citerefentry><refentrytitle>systemd.kill
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
530 <citerefentry><refentrytitle>systemd.resource-control
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
531 <citerefentry><refentrytitle>systemd.service
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
532 <citerefentry><refentrytitle>systemd.device
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
533 <citerefentry project='man-pages'
><refentrytitle>proc
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
534 <citerefentry project='man-pages'
><refentrytitle>mount
</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
535 <citerefentry><refentrytitle>systemd-fstab-generator
</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
536 <citerefentry><refentrytitle>systemd.directives
</refentrytitle><manvolnum>7</manvolnum></citerefentry>