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