]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/systemd.mount.xml
58cdb547ea84742460dd44a0eb766fc69df0a3c7
[thirdparty/systemd.git] / man / systemd.mount.xml
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">
4
5 <!--
6 This file is part of systemd.
7
8 Copyright 2010 Lennart Poettering
9
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 -->
23
24 <refentry id="systemd.mount">
25 <refentryinfo>
26 <title>systemd.mount</title>
27 <productname>systemd</productname>
28
29 <authorgroup>
30 <author>
31 <contrib>Developer</contrib>
32 <firstname>Lennart</firstname>
33 <surname>Poettering</surname>
34 <email>lennart@poettering.net</email>
35 </author>
36 </authorgroup>
37 </refentryinfo>
38
39 <refmeta>
40 <refentrytitle>systemd.mount</refentrytitle>
41 <manvolnum>5</manvolnum>
42 </refmeta>
43
44 <refnamediv>
45 <refname>systemd.mount</refname>
46 <refpurpose>Mount unit configuration</refpurpose>
47 </refnamediv>
48
49 <refsynopsisdiv>
50 <para><filename><replaceable>mount</replaceable>.mount</filename></para>
51 </refsynopsisdiv>
52
53 <refsect1>
54 <title>Description</title>
55
56 <para>A unit configuration file whose name ends in
57 <literal>.mount</literal> encodes information about a file system
58 mount point controlled and supervised by systemd.</para>
59
60 <para>This man page lists the configuration options specific to
61 this unit type. See
62 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
63 for the common options of all unit configuration files. The common
64 configuration items are configured in the generic [Unit] and
65 [Install] sections. The mount specific configuration options are
66 configured in the [Mount] section.</para>
67
68 <para>Additional options are listed in
69 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
70 which define the execution environment the
71 <citerefentry project='man-pages'><refentrytitle>mount</refentrytitle><manvolnum>8</manvolnum></citerefentry>
72 binary is executed in, and in
73 <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
74 which define the way the processes are terminated, and in
75 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
76 which configure resource control settings for the processes of the
77 service. Note that the User= and Group= options are not
78 particularly useful for mount units specifying a
79 <literal>Type=</literal> option or using configuration not
80 specified in <filename>/etc/fstab</filename>;
81 <citerefentry project='man-pages'><refentrytitle>mount</refentrytitle><manvolnum>8</manvolnum></citerefentry>
82 will refuse options that are not listed in
83 <filename>/etc/fstab</filename> if it is not run as UID 0.</para>
84
85 <para>Mount units must be named after the mount point directories they control. Example: the mount point <filename
86 noindex='true'>/home/lennart</filename> must be configured in a unit file <filename>home-lennart.mount</filename>.
87 For details about the escaping logic used to convert a file system path to a unit name, see
88 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>. Note that mount
89 units cannot be templated, nor is possible to add multiple names to a mount unit by creating additional symlinks to
90 it.</para>
91
92 <para>Optionally, a mount unit may be accompanied by an automount
93 unit, to allow on-demand or parallelized mounting. See
94 <citerefentry><refentrytitle>systemd.automount</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
95
96 <para>Mount points created at runtime (independently of unit files
97 or <filename>/etc/fstab</filename>) will be monitored by systemd
98 and appear like any other mount unit in systemd. See
99 <filename>/proc/self/mountinfo</filename> description in
100 <citerefentry project='man-pages'><refentrytitle>proc</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
101 </para>
102
103 <para>Some file systems have special semantics as API file systems
104 for kernel-to-userspace and userspace-to-userspace interfaces. Some
105 of them may not be changed via mount units, and cannot be
106 disabled. For a longer discussion see <ulink
107 url="https://www.freedesktop.org/wiki/Software/systemd/APIFileSystems">API
108 File Systems</ulink>.</para>
109 </refsect1>
110
111 <refsect1>
112 <title>Implicit Dependencies</title>
113
114 <para>The following dependencies are implicitly added:</para>
115
116 <itemizedlist>
117 <listitem><para>If a mount unit is beneath another mount unit in the file
118 system hierarchy, both a requirement dependency and an ordering
119 dependency between both units are created automatically.</para></listitem>
120
121 <listitem><para>Block device backed file systems automatically gain
122 <varname>BindsTo=</varname> and <varname>After=</varname> type
123 dependencies on the device unit encapsulating the block
124 device (see below).</para></listitem>
125
126 <listitem><para>If traditional file system quota is enabled for a mount
127 unit, automatic <varname>Wants=</varname> and
128 <varname>Before=</varname> dependencies on
129 <filename>systemd-quotacheck.service</filename> and
130 <filename>quotaon.service</filename> are added.</para></listitem>
131
132 <listitem><para>Additional implicit dependencies may be added as result of
133 execution and resource control parameters as documented in
134 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
135 and
136 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
137 </para></listitem>
138 </itemizedlist>
139 </refsect1>
140
141 <refsect1>
142 <title>Default Dependencies</title>
143
144 <para>The following dependencies are added unless <varname>DefaultDependencies=no</varname> is set:</para>
145
146 <itemizedlist>
147 <listitem><para>All mount units acquire automatic <varname>Before=</varname> and <varname>Conflicts=</varname> on
148 <filename>umount.target</filename> in order to be stopped during shutdown.</para></listitem>
149
150 <listitem><para>Mount units referring to local file systems automatically gain
151 an <varname>After=</varname> dependency on <filename>local-fs-pre.target</filename>.</para></listitem>
152
153 <listitem><para>Network mount units
154 automatically acquire <varname>After=</varname> dependencies on <filename>remote-fs-pre.target</filename>,
155 <filename>network.target</filename> and <filename>network-online.target</filename>. Towards the latter a
156 <varname>Wants=</varname> unit is added as well.</para></listitem>
157 </itemizedlist>
158
159 <para>Mount units referring to local and network file systems are
160 distinguished by their file system type specification. In some cases this is not sufficient (for example network
161 block device based mounts, such as iSCSI), in which case <option>_netdev</option> may be added to the mount option
162 string of the unit, which forces systemd to consider the mount unit a network mount.</para>
163 </refsect1>
164
165 <refsect1>
166 <title><filename>fstab</filename></title>
167
168 <para>Mount units may either be configured via unit files, or via
169 <filename>/etc/fstab</filename> (see
170 <citerefentry project='man-pages'><refentrytitle>fstab</refentrytitle><manvolnum>5</manvolnum></citerefentry>
171 for details). Mounts listed in <filename>/etc/fstab</filename>
172 will be converted into native units dynamically at boot and when
173 the configuration of the system manager is reloaded. In general,
174 configuring mount points through <filename>/etc/fstab</filename>
175 is the preferred approach. See
176 <citerefentry><refentrytitle>systemd-fstab-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>
177 for details about the conversion.</para>
178
179 <para>The NFS mount option <option>bg</option> for NFS background mounts
180 as documented in <citerefentry project='man-pages'><refentrytitle>nfs</refentrytitle><manvolnum>5</manvolnum></citerefentry>
181 is detected by <command>systemd-fstab-generator</command> and the options
182 are transformed so that systemd fulfills the job-control implications of
183 that option. Specifically <command>systemd-fstab-generator</command> acts
184 as though <literal>x-systemd.mount-timout=infinity,retry=10000</literal> was
185 prepended to the option list, and <literal>fg,nofail</literal> was appended.
186 Depending on specific requirements, it may be appropriate to provide some of
187 these options explicitly, or to make use of the
188 <literal>x-systemd.automount</literal> option described below instead
189 of using <literal>bg</literal>.</para>
190
191 <para>When reading <filename>/etc/fstab</filename> a few special
192 mount options are understood by systemd which influence how
193 dependencies are created for mount points. systemd will create a
194 dependency of type <varname>Wants=</varname> or
195 <option>Requires</option> (see option <option>nofail</option>
196 below), from either <filename>local-fs.target</filename> or
197 <filename>remote-fs.target</filename>, depending whether the file
198 system is local or remote.</para>
199
200 <variablelist class='fstab-options'>
201
202 <varlistentry>
203 <term><option>x-systemd.requires=</option></term>
204
205 <listitem><para>Configures a <varname>Requires=</varname> and
206 an <varname>After=</varname> dependency between the created
207 mount unit and another systemd unit, such as a device or mount
208 unit. The argument should be a unit name, or an absolute path
209 to a device node or mount point. This option may be specified
210 more than once. This option is particularly useful for mount
211 point declarations that need an additional device to be around
212 (such as an external journal device for journal file systems)
213 or an additional mount to be in place (such as an overlay file
214 system that merges multiple mount points). See
215 <varname>After=</varname> and <varname>Requires=</varname> in
216 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
217 for details.</para></listitem>
218 </varlistentry>
219
220 <varlistentry>
221 <term><option>x-systemd.before=</option></term>
222 <term><option>x-systemd.after=</option></term>
223
224 <listitem><para>Configures a <varname>Before=</varname>
225 dependency or <varname>After=</varname> between the created
226 mount unit and another systemd unit, such as a mount unit.
227 The argument should be a unit name or an absolute path
228 to a mount point. This option may be specified more than once.
229 This option is particularly useful for mount point declarations
230 with <option>nofail</option> option that are mounted
231 asynchronously but need to be mounted before or after some unit
232 start, for example, before <filename>local-fs.target</filename>
233 unit.
234 See <varname>Before=</varname> and <varname>After=</varname> in
235 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
236 for details.</para></listitem>
237 </varlistentry>
238
239 <varlistentry>
240 <term><option>x-systemd.requires-mounts-for=</option></term>
241
242 <listitem><para>Configures a
243 <varname>RequiresMountsFor=</varname> dependency between the
244 created mount unit and other mount units. The argument must be
245 an absolute path. This option may be specified more than once.
246 See <varname>RequiresMountsFor=</varname> in
247 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
248 for details.</para></listitem>
249 </varlistentry>
250
251 <varlistentry>
252 <term><option>x-systemd.device-bound</option></term>
253
254 <listitem><para>The block device backed file system will be upgraded
255 to <varname>BindsTo=</varname> dependency. This option is only useful
256 when mounting file systems manually with
257 <citerefentry project='man-pages'><refentrytitle>mount</refentrytitle><manvolnum>8</manvolnum></citerefentry>
258 as the default dependency in this case is <varname>Requires=</varname>.
259 This option is already implied by entries in <filename>/etc/fstab</filename>
260 or by mount units.
261 </para></listitem>
262 </varlistentry>
263
264 <varlistentry>
265 <term><option>x-systemd.automount</option></term>
266
267 <listitem><para>An automount unit will be created for the file
268 system. See
269 <citerefentry><refentrytitle>systemd.automount</refentrytitle><manvolnum>5</manvolnum></citerefentry>
270 for details.</para></listitem>
271 </varlistentry>
272
273 <varlistentry>
274 <term><option>x-systemd.idle-timeout=</option></term>
275
276 <listitem><para>Configures the idle timeout of the
277 automount unit. See <varname>TimeoutIdleSec=</varname> in
278 <citerefentry><refentrytitle>systemd.automount</refentrytitle><manvolnum>5</manvolnum></citerefentry>
279 for details.</para></listitem>
280 </varlistentry>
281
282 <varlistentry>
283 <term><option>x-systemd.device-timeout=</option></term>
284
285 <listitem><para>Configure how long systemd should wait for a
286 device to show up before giving up on an entry from
287 <filename>/etc/fstab</filename>. Specify a time in seconds or
288 explicitly append a unit such as <literal>s</literal>,
289 <literal>min</literal>, <literal>h</literal>,
290 <literal>ms</literal>.</para>
291
292 <para>Note that this option can only be used in
293 <filename>/etc/fstab</filename>, and will be
294 ignored when part of the <varname>Options=</varname>
295 setting in a unit file.</para>
296 </listitem>
297 </varlistentry>
298
299 <varlistentry>
300 <term><option>x-systemd.mount-timeout=</option></term>
301
302 <listitem><para>Configure how long systemd should wait for the
303 mount command to finish before giving up on an entry from
304 <filename>/etc/fstab</filename>. Specify a time in seconds or
305 explicitly append a unit such as <literal>s</literal>,
306 <literal>min</literal>, <literal>h</literal>,
307 <literal>ms</literal>.</para>
308
309 <para>Note that this option can only be used in
310 <filename>/etc/fstab</filename>, and will be
311 ignored when part of the <varname>Options=</varname>
312 setting in a unit file.</para>
313
314 <para>See <varname>TimeoutSec=</varname> below for
315 details.</para>
316 </listitem>
317 </varlistentry>
318
319 <varlistentry>
320 <term><option>_netdev</option></term>
321
322 <listitem><para>Normally the file system type is used to determine if a
323 mount is a "network mount", i.e. if it should only be started after the
324 network is available. Using this option overrides this detection and
325 specifies that the mount requires network.</para>
326
327 <para>Network mount units are ordered between <filename>remote-fs-pre.target</filename>
328 and <filename>remote-fs.target</filename>, instead of
329 <filename>local-fs-pre.target</filename> and <filename>local-fs.target</filename>.
330 They also pull in <filename>network-online.target</filename> and are ordered after
331 it and <filename>network.target</filename>.</para>
332 </listitem>
333 </varlistentry>
334
335 <varlistentry>
336 <term><option>noauto</option></term>
337 <term><option>auto</option></term>
338
339 <listitem><para>With <option>noauto</option>, this mount will
340 not be added as a dependency for
341 <filename>local-fs.target</filename> or
342 <filename>remote-fs.target</filename>. This means that it will
343 not be mounted automatically during boot, unless it is pulled
344 in by some other unit. The <option>auto</option> option has the
345 opposite meaning and is the default.</para>
346 </listitem>
347 </varlistentry>
348
349 <varlistentry>
350 <term><option>nofail</option></term>
351
352 <listitem><para>With <option>nofail</option>, this mount will
353 be only wanted, not required, by
354 <filename>local-fs.target</filename> or
355 <filename>remote-fs.target</filename>. This means that the
356 boot will continue even if this mount point is not mounted
357 successfully.</para>
358 </listitem>
359 </varlistentry>
360
361 <varlistentry>
362 <term><option>x-initrd.mount</option></term>
363
364 <listitem><para>An additional filesystem to be mounted in the
365 initramfs. See <filename>initrd-fs.target</filename>
366 description in
367 <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>.
368 </para></listitem>
369 </varlistentry>
370 </variablelist>
371
372 <para>If a mount point is configured in both
373 <filename>/etc/fstab</filename> and a unit file that is stored
374 below <filename>/usr</filename>, the former will take precedence.
375 If the unit file is stored below <filename>/etc</filename>, it
376 will take precedence. This means: native unit files take
377 precedence over traditional configuration files, but this is
378 superseded by the rule that configuration in
379 <filename>/etc</filename> will always take precedence over
380 configuration in <filename>/usr</filename>.</para>
381 </refsect1>
382
383 <refsect1>
384 <title>Options</title>
385
386 <para>Mount files must include a [Mount] section, which carries
387 information about the file system mount points it supervises. A
388 number of options that may be used in this section are shared with
389 other unit types. These options are documented in
390 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
391 and
392 <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
393 The options specific to the [Mount] section of mount units are the
394 following:</para>
395
396 <variablelist class='unit-directives'>
397
398 <varlistentry>
399 <term><varname>What=</varname></term>
400 <listitem><para>Takes an absolute path of a device node, file or other resource to mount. See <citerefentry
401 project='man-pages'><refentrytitle>mount</refentrytitle><manvolnum>8</manvolnum></citerefentry> for details. If
402 this refers to a device node, a dependency on the respective device unit is automatically created. (See
403 <citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more
404 information.) This option is mandatory. Note that the usual specifier expansion is applied to this setting,
405 literal percent characters should hence be written as <literal>%%</literal>.</para></listitem>
406 </varlistentry>
407
408 <varlistentry>
409 <term><varname>Where=</varname></term>
410 <listitem><para>Takes an absolute path of a directory for the
411 mount point; in particular, the destination cannot be a symbolic
412 link. If the mount point does not exist at the time of
413 mounting, it is created. This string must be reflected in the
414 unit filename. (See above.) This option is
415 mandatory.</para></listitem>
416 </varlistentry>
417
418 <varlistentry>
419 <term><varname>Type=</varname></term>
420 <listitem><para>Takes a string for the file system type. See
421 <citerefentry project='man-pages'><refentrytitle>mount</refentrytitle><manvolnum>8</manvolnum></citerefentry>
422 for details. This setting is optional.</para></listitem>
423 </varlistentry>
424
425 <varlistentry>
426 <term><varname>Options=</varname></term>
427
428 <listitem><para>Mount options to use when mounting. This takes a comma-separated list of options. This setting
429 is optional. Note that the usual specifier expansion is applied to this setting, literal percent characters
430 should hence be written as <literal>%%</literal>.</para></listitem>
431 </varlistentry>
432
433 <varlistentry>
434 <term><varname>SloppyOptions=</varname></term>
435
436 <listitem><para>Takes a boolean argument. If true, parsing of
437 the options specified in <varname>Options=</varname> is
438 relaxed, and unknown mount options are tolerated. This
439 corresponds with
440 <citerefentry project='man-pages'><refentrytitle>mount</refentrytitle><manvolnum>8</manvolnum></citerefentry>'s
441 <parameter>-s</parameter> switch. Defaults to
442 off.</para></listitem>
443 </varlistentry>
444
445 <varlistentry>
446 <term><varname>LazyUnmount=</varname></term>
447
448 <listitem><para>Takes a boolean argument. If true, detach the
449 filesystem from the filesystem hierarchy at time of the unmount
450 operation, and clean up all references to the filesystem as
451 soon as they are not busy anymore.
452 This corresponds with
453 <citerefentry project='man-pages'><refentrytitle>umount</refentrytitle><manvolnum>8</manvolnum></citerefentry>'s
454 <parameter>-l</parameter> switch. Defaults to
455 off.</para></listitem>
456 </varlistentry>
457
458 <varlistentry>
459 <term><varname>ForceUnmount=</varname></term>
460
461 <listitem><para>Takes a boolean argument. If true, force an
462 unmount (in case of an unreachable NFS system).
463 This corresponds with
464 <citerefentry project='man-pages'><refentrytitle>umount</refentrytitle><manvolnum>8</manvolnum></citerefentry>'s
465 <parameter>-f</parameter> switch. Defaults to
466 off.</para></listitem>
467 </varlistentry>
468
469 <varlistentry>
470 <term><varname>DirectoryMode=</varname></term>
471 <listitem><para>Directories of mount points (and any parent
472 directories) are automatically created if needed. This option
473 specifies the file system access mode used when creating these
474 directories. Takes an access mode in octal notation. Defaults
475 to 0755.</para></listitem>
476 </varlistentry>
477
478 <varlistentry>
479 <term><varname>TimeoutSec=</varname></term>
480 <listitem><para>Configures the time to wait for the mount
481 command to finish. If a command does not exit within the
482 configured time, the mount will be considered failed and be
483 shut down again. All commands still running will be terminated
484 forcibly via <constant>SIGTERM</constant>, and after another
485 delay of this time with <constant>SIGKILL</constant>. (See
486 <option>KillMode=</option> in
487 <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>.)
488 Takes a unit-less value in seconds, or a time span value such
489 as "5min 20s". Pass 0 to disable the timeout logic. The
490 default value is set from the manager configuration file's
491 <varname>DefaultTimeoutStartSec=</varname>
492 variable.</para></listitem>
493 </varlistentry>
494 </variablelist>
495
496 <para>Check
497 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
498 and
499 <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>
500 for more settings.</para>
501 </refsect1>
502
503 <refsect1>
504 <title>See Also</title>
505 <para>
506 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
507 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
508 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
509 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
510 <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
511 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
512 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
513 <citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
514 <citerefentry project='man-pages'><refentrytitle>proc</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
515 <citerefentry project='man-pages'><refentrytitle>mount</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
516 <citerefentry><refentrytitle>systemd-fstab-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
517 <citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry>
518 </para>
519 </refsect1>
520
521 </refentry>