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 This file is part of systemd.
10 Copyright 2010 Lennart Poettering
13 <refentry id=
"systemd.mount">
15 <title>systemd.mount
</title>
16 <productname>systemd
</productname>
20 <contrib>Developer
</contrib>
21 <firstname>Lennart
</firstname>
22 <surname>Poettering
</surname>
23 <email>lennart@poettering.net
</email>
29 <refentrytitle>systemd.mount
</refentrytitle>
30 <manvolnum>5</manvolnum>
34 <refname>systemd.mount
</refname>
35 <refpurpose>Mount unit configuration
</refpurpose>
39 <para><filename><replaceable>mount
</replaceable>.mount
</filename></para>
43 <title>Description
</title>
45 <para>A unit configuration file whose name ends in
46 <literal>.mount
</literal> encodes information about a file system
47 mount point controlled and supervised by systemd.
</para>
49 <para>This man page lists the configuration options specific to
51 <citerefentry><refentrytitle>systemd.unit
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
52 for the common options of all unit configuration files. The common
53 configuration items are configured in the generic [Unit] and
54 [Install] sections. The mount specific configuration options are
55 configured in the [Mount] section.
</para>
57 <para>Additional options are listed in
58 <citerefentry><refentrytitle>systemd.exec
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
59 which define the execution environment the
60 <citerefentry project='man-pages'
><refentrytitle>mount
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
61 program is executed in, and in
62 <citerefentry><refentrytitle>systemd.kill
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
63 which define the way the processes are terminated, and in
64 <citerefentry><refentrytitle>systemd.resource-control
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
65 which configure resource control settings for the processes of the
68 <para>Note that the options
<varname>User=
</varname> and
69 <varname>Group=
</varname> are not useful for mount units.
70 systemd passes two parameters to
71 <citerefentry project='man-pages'
><refentrytitle>mount
</refentrytitle><manvolnum>8</manvolnum></citerefentry>;
72 the values of
<varname>What=
</varname> and
<varname>Where=
</varname>.
73 When invoked in this way,
74 <citerefentry project='man-pages'
><refentrytitle>mount
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
75 does not read any options from
<filename>/etc/fstab
</filename>, and
76 must be run as UID
0.
</para>
78 <para>Mount units must be named after the mount point directories they control. Example: the mount point
<filename
79 noindex='true'
>/home/lennart
</filename> must be configured in a unit file
<filename>home-lennart.mount
</filename>.
80 For details about the escaping logic used to convert a file system path to a unit name, see
81 <citerefentry><refentrytitle>systemd.unit
</refentrytitle><manvolnum>5</manvolnum></citerefentry>. Note that mount
82 units cannot be templated, nor is possible to add multiple names to a mount unit by creating additional symlinks to
85 <para>Optionally, a mount unit may be accompanied by an automount
86 unit, to allow on-demand or parallelized mounting. See
87 <citerefentry><refentrytitle>systemd.automount
</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
</para>
89 <para>Mount points created at runtime (independently of unit files
90 or
<filename>/etc/fstab
</filename>) will be monitored by systemd
91 and appear like any other mount unit in systemd. See
92 <filename>/proc/self/mountinfo
</filename> description in
93 <citerefentry project='man-pages'
><refentrytitle>proc
</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
96 <para>Some file systems have special semantics as API file systems
97 for kernel-to-userspace and userspace-to-userspace interfaces. Some
98 of them may not be changed via mount units, and cannot be
99 disabled. For a longer discussion see
<ulink
100 url=
"https://www.freedesktop.org/wiki/Software/systemd/APIFileSystems">API
101 File Systems
</ulink>.
</para>
105 <title>Implicit Dependencies
</title>
107 <para>The following dependencies are implicitly added:
</para>
110 <listitem><para>If a mount unit is beneath another mount unit in the file
111 system hierarchy, both a requirement dependency and an ordering
112 dependency between both units are created automatically.
</para></listitem>
114 <listitem><para>Block device backed file systems automatically gain
115 <varname>BindsTo=
</varname> and
<varname>After=
</varname> type
116 dependencies on the device unit encapsulating the block
117 device (see below).
</para></listitem>
119 <listitem><para>If traditional file system quota is enabled for a mount
120 unit, automatic
<varname>Wants=
</varname> and
121 <varname>Before=
</varname> dependencies on
122 <filename>systemd-quotacheck.service
</filename> and
123 <filename>quotaon.service
</filename> are added.
</para></listitem>
125 <listitem><para>Additional implicit dependencies may be added as result of
126 execution and resource control parameters as documented in
127 <citerefentry><refentrytitle>systemd.exec
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
129 <citerefentry><refentrytitle>systemd.resource-control
</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
135 <title>Default Dependencies
</title>
137 <para>The following dependencies are added unless
<varname>DefaultDependencies=no
</varname> is set:
</para>
140 <listitem><para>All mount units acquire automatic
<varname>Before=
</varname> and
<varname>Conflicts=
</varname> on
141 <filename>umount.target
</filename> in order to be stopped during shutdown.
</para></listitem>
143 <listitem><para>Mount units referring to local file systems automatically gain
144 an
<varname>After=
</varname> dependency on
<filename>local-fs-pre.target
</filename>.
</para></listitem>
146 <listitem><para>Network mount units
147 automatically acquire
<varname>After=
</varname> dependencies on
<filename>remote-fs-pre.target
</filename>,
148 <filename>network.target
</filename> and
<filename>network-online.target
</filename>. Towards the latter a
149 <varname>Wants=
</varname> unit is added as well.
</para></listitem>
152 <para>Mount units referring to local and network file systems are
153 distinguished by their file system type specification. In some cases this is not sufficient (for example network
154 block device based mounts, such as iSCSI), in which case
<option>_netdev
</option> may be added to the mount option
155 string of the unit, which forces systemd to consider the mount unit a network mount.
</para>
159 <title><filename>fstab
</filename></title>
161 <para>Mount units may either be configured via unit files, or via
162 <filename>/etc/fstab
</filename> (see
163 <citerefentry project='man-pages'
><refentrytitle>fstab
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
164 for details). Mounts listed in
<filename>/etc/fstab
</filename>
165 will be converted into native units dynamically at boot and when
166 the configuration of the system manager is reloaded. In general,
167 configuring mount points through
<filename>/etc/fstab
</filename>
168 is the preferred approach. See
169 <citerefentry><refentrytitle>systemd-fstab-generator
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
170 for details about the conversion.
</para>
172 <para>The NFS mount option
<option>bg
</option> for NFS background mounts
173 as documented in
<citerefentry project='man-pages'
><refentrytitle>nfs
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
174 is detected by
<command>systemd-fstab-generator
</command> and the options
175 are transformed so that systemd fulfills the job-control implications of
176 that option. Specifically
<command>systemd-fstab-generator
</command> acts
177 as though
<literal>x-systemd.mount-timout=infinity,retry=
10000</literal> was
178 prepended to the option list, and
<literal>fg,nofail
</literal> was appended.
179 Depending on specific requirements, it may be appropriate to provide some of
180 these options explicitly, or to make use of the
181 <literal>x-systemd.automount
</literal> option described below instead
182 of using
<literal>bg
</literal>.
</para>
184 <para>When reading
<filename>/etc/fstab
</filename> a few special
185 mount options are understood by systemd which influence how
186 dependencies are created for mount points. systemd will create a
187 dependency of type
<varname>Wants=
</varname> or
188 <option>Requires
</option> (see option
<option>nofail
</option>
189 below), from either
<filename>local-fs.target
</filename> or
190 <filename>remote-fs.target
</filename>, depending whether the file
191 system is local or remote.
</para>
193 <variablelist class='fstab-options'
>
196 <term><option>x-systemd.requires=
</option></term>
198 <listitem><para>Configures a
<varname>Requires=
</varname> and
199 an
<varname>After=
</varname> dependency between the created
200 mount unit and another systemd unit, such as a device or mount
201 unit. The argument should be a unit name, or an absolute path
202 to a device node or mount point. This option may be specified
203 more than once. This option is particularly useful for mount
204 point declarations that need an additional device to be around
205 (such as an external journal device for journal file systems)
206 or an additional mount to be in place (such as an overlay file
207 system that merges multiple mount points). See
208 <varname>After=
</varname> and
<varname>Requires=
</varname> in
209 <citerefentry><refentrytitle>systemd.unit
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
210 for details.
</para></listitem>
214 <term><option>x-systemd.before=
</option></term>
215 <term><option>x-systemd.after=
</option></term>
217 <listitem><para>Configures a
<varname>Before=
</varname>
218 dependency or
<varname>After=
</varname> between the created
219 mount unit and another systemd unit, such as a mount unit.
220 The argument should be a unit name or an absolute path
221 to a mount point. This option may be specified more than once.
222 This option is particularly useful for mount point declarations
223 with
<option>nofail
</option> option that are mounted
224 asynchronously but need to be mounted before or after some unit
225 start, for example, before
<filename>local-fs.target
</filename>
227 See
<varname>Before=
</varname> and
<varname>After=
</varname> in
228 <citerefentry><refentrytitle>systemd.unit
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
229 for details.
</para></listitem>
233 <term><option>x-systemd.requires-mounts-for=
</option></term>
235 <listitem><para>Configures a
236 <varname>RequiresMountsFor=
</varname> dependency between the
237 created mount unit and other mount units. The argument must be
238 an absolute path. This option may be specified more than once.
239 See
<varname>RequiresMountsFor=
</varname> in
240 <citerefentry><refentrytitle>systemd.unit
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
241 for details.
</para></listitem>
245 <term><option>x-systemd.device-bound
</option></term>
247 <listitem><para>The block device backed file system will be upgraded
248 to
<varname>BindsTo=
</varname> dependency. This option is only useful
249 when mounting file systems manually with
250 <citerefentry project='man-pages'
><refentrytitle>mount
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
251 as the default dependency in this case is
<varname>Requires=
</varname>.
252 This option is already implied by entries in
<filename>/etc/fstab
</filename>
258 <term><option>x-systemd.automount
</option></term>
260 <listitem><para>An automount unit will be created for the file
262 <citerefentry><refentrytitle>systemd.automount
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
263 for details.
</para></listitem>
267 <term><option>x-systemd.idle-timeout=
</option></term>
269 <listitem><para>Configures the idle timeout of the
270 automount unit. See
<varname>TimeoutIdleSec=
</varname> in
271 <citerefentry><refentrytitle>systemd.automount
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
272 for details.
</para></listitem>
276 <term><option>x-systemd.device-timeout=
</option></term>
278 <listitem><para>Configure how long systemd should wait for a
279 device to show up before giving up on an entry from
280 <filename>/etc/fstab
</filename>. Specify a time in seconds or
281 explicitly append a unit such as
<literal>s
</literal>,
282 <literal>min
</literal>,
<literal>h
</literal>,
283 <literal>ms
</literal>.
</para>
285 <para>Note that this option can only be used in
286 <filename>/etc/fstab
</filename>, and will be
287 ignored when part of the
<varname>Options=
</varname>
288 setting in a unit file.
</para>
293 <term><option>x-systemd.mount-timeout=
</option></term>
295 <listitem><para>Configure how long systemd should wait for the
296 mount command to finish before giving up on an entry from
297 <filename>/etc/fstab
</filename>. Specify a time in seconds or
298 explicitly append a unit such as
<literal>s
</literal>,
299 <literal>min
</literal>,
<literal>h
</literal>,
300 <literal>ms
</literal>.
</para>
302 <para>Note that this option can only be used in
303 <filename>/etc/fstab
</filename>, and will be
304 ignored when part of the
<varname>Options=
</varname>
305 setting in a unit file.
</para>
307 <para>See
<varname>TimeoutSec=
</varname> below for
313 <term><option>x-systemd.makefs
</option></term>
315 <listitem><para>The file system or swap structure will be intialized
316 on the device. If the device is not
"empty", i.e. it contains any signature,
317 the operation will be skipped. It is hence expected that this option
318 remains set even after the device has been initalized.
</para>
320 <para>Note that this option can only be used in
321 <filename>/etc/fstab
</filename>, and will be ignored when part of the
322 <varname>Options=
</varname> setting in a unit file.
</para>
325 <citerefentry><refentrytitle>systemd-makefs@.service
</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
328 <para><citerefentry project='man-pages'
><refentrytitle>wipefs
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
329 may be used to remove any signatures from a block device to force
330 <option>x-systemd.makefs
</option> to reinitialize the device.
</para>
335 <term><option>x-systemd.growfs
</option></term>
337 <listitem><para>The file system will be grown to occupy the full block
338 device. If the file system is already at maximum size, no action will
339 be performed. It is hence expected that this option remains set even after
340 the file system has been grown. Only certain file system types are supported,
342 <citerefentry><refentrytitle>systemd-makefs@.service
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
345 <para>Note that this option can only be used in
346 <filename>/etc/fstab
</filename>, and will be ignored when part of the
347 <varname>Options=
</varname> setting in a unit file.
</para></listitem>
351 <term><option>_netdev
</option></term>
353 <listitem><para>Normally the file system type is used to determine if a
354 mount is a
"network mount", i.e. if it should only be started after the
355 network is available. Using this option overrides this detection and
356 specifies that the mount requires network.
</para>
358 <para>Network mount units are ordered between
<filename>remote-fs-pre.target
</filename>
359 and
<filename>remote-fs.target
</filename>, instead of
360 <filename>local-fs-pre.target
</filename> and
<filename>local-fs.target
</filename>.
361 They also pull in
<filename>network-online.target
</filename> and are ordered after
362 it and
<filename>network.target
</filename>.
</para>
367 <term><option>noauto
</option></term>
368 <term><option>auto
</option></term>
370 <listitem><para>With
<option>noauto
</option>, the mount unit will not be added as a dependency for
371 <filename>local-fs.target
</filename> or
<filename>remote-fs.target
</filename>. This means that it will not be
372 mounted automatically during boot, unless it is pulled in by some other unit. The
<option>auto
</option> option
373 has the opposite meaning and is the default. Note that the
<option>noauto
</option> option has an effect on the
374 mount unit itself only — if
<option>x-systemd.automount
</option> is used (see above), then the matching
375 automount unit will still be pulled in by these targets.
</para>
380 <term><option>nofail
</option></term>
382 <listitem><para>With
<option>nofail
</option>, this mount will
383 be only wanted, not required, by
384 <filename>local-fs.target
</filename> or
385 <filename>remote-fs.target
</filename>. This means that the
386 boot will continue even if this mount point is not mounted
392 <term><option>x-initrd.mount
</option></term>
394 <listitem><para>An additional filesystem to be mounted in the
395 initramfs. See
<filename>initrd-fs.target
</filename>
397 <citerefentry><refentrytitle>systemd.special
</refentrytitle><manvolnum>7</manvolnum></citerefentry>.
402 <para>If a mount point is configured in both
403 <filename>/etc/fstab
</filename> and a unit file that is stored
404 below
<filename>/usr
</filename>, the former will take precedence.
405 If the unit file is stored below
<filename>/etc
</filename>, it
406 will take precedence. This means: native unit files take
407 precedence over traditional configuration files, but this is
408 superseded by the rule that configuration in
409 <filename>/etc
</filename> will always take precedence over
410 configuration in
<filename>/usr
</filename>.
</para>
414 <title>Options
</title>
416 <para>Mount files must include a [Mount] section, which carries
417 information about the file system mount points it supervises. A
418 number of options that may be used in this section are shared with
419 other unit types. These options are documented in
420 <citerefentry><refentrytitle>systemd.exec
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
422 <citerefentry><refentrytitle>systemd.kill
</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
423 The options specific to the [Mount] section of mount units are the
426 <variablelist class='unit-directives'
>
429 <term><varname>What=
</varname></term>
430 <listitem><para>Takes an absolute path of a device node, file or other resource to mount. See
<citerefentry
431 project='man-pages'
><refentrytitle>mount
</refentrytitle><manvolnum>8</manvolnum></citerefentry> for details. If
432 this refers to a device node, a dependency on the respective device unit is automatically created. (See
433 <citerefentry><refentrytitle>systemd.device
</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more
434 information.) This option is mandatory. Note that the usual specifier expansion is applied to this setting,
435 literal percent characters should hence be written as
<literal>%%
</literal>.
</para></listitem>
439 <term><varname>Where=
</varname></term>
440 <listitem><para>Takes an absolute path of a directory for the
441 mount point; in particular, the destination cannot be a symbolic
442 link. If the mount point does not exist at the time of
443 mounting, it is created. This string must be reflected in the
444 unit filename. (See above.) This option is
445 mandatory.
</para></listitem>
449 <term><varname>Type=
</varname></term>
450 <listitem><para>Takes a string for the file system type. See
451 <citerefentry project='man-pages'
><refentrytitle>mount
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
452 for details. This setting is optional.
</para></listitem>
456 <term><varname>Options=
</varname></term>
458 <listitem><para>Mount options to use when mounting. This takes a comma-separated list of options. This setting
459 is optional. Note that the usual specifier expansion is applied to this setting, literal percent characters
460 should hence be written as
<literal>%%
</literal>.
</para></listitem>
464 <term><varname>SloppyOptions=
</varname></term>
466 <listitem><para>Takes a boolean argument. If true, parsing of
467 the options specified in
<varname>Options=
</varname> is
468 relaxed, and unknown mount options are tolerated. This
470 <citerefentry project='man-pages'
><refentrytitle>mount
</refentrytitle><manvolnum>8</manvolnum></citerefentry>'s
471 <parameter>-s
</parameter> switch. Defaults to
472 off.
</para></listitem>
476 <term><varname>LazyUnmount=
</varname></term>
478 <listitem><para>Takes a boolean argument. If true, detach the
479 filesystem from the filesystem hierarchy at time of the unmount
480 operation, and clean up all references to the filesystem as
481 soon as they are not busy anymore.
482 This corresponds with
483 <citerefentry project='man-pages'
><refentrytitle>umount
</refentrytitle><manvolnum>8</manvolnum></citerefentry>'s
484 <parameter>-l
</parameter> switch. Defaults to
485 off.
</para></listitem>
489 <term><varname>ForceUnmount=
</varname></term>
491 <listitem><para>Takes a boolean argument. If true, force an
492 unmount (in case of an unreachable NFS system).
493 This corresponds with
494 <citerefentry project='man-pages'
><refentrytitle>umount
</refentrytitle><manvolnum>8</manvolnum></citerefentry>'s
495 <parameter>-f
</parameter> switch. Defaults to
496 off.
</para></listitem>
500 <term><varname>DirectoryMode=
</varname></term>
501 <listitem><para>Directories of mount points (and any parent
502 directories) are automatically created if needed. This option
503 specifies the file system access mode used when creating these
504 directories. Takes an access mode in octal notation. Defaults
505 to
0755.
</para></listitem>
509 <term><varname>TimeoutSec=
</varname></term>
510 <listitem><para>Configures the time to wait for the mount
511 command to finish. If a command does not exit within the
512 configured time, the mount will be considered failed and be
513 shut down again. All commands still running will be terminated
514 forcibly via
<constant>SIGTERM
</constant>, and after another
515 delay of this time with
<constant>SIGKILL
</constant>. (See
516 <option>KillMode=
</option> in
517 <citerefentry><refentrytitle>systemd.kill
</refentrytitle><manvolnum>5</manvolnum></citerefentry>.)
518 Takes a unit-less value in seconds, or a time span value such
519 as
"5min 20s". Pass
0 to disable the timeout logic. The
520 default value is set from the manager configuration file's
521 <varname>DefaultTimeoutStartSec=
</varname>
522 variable.
</para></listitem>
527 <citerefentry><refentrytitle>systemd.exec
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
529 <citerefentry><refentrytitle>systemd.kill
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
530 for more settings.
</para>
534 <title>See Also
</title>
536 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
537 <citerefentry><refentrytitle>systemctl
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
538 <citerefentry><refentrytitle>systemd.unit
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
539 <citerefentry><refentrytitle>systemd.exec
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
540 <citerefentry><refentrytitle>systemd.kill
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
541 <citerefentry><refentrytitle>systemd.resource-control
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
542 <citerefentry><refentrytitle>systemd.service
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
543 <citerefentry><refentrytitle>systemd.device
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
544 <citerefentry project='man-pages'
><refentrytitle>proc
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
545 <citerefentry project='man-pages'
><refentrytitle>mount
</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
546 <citerefentry><refentrytitle>systemd-fstab-generator
</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
547 <citerefentry><refentrytitle>systemd.directives
</refentrytitle><manvolnum>7</manvolnum></citerefentry>