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