]>
Commit | Line | Data |
---|---|---|
514094f9 | 1 | <?xml version='1.0'?> |
3a54a157 ZJS |
2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" |
3 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> | |
db9ecf05 | 4 | <!-- SPDX-License-Identifier: LGPL-2.1-or-later --> |
450442cf LP |
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> | |
450442cf LP |
12 | </refentryinfo> |
13 | ||
14 | <refmeta> | |
15 | <refentrytitle>systemd-mount</refentrytitle> | |
16 | <manvolnum>1</manvolnum> | |
17 | </refmeta> | |
18 | ||
19 | <refnamediv> | |
20 | <refname>systemd-mount</refname> | |
d20a328f ZJS |
21 | <refname>systemd-umount</refname> |
22 | <refpurpose>Establish and destroy transient mount or auto-mount points</refpurpose> | |
450442cf LP |
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> | |
2322c6c7 LB |
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> | |
450442cf LP |
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> | |
d20a328f | 44 | <cmdsynopsis> |
9017f5d8 | 45 | <command>systemd-mount</command> |
d20a328f | 46 | <arg choice="opt" rep="repeat"><replaceable>OPTIONS</replaceable></arg> |
9017f5d8 YW |
47 | <arg choice="plain"><option>--umount</option></arg> |
48 | <arg choice="plain" rep="repeat"><replaceable>WHAT|WHERE</replaceable></arg> | |
d20a328f | 49 | </cmdsynopsis> |
450442cf LP |
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 | |
e9dd6984 ZJS |
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> | |
450442cf | 65 | |
f0e3650d LP |
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 | |
e9dd6984 | 72 | removable block device (e.g. a USB stick), an automount point is created instead of a regular mount point |
2322c6c7 LB |
73 | (i.e. the <option>--automount=</option> option is implied, see below). If the option <option>--tmpfs</option> |
74 | is specified, then the argument will be interpreted as the path where the new temporary file system will | |
75 | be mounted on.</para> | |
450442cf | 76 | |
e9dd6984 ZJS |
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> | |
450442cf LP |
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> | |
d20a328f ZJS |
86 | |
87 | <para><command>systemd-umount</command> can be used to unmount a mount or automount point. It is the same | |
8cc7661d | 88 | as <command>systemd-mount</command> <option>--umount</option>.</para> |
450442cf LP |
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 | </listitem> | |
106 | </varlistentry> | |
107 | ||
a362c069 YW |
108 | <varlistentry> |
109 | <term><option>-l</option></term> | |
110 | <term><option>--full</option></term> | |
111 | ||
112 | <listitem> | |
113 | <para>Do not ellipsize the output when <option>--list</option> is specified.</para> | |
114 | </listitem> | |
115 | </varlistentry> | |
116 | ||
450442cf | 117 | <xi:include href="standard-options.xml" xpointer="no-pager"/> |
a5279634 | 118 | <xi:include href="standard-options.xml" xpointer="no-legend" /> |
450442cf LP |
119 | <xi:include href="standard-options.xml" xpointer="no-ask-password"/> |
120 | ||
121 | <varlistentry> | |
122 | <term><option>--quiet</option></term> | |
123 | <term><option>-q</option></term> | |
124 | ||
125 | <listitem><para>Suppresses additional informational output while running.</para></listitem> | |
126 | </varlistentry> | |
127 | ||
128 | <varlistentry> | |
129 | <term><option>--discover</option></term> | |
130 | ||
131 | <listitem><para>Enable probing of the mount source. This switch is implied if a single argument is specified on | |
132 | the command line. If passed, additional metadata is read from the device to enhance the unit to create. For | |
133 | example, a descriptive string for the transient units is generated from the file system label and device | |
134 | model. Moreover if a removable block device (e.g. USB stick) is detected an automount unit instead of a regular | |
3f9a0a52 | 135 | mount unit is created, with a short idle timeout, in order to ensure the file-system is placed in a clean |
450442cf LP |
136 | state quickly after each access.</para></listitem> |
137 | </varlistentry> | |
138 | ||
139 | <varlistentry> | |
140 | <term><option>--type=</option></term> | |
141 | <term><option>-t</option></term> | |
142 | ||
885a4e6c ZJS |
143 | <listitem><para>Specifies the file system type to mount (e.g. <literal>vfat</literal> or |
144 | <literal>ext4</literal>). If omitted or set to <literal>auto</literal>, the file system type is | |
145 | determined automatically.</para></listitem> | |
450442cf LP |
146 | </varlistentry> |
147 | ||
148 | <varlistentry> | |
149 | <term><option>--options=</option></term> | |
150 | <term><option>-o</option></term> | |
151 | ||
152 | <listitem><para>Additional mount options for the mount point.</para></listitem> | |
153 | </varlistentry> | |
154 | ||
e09fc884 ZJS |
155 | <varlistentry> |
156 | <term><option>--owner=<replaceable>USER</replaceable></option></term> | |
157 | ||
158 | <listitem><para>Let the specified user <replaceable>USER</replaceable> own the mounted file system. | |
159 | This is done by appending <option>uid=</option> and <option>gid=</option> options to the list | |
160 | of mount options. Only certain file systems support this option.</para></listitem> | |
161 | </varlistentry> | |
162 | ||
450442cf LP |
163 | <varlistentry> |
164 | <term><option>--fsck=</option></term> | |
165 | ||
166 | <listitem><para>Takes a boolean argument, defaults to on. Controls whether to run a file system check | |
167 | immediately before the mount operation. In the automount case (see <option>--automount=</option> below) the | |
168 | check will be run the moment the first access to the device is made, which might slightly delay the | |
169 | access.</para></listitem> | |
170 | </varlistentry> | |
171 | ||
172 | <varlistentry> | |
173 | <term><option>--description=</option></term> | |
174 | ||
175 | <listitem><para>Provide a description for the mount or automount unit. See <varname>Description=</varname> in | |
176 | <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>. | |
177 | </para></listitem> | |
178 | </varlistentry> | |
179 | ||
180 | <varlistentry> | |
181 | <term><option>--property=</option></term> | |
182 | <term><option>-p</option></term> | |
183 | ||
184 | <listitem><para>Sets a unit property for the mount unit that is created. This takes an assignment in the same | |
185 | format as <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s | |
186 | <command>set-property</command> command.</para> | |
187 | </listitem> | |
188 | </varlistentry> | |
189 | ||
190 | <varlistentry> | |
191 | <term><option>--automount=</option></term> | |
192 | ||
193 | <listitem><para>Takes a boolean argument. Controls whether to create an automount point or a regular mount | |
194 | point. If true an automount point is created that is backed by the actual file system at the time of first | |
195 | access. If false a plain mount point is created that is backed by the actual file system immediately. Automount | |
196 | points have the benefit that the file system stays unmounted and hence in clean state until it is first | |
197 | accessed. In automount mode the <option>--timeout-idle-sec=</option> switch (see below) may be used to ensure | |
198 | the mount point is unmounted automatically after the last access and an idle period passed.</para> | |
199 | ||
200 | <para>If this switch is not specified it defaults to false. If not specified and <option>--discover</option> is | |
201 | used (or only a single argument passed, which implies <option>--discover</option>, see above), and the file | |
202 | system block device is detected to be removable, it is set to true, in order to increase the chance that the | |
203 | file system is in a fully clean state if the device is unplugged abruptly.</para></listitem> | |
204 | </varlistentry> | |
205 | ||
206 | <varlistentry> | |
207 | <term><option>-A</option></term> | |
208 | ||
209 | <listitem><para>Equivalent to <option>--automount=yes</option>.</para></listitem> | |
210 | </varlistentry> | |
211 | ||
212 | <varlistentry> | |
213 | <term><option>--timeout-idle-sec=</option></term> | |
214 | ||
215 | <listitem><para>Takes a time value that controls the idle timeout in automount mode. If set to | |
216 | <literal>infinity</literal> (the default) no automatic unmounts are done. Otherwise the file system backing the | |
217 | automount point is detached after the last access and the idle timeout passed. See | |
218 | <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry> for details on | |
219 | the time syntax supported. This option has no effect if only a regular mount is established, and automounting | |
220 | is not used.</para> | |
221 | ||
222 | <para>Note that if <option>--discover</option> is used (or only a single argument passed, which implies | |
223 | <option>--discover</option>, see above), and the file system block device is detected to be removable, | |
224 | <option>--timeout-idle-sec=1s</option> is implied.</para></listitem> | |
225 | </varlistentry> | |
226 | ||
227 | <varlistentry> | |
228 | <term><option>--automount-property=</option></term> | |
229 | ||
230 | <listitem><para>Similar to <option>--property=</option>, but applies additional properties to the automount | |
231 | unit created, instead of the mount unit.</para></listitem> | |
232 | </varlistentry> | |
233 | ||
234 | <varlistentry> | |
2fc1afca | 235 | <term><option>--bind-device</option></term> |
450442cf | 236 | |
2fc1afca OH |
237 | <listitem><para>This option only has an effect in automount mode, |
238 | and controls whether the automount unit shall be bound to the backing device's lifetime. If set, the | |
381ccb42 | 239 | automount unit will be stopped automatically when the backing device vanishes. By default the automount unit |
450442cf LP |
240 | stays around, and subsequent accesses will block until backing device is replugged. This option has no effect |
241 | in case of non-device mounts, such as network or virtual file system mounts.</para> | |
242 | ||
243 | <para>Note that if <option>--discover</option> is used (or only a single argument passed, which implies | |
244 | <option>--discover</option>, see above), and the file system block device is detected to be removable, this | |
245 | option is implied.</para></listitem> | |
246 | </varlistentry> | |
247 | ||
248 | <varlistentry> | |
249 | <term><option>--list</option></term> | |
250 | ||
251 | <listitem><para>Instead of establishing a mount or automount point, print a terse list of block devices | |
252 | containing file systems that may be mounted with <literal>systemd-mount</literal>, along with useful metadata | |
253 | such as labels, etc.</para></listitem> | |
254 | </varlistentry> | |
255 | ||
d20a328f ZJS |
256 | <varlistentry> |
257 | <term><option>-u</option></term> | |
cec2a20d | 258 | <term><option>--umount</option></term> |
d20a328f ZJS |
259 | |
260 | <listitem><para>Stop the mount and automount units corresponding to the specified mount points | |
9017f5d8 YW |
261 | <replaceable>WHERE</replaceable> or the devices <replaceable>WHAT</replaceable>. |
262 | <command>systemd-mount</command> with this option or <command>systemd-umount</command> can take multiple arguments | |
6f6165bf YW |
263 | which can be mount points, devices, <filename>/etc/fstab</filename> style node names, or backing files |
264 | corresponding to loop devices, like | |
265 | <command>systemd-mount --umount /path/to/umount /dev/sda1 UUID=xxxxxx-xxxx LABEL=xxxxx /path/to/disk.img</command>. | |
3747daa2 YW |
266 | Note that when <option>-H</option> or <option>-M</option> is specified, only absolute paths to mount points are |
267 | supported.</para></listitem> | |
d20a328f ZJS |
268 | </varlistentry> |
269 | ||
dc336483 YW |
270 | <varlistentry> |
271 | <term><option>-G</option></term> | |
272 | <term><option>--collect</option></term> | |
273 | ||
274 | <listitem><para>Unload the transient unit after it completed, even if it failed. Normally, without this option, | |
275 | all mount units that mount and failed are kept in memory until the user explicitly resets their failure state with | |
276 | <command>systemctl reset-failed</command> or an equivalent command. On the other hand, units that stopped | |
277 | successfully are unloaded immediately. If this option is turned on the "garbage collection" of units is more | |
1b2ad5d9 | 278 | aggressive, and unloads units regardless if they exited successfully or failed. This option is a shortcut for |
dc336483 YW |
279 | <command>--property=CollectMode=inactive-or-failed</command>, see the explanation for |
280 | <varname>CollectMode=</varname> in | |
281 | <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry> for further | |
282 | information.</para></listitem> | |
283 | </varlistentry> | |
284 | ||
2322c6c7 LB |
285 | <varlistentry> |
286 | <term><option>-T</option></term> | |
287 | <term><option>--tmpfs</option></term> | |
288 | ||
289 | <listitem> | |
290 | <para>Create and mount a new temporary file system on <replaceable>WHERE</replaceable>, with an | |
291 | optional <replaceable>NAME</replaceable> that defaults to <literal>tmpfs</literal>.</para> | |
292 | </listitem> | |
293 | </varlistentry> | |
294 | ||
450442cf LP |
295 | <xi:include href="user-system-options.xml" xpointer="user" /> |
296 | <xi:include href="user-system-options.xml" xpointer="system" /> | |
297 | <xi:include href="user-system-options.xml" xpointer="host" /> | |
298 | <xi:include href="user-system-options.xml" xpointer="machine" /> | |
299 | ||
300 | <xi:include href="standard-options.xml" xpointer="help" /> | |
301 | <xi:include href="standard-options.xml" xpointer="version" /> | |
302 | </variablelist> | |
303 | ||
304 | </refsect1> | |
305 | ||
306 | <refsect1> | |
307 | <title>Exit status</title> | |
308 | ||
309 | <para>On success, 0 is returned, a non-zero failure | |
310 | code otherwise.</para> | |
311 | </refsect1> | |
312 | ||
313 | <refsect1> | |
314 | <title>The udev Database</title> | |
315 | ||
2dd67817 | 316 | <para>If <option>--discover</option> is used, <command>systemd-mount</command> honors a couple of additional udev |
450442cf LP |
317 | properties of block devices:</para> |
318 | ||
319 | <variablelist class='udev-directives'> | |
320 | <varlistentry> | |
321 | <term><varname>SYSTEMD_MOUNT_OPTIONS=</varname></term> | |
322 | ||
323 | <listitem><para>The mount options to use, if <option>--options=</option> is not used.</para></listitem> | |
324 | </varlistentry> | |
325 | ||
326 | <varlistentry> | |
327 | <term><varname>SYSTEMD_MOUNT_WHERE=</varname></term> | |
328 | ||
329 | <listitem><para>The file system path to place the mount point at, instead of the automatically generated | |
330 | one.</para></listitem> | |
331 | </varlistentry> | |
332 | </variablelist> | |
333 | </refsect1> | |
334 | ||
1e4960b8 LP |
335 | <refsect1> |
336 | <title>Example</title> | |
337 | ||
338 | <para>Use a udev rule like the following to automatically mount all USB storage plugged in:</para> | |
339 | ||
340 | <programlisting>ACTION=="add", SUBSYSTEMS=="usb", SUBSYSTEM=="block", ENV{ID_FS_USAGE}=="filesystem", \ | |
341 | RUN{program}+="/usr/bin/systemd-mount --no-block --automount=yes --collect $devnode"</programlisting> | |
342 | </refsect1> | |
343 | ||
450442cf LP |
344 | <refsect1> |
345 | <title>See Also</title> | |
346 | <para> | |
347 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
98e9d710 | 348 | <citerefentry project='man-pages'><refentrytitle>mount</refentrytitle><manvolnum>8</manvolnum></citerefentry>, |
450442cf LP |
349 | <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>, |
350 | <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
351 | <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
352 | <citerefentry><refentrytitle>systemd.automount</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
353 | <citerefentry><refentrytitle>systemd-run</refentrytitle><manvolnum>1</manvolnum></citerefentry> | |
354 | </para> | |
355 | </refsect1> | |
356 | ||
357 | </refentry> |