]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/systemd-mount.xml
man: fix link markup
[thirdparty/systemd.git] / man / systemd-mount.xml
1 <?xml version='1.0'?>
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1+ -->
5
6 <refentry id="systemd-mount"
7 xmlns:xi="http://www.w3.org/2001/XInclude">
8
9 <refentryinfo>
10 <title>systemd-mount</title>
11 <productname>systemd</productname>
12 </refentryinfo>
13
14 <refmeta>
15 <refentrytitle>systemd-mount</refentrytitle>
16 <manvolnum>1</manvolnum>
17 </refmeta>
18
19 <refnamediv>
20 <refname>systemd-mount</refname>
21 <refname>systemd-umount</refname>
22 <refpurpose>Establish and destroy transient mount or auto-mount points</refpurpose>
23 </refnamediv>
24
25 <refsynopsisdiv>
26 <cmdsynopsis>
27 <command>systemd-mount</command>
28 <arg choice="opt" rep="repeat"><replaceable>OPTIONS</replaceable></arg>
29 <arg choice="plain"><replaceable>WHAT</replaceable></arg>
30 <arg choice="opt"><replaceable>WHERE</replaceable></arg>
31 </cmdsynopsis>
32 <cmdsynopsis>
33 <command>systemd-mount</command>
34 <arg choice="opt" rep="repeat"><replaceable>OPTIONS</replaceable></arg>
35 <arg choice="plain"><option>--list</option></arg>
36 </cmdsynopsis>
37 <cmdsynopsis>
38 <command>systemd-mount</command>
39 <arg choice="opt" rep="repeat"><replaceable>OPTIONS</replaceable></arg>
40 <arg choice="plain"><option>--umount</option></arg>
41 <arg choice="plain" rep="repeat"><replaceable>WHAT|WHERE</replaceable></arg>
42 </cmdsynopsis>
43 </refsynopsisdiv>
44
45 <refsect1>
46 <title>Description</title>
47
48 <para><command>systemd-mount</command> may be used to create and start a transient <filename>.mount</filename> or
49 <filename>.automount</filename> unit of the file system <replaceable>WHAT</replaceable> on the mount point
50 <replaceable>WHERE</replaceable>.</para>
51
52 <para>In many ways, <command>systemd-mount</command> is similar to the lower-level
53 <citerefentry project='man-pages'><refentrytitle>mount</refentrytitle><manvolnum>8</manvolnum></citerefentry>
54 command, however instead of executing the mount operation directly and immediately,
55 <command>systemd-mount</command> schedules it through the service manager job queue, so that it may pull
56 in further dependencies (such as parent mounts, or a file system checker to execute a priori), and may
57 make use of the auto-mounting logic.</para>
58
59 <para>The command takes either one or two arguments. If only one argument is specified it should refer to
60 a block device or regular file containing a file system (e.g. <literal>/dev/sdb1</literal> or
61 <literal>/path/to/disk.img</literal>). The block device or image file is then probed for a file system
62 label and other metadata, and is mounted to a directory below <filename>/run/media/system/</filename>
63 whose name is generated from the file system label. In this mode the block device or image file must
64 exist at the time of invocation of the command, so that it may be probed. If the device is found to be a
65 removable block device (e.g. a USB stick), an automount point is created instead of a regular mount point
66 (i.e. the <option>--automount=</option> option is implied, see below).</para>
67
68 <para>If two arguments are specified, the first indicates the mount source (the
69 <replaceable>WHAT</replaceable>) and the second indicates the path to mount it on (the
70 <replaceable>WHERE</replaceable>). In this mode no probing of the source is attempted, and a backing
71 device node doesn't have to exist. However, if this mode is combined with <option>--discover</option>,
72 device node probing for additional metadata is enabled, and – much like in the single-argument case
73 discussed above – the specified device has to exist at the time of invocation of the command.</para>
74
75 <para>Use the <option>--list</option> command to show a terse table of all local, known block devices with file
76 systems that may be mounted with this command.</para>
77
78 <para><command>systemd-umount</command> can be used to unmount a mount or automount point. It is the same
79 as <command>systemd-mount</command> <option>--umount</option>.</para>
80 </refsect1>
81
82 <refsect1>
83 <title>Options</title>
84
85 <para>The following options are understood:</para>
86
87 <variablelist>
88
89 <varlistentry>
90 <term><option>--no-block</option></term>
91
92 <listitem>
93 <para>Do not synchronously wait for the requested operation to finish. If this is not specified, the job will
94 be verified, enqueued and <command>systemd-mount</command> will wait until the mount or automount unit's
95 start-up is completed. By passing this argument, it is only verified and enqueued.</para>
96 </listitem>
97 </varlistentry>
98
99 <varlistentry>
100 <term><option>-l</option></term>
101 <term><option>--full</option></term>
102
103 <listitem>
104 <para>Do not ellipsize the output when <option>--list</option> is specified.</para>
105 </listitem>
106 </varlistentry>
107
108 <xi:include href="standard-options.xml" xpointer="no-pager"/>
109 <xi:include href="standard-options.xml" xpointer="no-legend" />
110 <xi:include href="standard-options.xml" xpointer="no-ask-password"/>
111
112 <varlistentry>
113 <term><option>--quiet</option></term>
114 <term><option>-q</option></term>
115
116 <listitem><para>Suppresses additional informational output while running.</para></listitem>
117 </varlistentry>
118
119 <varlistentry>
120 <term><option>--discover</option></term>
121
122 <listitem><para>Enable probing of the mount source. This switch is implied if a single argument is specified on
123 the command line. If passed, additional metadata is read from the device to enhance the unit to create. For
124 example, a descriptive string for the transient units is generated from the file system label and device
125 model. Moreover if a removable block device (e.g. USB stick) is detected an automount unit instead of a regular
126 mount unit is created, with a short idle timeout, in order to ensure the file-system is placed in a clean
127 state quickly after each access.</para></listitem>
128 </varlistentry>
129
130 <varlistentry>
131 <term><option>--type=</option></term>
132 <term><option>-t</option></term>
133
134 <listitem><para>Specifies the file system type to mount (e.g. <literal>vfat</literal>, <literal>ext4</literal>,
135 …). If omitted (or set to <literal>auto</literal>) the file system is determined automatically.</para></listitem>
136 </varlistentry>
137
138 <varlistentry>
139 <term><option>--options=</option></term>
140 <term><option>-o</option></term>
141
142 <listitem><para>Additional mount options for the mount point.</para></listitem>
143 </varlistentry>
144
145 <varlistentry>
146 <term><option>--owner=<replaceable>USER</replaceable></option></term>
147
148 <listitem><para>Let the specified user <replaceable>USER</replaceable> own the mounted file system.
149 This is done by appending <option>uid=</option> and <option>gid=</option> options to the list
150 of mount options. Only certain file systems support this option.</para></listitem>
151 </varlistentry>
152
153 <varlistentry>
154 <term><option>--fsck=</option></term>
155
156 <listitem><para>Takes a boolean argument, defaults to on. Controls whether to run a file system check
157 immediately before the mount operation. In the automount case (see <option>--automount=</option> below) the
158 check will be run the moment the first access to the device is made, which might slightly delay the
159 access.</para></listitem>
160 </varlistentry>
161
162 <varlistentry>
163 <term><option>--description=</option></term>
164
165 <listitem><para>Provide a description for the mount or automount unit. See <varname>Description=</varname> in
166 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
167 </para></listitem>
168 </varlistentry>
169
170 <varlistentry>
171 <term><option>--property=</option></term>
172 <term><option>-p</option></term>
173
174 <listitem><para>Sets a unit property for the mount unit that is created. This takes an assignment in the same
175 format as <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s
176 <command>set-property</command> command.</para>
177 </listitem>
178 </varlistentry>
179
180 <varlistentry>
181 <term><option>--automount=</option></term>
182
183 <listitem><para>Takes a boolean argument. Controls whether to create an automount point or a regular mount
184 point. If true an automount point is created that is backed by the actual file system at the time of first
185 access. If false a plain mount point is created that is backed by the actual file system immediately. Automount
186 points have the benefit that the file system stays unmounted and hence in clean state until it is first
187 accessed. In automount mode the <option>--timeout-idle-sec=</option> switch (see below) may be used to ensure
188 the mount point is unmounted automatically after the last access and an idle period passed.</para>
189
190 <para>If this switch is not specified it defaults to false. If not specified and <option>--discover</option> is
191 used (or only a single argument passed, which implies <option>--discover</option>, see above), and the file
192 system block device is detected to be removable, it is set to true, in order to increase the chance that the
193 file system is in a fully clean state if the device is unplugged abruptly.</para></listitem>
194 </varlistentry>
195
196 <varlistentry>
197 <term><option>-A</option></term>
198
199 <listitem><para>Equivalent to <option>--automount=yes</option>.</para></listitem>
200 </varlistentry>
201
202 <varlistentry>
203 <term><option>--timeout-idle-sec=</option></term>
204
205 <listitem><para>Takes a time value that controls the idle timeout in automount mode. If set to
206 <literal>infinity</literal> (the default) no automatic unmounts are done. Otherwise the file system backing the
207 automount point is detached after the last access and the idle timeout passed. See
208 <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry> for details on
209 the time syntax supported. This option has no effect if only a regular mount is established, and automounting
210 is not used.</para>
211
212 <para>Note that if <option>--discover</option> is used (or only a single argument passed, which implies
213 <option>--discover</option>, see above), and the file system block device is detected to be removable,
214 <option>--timeout-idle-sec=1s</option> is implied.</para></listitem>
215 </varlistentry>
216
217 <varlistentry>
218 <term><option>--automount-property=</option></term>
219
220 <listitem><para>Similar to <option>--property=</option>, but applies additional properties to the automount
221 unit created, instead of the mount unit.</para></listitem>
222 </varlistentry>
223
224 <varlistentry>
225 <term><option>--bind-device</option></term>
226
227 <listitem><para>This option only has an effect in automount mode,
228 and controls whether the automount unit shall be bound to the backing device's lifetime. If set, the
229 automount point will be removed automatically when the backing device vanishes. By default the automount point
230 stays around, and subsequent accesses will block until backing device is replugged. This option has no effect
231 in case of non-device mounts, such as network or virtual file system mounts.</para>
232
233 <para>Note that if <option>--discover</option> is used (or only a single argument passed, which implies
234 <option>--discover</option>, see above), and the file system block device is detected to be removable, this
235 option is implied.</para></listitem>
236 </varlistentry>
237
238 <varlistentry>
239 <term><option>--list</option></term>
240
241 <listitem><para>Instead of establishing a mount or automount point, print a terse list of block devices
242 containing file systems that may be mounted with <literal>systemd-mount</literal>, along with useful metadata
243 such as labels, etc.</para></listitem>
244 </varlistentry>
245
246 <varlistentry>
247 <term><option>-u</option></term>
248 <term><option>--umount</option></term>
249
250 <listitem><para>Stop the mount and automount units corresponding to the specified mount points
251 <replaceable>WHERE</replaceable> or the devices <replaceable>WHAT</replaceable>.
252 <command>systemd-mount</command> with this option or <command>systemd-umount</command> can take multiple arguments
253 which can be mount points, devices, <filename>/etc/fstab</filename> style node names, or backing files
254 corresponding to loop devices, like
255 <command>systemd-mount --umount /path/to/umount /dev/sda1 UUID=xxxxxx-xxxx LABEL=xxxxx /path/to/disk.img</command>.
256 Note that when <option>-H</option> or <option>-M</option> is specified, only absolute paths to mount points are
257 supported.</para></listitem>
258 </varlistentry>
259
260 <varlistentry>
261 <term><option>-G</option></term>
262 <term><option>--collect</option></term>
263
264 <listitem><para>Unload the transient unit after it completed, even if it failed. Normally, without this option,
265 all mount units that mount and failed are kept in memory until the user explicitly resets their failure state with
266 <command>systemctl reset-failed</command> or an equivalent command. On the other hand, units that stopped
267 successfully are unloaded immediately. If this option is turned on the "garbage collection" of units is more
268 aggressive, and unloads units regardless if they exited successfully or failed. This option is a shortcut for
269 <command>--property=CollectMode=inactive-or-failed</command>, see the explanation for
270 <varname>CollectMode=</varname> in
271 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry> for further
272 information.</para></listitem>
273 </varlistentry>
274
275 <xi:include href="user-system-options.xml" xpointer="user" />
276 <xi:include href="user-system-options.xml" xpointer="system" />
277 <xi:include href="user-system-options.xml" xpointer="host" />
278 <xi:include href="user-system-options.xml" xpointer="machine" />
279
280 <xi:include href="standard-options.xml" xpointer="help" />
281 <xi:include href="standard-options.xml" xpointer="version" />
282 </variablelist>
283
284 </refsect1>
285
286 <refsect1>
287 <title>Exit status</title>
288
289 <para>On success, 0 is returned, a non-zero failure
290 code otherwise.</para>
291 </refsect1>
292
293 <refsect1>
294 <title>The udev Database</title>
295
296 <para>If <option>--discover</option> is used, <command>systemd-mount</command> honors a couple of additional udev
297 properties of block devices:</para>
298
299 <variablelist class='udev-directives'>
300 <varlistentry>
301 <term><varname>SYSTEMD_MOUNT_OPTIONS=</varname></term>
302
303 <listitem><para>The mount options to use, if <option>--options=</option> is not used.</para></listitem>
304 </varlistentry>
305
306 <varlistentry>
307 <term><varname>SYSTEMD_MOUNT_WHERE=</varname></term>
308
309 <listitem><para>The file system path to place the mount point at, instead of the automatically generated
310 one.</para></listitem>
311 </varlistentry>
312 </variablelist>
313 </refsect1>
314
315 <refsect1>
316 <title>Example</title>
317
318 <para>Use a udev rule like the following to automatically mount all USB storage plugged in:</para>
319
320 <programlisting>ACTION=="add", SUBSYSTEMS=="usb", SUBSYSTEM=="block", ENV{ID_FS_USAGE}=="filesystem", \
321 RUN{program}+="/usr/bin/systemd-mount --no-block --automount=yes --collect $devnode"</programlisting>
322 </refsect1>
323
324 <refsect1>
325 <title>See Also</title>
326 <para>
327 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
328 <citerefentry project='man-pages'><refentrytitle>mount</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
329 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
330 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
331 <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
332 <citerefentry><refentrytitle>systemd.automount</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
333 <citerefentry><refentrytitle>systemd-run</refentrytitle><manvolnum>1</manvolnum></citerefentry>
334 </para>
335 </refsect1>
336
337 </refentry>