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+
8 Copyright 2010 Lennart Poettering
11 <refentry id=
"systemd.mount">
13 <title>systemd.mount
</title>
14 <productname>systemd
</productname>
18 <contrib>Developer
</contrib>
19 <firstname>Lennart
</firstname>
20 <surname>Poettering
</surname>
21 <email>lennart@poettering.net
</email>
27 <refentrytitle>systemd.mount
</refentrytitle>
28 <manvolnum>5</manvolnum>
32 <refname>systemd.mount
</refname>
33 <refpurpose>Mount unit configuration
</refpurpose>
37 <para><filename><replaceable>mount
</replaceable>.mount
</filename></para>
41 <title>Description
</title>
43 <para>A unit configuration file whose name ends in
44 <literal>.mount
</literal> encodes information about a file system
45 mount point controlled and supervised by systemd.
</para>
47 <para>This man page lists the configuration options specific to
49 <citerefentry><refentrytitle>systemd.unit
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
50 for the common options of all unit configuration files. The common
51 configuration items are configured in the generic [Unit] and
52 [Install] sections. The mount specific configuration options are
53 configured in the [Mount] section.
</para>
55 <para>Additional options are listed in
56 <citerefentry><refentrytitle>systemd.exec
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
57 which define the execution environment the
58 <citerefentry project='man-pages'
><refentrytitle>mount
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
59 program is executed in, and in
60 <citerefentry><refentrytitle>systemd.kill
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
61 which define the way the processes are terminated, and in
62 <citerefentry><refentrytitle>systemd.resource-control
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
63 which configure resource control settings for the processes of the
66 <para>Note that the options
<varname>User=
</varname> and
67 <varname>Group=
</varname> are not useful for mount units.
68 systemd passes two parameters to
69 <citerefentry project='man-pages'
><refentrytitle>mount
</refentrytitle><manvolnum>8</manvolnum></citerefentry>;
70 the values of
<varname>What=
</varname> and
<varname>Where=
</varname>.
71 When invoked in this way,
72 <citerefentry project='man-pages'
><refentrytitle>mount
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
73 does not read any options from
<filename>/etc/fstab
</filename>, and
74 must be run as UID
0.
</para>
76 <para>Mount units must be named after the mount point directories they control. Example: the mount point
<filename
77 noindex='true'
>/home/lennart
</filename> must be configured in a unit file
<filename>home-lennart.mount
</filename>.
78 For details about the escaping logic used to convert a file system path to a unit name, see
79 <citerefentry><refentrytitle>systemd.unit
</refentrytitle><manvolnum>5</manvolnum></citerefentry>. Note that mount
80 units cannot be templated, nor is possible to add multiple names to a mount unit by creating additional symlinks to
83 <para>Optionally, a mount unit may be accompanied by an automount
84 unit, to allow on-demand or parallelized mounting. See
85 <citerefentry><refentrytitle>systemd.automount
</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
</para>
87 <para>Mount points created at runtime (independently of unit files
88 or
<filename>/etc/fstab
</filename>) will be monitored by systemd
89 and appear like any other mount unit in systemd. See
90 <filename>/proc/self/mountinfo
</filename> description in
91 <citerefentry project='man-pages'
><refentrytitle>proc
</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
94 <para>Some file systems have special semantics as API file systems
95 for kernel-to-userspace and userspace-to-userspace interfaces. Some
96 of them may not be changed via mount units, and cannot be
97 disabled. For a longer discussion see
<ulink
98 url=
"https://www.freedesktop.org/wiki/Software/systemd/APIFileSystems">API
99 File Systems
</ulink>.
</para>
103 <title>Automatic Dependencies
</title>
106 <title>Implicit Dependencies
</title>
108 <para>The following dependencies are implicitly added:
</para>
111 <listitem><para>If a mount unit is beneath another mount unit in the file
112 system hierarchy, both a requirement dependency and an ordering
113 dependency between both units are created automatically.
</para></listitem>
115 <listitem><para>Block device backed file systems automatically gain
116 <varname>BindsTo=
</varname> and
<varname>After=
</varname> type
117 dependencies on the device unit encapsulating the block
118 device (see below).
</para></listitem>
120 <listitem><para>If traditional file system quota is enabled for a mount
121 unit, automatic
<varname>Wants=
</varname> and
122 <varname>Before=
</varname> dependencies on
123 <filename>systemd-quotacheck.service
</filename> and
124 <filename>quotaon.service
</filename> are added.
</para></listitem>
126 <listitem><para>Additional implicit dependencies may be added as result of
127 execution and resource control parameters as documented in
128 <citerefentry><refentrytitle>systemd.exec
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
130 <citerefentry><refentrytitle>systemd.resource-control
</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
136 <title>Default Dependencies
</title>
138 <para>The following dependencies are added unless
<varname>DefaultDependencies=no
</varname> is set:
</para>
141 <listitem><para>All mount units acquire automatic
<varname>Before=
</varname> and
<varname>Conflicts=
</varname> on
142 <filename>umount.target
</filename> in order to be stopped during shutdown.
</para></listitem>
144 <listitem><para>Mount units referring to local file systems automatically gain
145 an
<varname>After=
</varname> dependency on
<filename>local-fs-pre.target
</filename>.
</para></listitem>
147 <listitem><para>Network mount units
148 automatically acquire
<varname>After=
</varname> dependencies on
<filename>remote-fs-pre.target
</filename>,
149 <filename>network.target
</filename> and
<filename>network-online.target
</filename>. Towards the latter a
150 <varname>Wants=
</varname> unit is added as well.
</para></listitem>
153 <para>Mount units referring to local and network file systems are distinguished by their file system type
154 specification. In some cases this is not sufficient (for example network block device based mounts, such as
155 iSCSI), in which case
<option>_netdev
</option> may be added to the mount option string of the unit, which forces
156 systemd to consider the mount unit a network mount.
</para>
161 <title><filename>fstab
</filename></title>
163 <para>Mount units may either be configured via unit files, or via
164 <filename>/etc/fstab
</filename> (see
165 <citerefentry project='man-pages'
><refentrytitle>fstab
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
166 for details). Mounts listed in
<filename>/etc/fstab
</filename>
167 will be converted into native units dynamically at boot and when
168 the configuration of the system manager is reloaded. In general,
169 configuring mount points through
<filename>/etc/fstab
</filename>
170 is the preferred approach. See
171 <citerefentry><refentrytitle>systemd-fstab-generator
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
172 for details about the conversion.
</para>
174 <para>The NFS mount option
<option>bg
</option> for NFS background mounts
175 as documented in
<citerefentry project='man-pages'
><refentrytitle>nfs
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
176 is detected by
<command>systemd-fstab-generator
</command> and the options
177 are transformed so that systemd fulfills the job-control implications of
178 that option. Specifically
<command>systemd-fstab-generator
</command> acts
179 as though
<literal>x-systemd.mount-timout=infinity,retry=
10000</literal> was
180 prepended to the option list, and
<literal>fg,nofail
</literal> was appended.
181 Depending on specific requirements, it may be appropriate to provide some of
182 these options explicitly, or to make use of the
183 <literal>x-systemd.automount
</literal> option described below instead
184 of using
<literal>bg
</literal>.
</para>
186 <para>When reading
<filename>/etc/fstab
</filename> a few special
187 mount options are understood by systemd which influence how
188 dependencies are created for mount points. systemd will create a
189 dependency of type
<varname>Wants=
</varname> or
190 <option>Requires
</option> (see option
<option>nofail
</option>
191 below), from either
<filename>local-fs.target
</filename> or
192 <filename>remote-fs.target
</filename>, depending whether the file
193 system is local or remote.
</para>
195 <variablelist class='fstab-options'
>
198 <term><option>x-systemd.requires=
</option></term>
200 <listitem><para>Configures a
<varname>Requires=
</varname> and
201 an
<varname>After=
</varname> dependency between the created
202 mount unit and another systemd unit, such as a device or mount
203 unit. The argument should be a unit name, or an absolute path
204 to a device node or mount point. This option may be specified
205 more than once. This option is particularly useful for mount
206 point declarations that need an additional device to be around
207 (such as an external journal device for journal file systems)
208 or an additional mount to be in place (such as an overlay file
209 system that merges multiple mount points). See
210 <varname>After=
</varname> and
<varname>Requires=
</varname> in
211 <citerefentry><refentrytitle>systemd.unit
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
212 for details.
</para></listitem>
216 <term><option>x-systemd.before=
</option></term>
217 <term><option>x-systemd.after=
</option></term>
219 <listitem><para>Configures a
<varname>Before=
</varname>
220 dependency or
<varname>After=
</varname> between the created
221 mount unit and another systemd unit, such as a mount unit.
222 The argument should be a unit name or an absolute path
223 to a mount point. This option may be specified more than once.
224 This option is particularly useful for mount point declarations
225 with
<option>nofail
</option> option that are mounted
226 asynchronously but need to be mounted before or after some unit
227 start, for example, before
<filename>local-fs.target
</filename>
229 See
<varname>Before=
</varname> and
<varname>After=
</varname> in
230 <citerefentry><refentrytitle>systemd.unit
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
231 for details.
</para></listitem>
235 <term><option>x-systemd.requires-mounts-for=
</option></term>
237 <listitem><para>Configures a
238 <varname>RequiresMountsFor=
</varname> dependency between the
239 created mount unit and other mount units. The argument must be
240 an absolute path. This option may be specified more than once.
241 See
<varname>RequiresMountsFor=
</varname> in
242 <citerefentry><refentrytitle>systemd.unit
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
243 for details.
</para></listitem>
247 <term><option>x-systemd.device-bound
</option></term>
249 <listitem><para>The block device backed file system will be upgraded
250 to
<varname>BindsTo=
</varname> dependency. This option is only useful
251 when mounting file systems manually with
252 <citerefentry project='man-pages'
><refentrytitle>mount
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
253 as the default dependency in this case is
<varname>Requires=
</varname>.
254 This option is already implied by entries in
<filename>/etc/fstab
</filename>
260 <term><option>x-systemd.automount
</option></term>
262 <listitem><para>An automount unit will be created for the file
264 <citerefentry><refentrytitle>systemd.automount
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
265 for details.
</para></listitem>
269 <term><option>x-systemd.idle-timeout=
</option></term>
271 <listitem><para>Configures the idle timeout of the
272 automount unit. See
<varname>TimeoutIdleSec=
</varname> in
273 <citerefentry><refentrytitle>systemd.automount
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
274 for details.
</para></listitem>
278 <term><option>x-systemd.device-timeout=
</option></term>
280 <listitem><para>Configure how long systemd should wait for a
281 device to show up before giving up on an entry from
282 <filename>/etc/fstab
</filename>. Specify a time in seconds or
283 explicitly append a unit such as
<literal>s
</literal>,
284 <literal>min
</literal>,
<literal>h
</literal>,
285 <literal>ms
</literal>.
</para>
287 <para>Note that this option can only be used in
288 <filename>/etc/fstab
</filename>, and will be
289 ignored when part of the
<varname>Options=
</varname>
290 setting in a unit file.
</para>
295 <term><option>x-systemd.mount-timeout=
</option></term>
297 <listitem><para>Configure how long systemd should wait for the
298 mount command to finish before giving up on an entry from
299 <filename>/etc/fstab
</filename>. Specify a time in seconds or
300 explicitly append a unit such as
<literal>s
</literal>,
301 <literal>min
</literal>,
<literal>h
</literal>,
302 <literal>ms
</literal>.
</para>
304 <para>Note that this option can only be used in
305 <filename>/etc/fstab
</filename>, and will be
306 ignored when part of the
<varname>Options=
</varname>
307 setting in a unit file.
</para>
309 <para>See
<varname>TimeoutSec=
</varname> below for
315 <term><option>x-systemd.makefs
</option></term>
317 <listitem><para>The file system or swap structure will be initialized
318 on the device. If the device is not
"empty", i.e. it contains any signature,
319 the operation will be skipped. It is hence expected that this option
320 remains set even after the device has been initalized.
</para>
322 <para>Note that this option can only be used in
323 <filename>/etc/fstab
</filename>, and will be ignored when part of the
324 <varname>Options=
</varname> setting in a unit file.
</para>
327 <citerefentry><refentrytitle>systemd-makefs@.service
</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
330 <para><citerefentry project='man-pages'
><refentrytitle>wipefs
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
331 may be used to remove any signatures from a block device to force
332 <option>x-systemd.makefs
</option> to reinitialize the device.
</para>
337 <term><option>x-systemd.growfs
</option></term>
339 <listitem><para>The file system will be grown to occupy the full block
340 device. If the file system is already at maximum size, no action will
341 be performed. It is hence expected that this option remains set even after
342 the file system has been grown. Only certain file system types are supported,
344 <citerefentry><refentrytitle>systemd-makefs@.service
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
347 <para>Note that this option can only be used in
348 <filename>/etc/fstab
</filename>, and will be ignored when part of the
349 <varname>Options=
</varname> setting in a unit file.
</para></listitem>
353 <term><option>_netdev
</option></term>
355 <listitem><para>Normally the file system type is used to determine if a
356 mount is a
"network mount", i.e. if it should only be started after the
357 network is available. Using this option overrides this detection and
358 specifies that the mount requires network.
</para>
360 <para>Network mount units are ordered between
<filename>remote-fs-pre.target
</filename>
361 and
<filename>remote-fs.target
</filename>, instead of
362 <filename>local-fs-pre.target
</filename> and
<filename>local-fs.target
</filename>.
363 They also pull in
<filename>network-online.target
</filename> and are ordered after
364 it and
<filename>network.target
</filename>.
</para>
369 <term><option>noauto
</option></term>
370 <term><option>auto
</option></term>
372 <listitem><para>With
<option>noauto
</option>, the mount unit will not be added as a dependency for
373 <filename>local-fs.target
</filename> or
<filename>remote-fs.target
</filename>. This means that it will not be
374 mounted automatically during boot, unless it is pulled in by some other unit. The
<option>auto
</option> option
375 has the opposite meaning and is the default. Note that the
<option>noauto
</option> option has an effect on the
376 mount unit itself only — if
<option>x-systemd.automount
</option> is used (see above), then the matching
377 automount unit will still be pulled in by these targets.
</para>
382 <term><option>nofail
</option></term>
384 <listitem><para>With
<option>nofail
</option>, this mount will
385 be only wanted, not required, by
386 <filename>local-fs.target
</filename> or
387 <filename>remote-fs.target
</filename>. This means that the
388 boot will continue even if this mount point is not mounted
394 <term><option>x-initrd.mount
</option></term>
396 <listitem><para>An additional filesystem to be mounted in the
397 initramfs. See
<filename>initrd-fs.target
</filename>
399 <citerefentry><refentrytitle>systemd.special
</refentrytitle><manvolnum>7</manvolnum></citerefentry>.
404 <para>If a mount point is configured in both
405 <filename>/etc/fstab
</filename> and a unit file that is stored
406 below
<filename>/usr
</filename>, the former will take precedence.
407 If the unit file is stored below
<filename>/etc
</filename>, it
408 will take precedence. This means: native unit files take
409 precedence over traditional configuration files, but this is
410 superseded by the rule that configuration in
411 <filename>/etc
</filename> will always take precedence over
412 configuration in
<filename>/usr
</filename>.
</para>
416 <title>Options
</title>
418 <para>Mount files must include a [Mount] section, which carries
419 information about the file system mount points it supervises. A
420 number of options that may be used in this section are shared with
421 other unit types. These options are documented in
422 <citerefentry><refentrytitle>systemd.exec
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
424 <citerefentry><refentrytitle>systemd.kill
</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
425 The options specific to the [Mount] section of mount units are the
428 <variablelist class='unit-directives'
>
431 <term><varname>What=
</varname></term>
432 <listitem><para>Takes an absolute path of a device node, file or other resource to mount. See
<citerefentry
433 project='man-pages'
><refentrytitle>mount
</refentrytitle><manvolnum>8</manvolnum></citerefentry> for details. If
434 this refers to a device node, a dependency on the respective device unit is automatically created. (See
435 <citerefentry><refentrytitle>systemd.device
</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more
436 information.) This option is mandatory. Note that the usual specifier expansion is applied to this setting,
437 literal percent characters should hence be written as
<literal>%%
</literal>.
</para></listitem>
441 <term><varname>Where=
</varname></term>
442 <listitem><para>Takes an absolute path of a directory for the
443 mount point; in particular, the destination cannot be a symbolic
444 link. If the mount point does not exist at the time of
445 mounting, it is created. This string must be reflected in the
446 unit filename. (See above.) This option is
447 mandatory.
</para></listitem>
451 <term><varname>Type=
</varname></term>
452 <listitem><para>Takes a string for the file system type. See
453 <citerefentry project='man-pages'
><refentrytitle>mount
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
454 for details. This setting is optional.
</para></listitem>
458 <term><varname>Options=
</varname></term>
460 <listitem><para>Mount options to use when mounting. This takes a comma-separated list of options. This setting
461 is optional. Note that the usual specifier expansion is applied to this setting, literal percent characters
462 should hence be written as
<literal>%%
</literal>.
</para></listitem>
466 <term><varname>SloppyOptions=
</varname></term>
468 <listitem><para>Takes a boolean argument. If true, parsing of
469 the options specified in
<varname>Options=
</varname> is
470 relaxed, and unknown mount options are tolerated. This
472 <citerefentry project='man-pages'
><refentrytitle>mount
</refentrytitle><manvolnum>8</manvolnum></citerefentry>'s
473 <parameter>-s
</parameter> switch. Defaults to
474 off.
</para></listitem>
478 <term><varname>LazyUnmount=
</varname></term>
480 <listitem><para>Takes a boolean argument. If true, detach the
481 filesystem from the filesystem hierarchy at time of the unmount
482 operation, and clean up all references to the filesystem as
483 soon as they are not busy anymore.
484 This corresponds with
485 <citerefentry project='man-pages'
><refentrytitle>umount
</refentrytitle><manvolnum>8</manvolnum></citerefentry>'s
486 <parameter>-l
</parameter> switch. Defaults to
487 off.
</para></listitem>
491 <term><varname>ForceUnmount=
</varname></term>
493 <listitem><para>Takes a boolean argument. If true, force an
494 unmount (in case of an unreachable NFS system).
495 This corresponds with
496 <citerefentry project='man-pages'
><refentrytitle>umount
</refentrytitle><manvolnum>8</manvolnum></citerefentry>'s
497 <parameter>-f
</parameter> switch. Defaults to
498 off.
</para></listitem>
502 <term><varname>DirectoryMode=
</varname></term>
503 <listitem><para>Directories of mount points (and any parent
504 directories) are automatically created if needed. This option
505 specifies the file system access mode used when creating these
506 directories. Takes an access mode in octal notation. Defaults
507 to
0755.
</para></listitem>
511 <term><varname>TimeoutSec=
</varname></term>
512 <listitem><para>Configures the time to wait for the mount
513 command to finish. If a command does not exit within the
514 configured time, the mount will be considered failed and be
515 shut down again. All commands still running will be terminated
516 forcibly via
<constant>SIGTERM
</constant>, and after another
517 delay of this time with
<constant>SIGKILL
</constant>. (See
518 <option>KillMode=
</option> in
519 <citerefentry><refentrytitle>systemd.kill
</refentrytitle><manvolnum>5</manvolnum></citerefentry>.)
520 Takes a unit-less value in seconds, or a time span value such
521 as
"5min 20s". Pass
0 to disable the timeout logic. The
522 default value is set from the manager configuration file's
523 <varname>DefaultTimeoutStartSec=
</varname>
524 variable.
</para></listitem>
529 <citerefentry><refentrytitle>systemd.exec
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
531 <citerefentry><refentrytitle>systemd.kill
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
532 for more settings.
</para>
536 <title>See Also
</title>
538 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
539 <citerefentry><refentrytitle>systemctl
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
540 <citerefentry><refentrytitle>systemd.unit
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
541 <citerefentry><refentrytitle>systemd.exec
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
542 <citerefentry><refentrytitle>systemd.kill
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
543 <citerefentry><refentrytitle>systemd.resource-control
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
544 <citerefentry><refentrytitle>systemd.service
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
545 <citerefentry><refentrytitle>systemd.device
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
546 <citerefentry project='man-pages'
><refentrytitle>proc
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
547 <citerefentry project='man-pages'
><refentrytitle>mount
</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
548 <citerefentry><refentrytitle>systemd-fstab-generator
</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
549 <citerefentry><refentrytitle>systemd.directives
</refentrytitle><manvolnum>7</manvolnum></citerefentry>