summaryrefslogtreecommitdiff
path: root/man/systemd-mount.xml
blob: e25d5c435e95a29166bb85692339870c39f68d47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
<?xml version='1.0'?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->

<refentry id="systemd-mount"
          xmlns:xi="http://www.w3.org/2001/XInclude">

  <refentryinfo>
    <title>systemd-mount</title>
    <productname>systemd</productname>
  </refentryinfo>

  <refmeta>
    <refentrytitle>systemd-mount</refentrytitle>
    <manvolnum>1</manvolnum>
  </refmeta>

  <refnamediv>
    <refname>systemd-mount</refname>
    <refname>systemd-umount</refname>
    <refpurpose>Establish and destroy transient mount or auto-mount points</refpurpose>
  </refnamediv>

  <refsynopsisdiv>
    <cmdsynopsis>
      <command>systemd-mount</command>
      <arg choice="opt" rep="repeat"><replaceable>OPTIONS</replaceable></arg>
      <arg choice="plain"><replaceable>WHAT</replaceable></arg>
      <arg choice="opt"><replaceable>WHERE</replaceable></arg>
    </cmdsynopsis>
    <cmdsynopsis>
      <command>systemd-mount</command>
      <arg choice="opt" rep="repeat"><replaceable>OPTIONS</replaceable></arg>
      <arg choice="plain"><option>--list</option></arg>
    </cmdsynopsis>
    <cmdsynopsis>
      <command>systemd-mount</command>
      <arg choice="opt" rep="repeat"><replaceable>OPTIONS</replaceable></arg>
      <arg choice="plain"><option>--umount</option></arg>
      <arg choice="plain" rep="repeat"><replaceable>WHAT|WHERE</replaceable></arg>
    </cmdsynopsis>
  </refsynopsisdiv>

  <refsect1>
    <title>Description</title>

    <para><command>systemd-mount</command> may be used to create and start a transient <filename>.mount</filename> or
    <filename>.automount</filename> unit of the file system <replaceable>WHAT</replaceable> on the mount point
    <replaceable>WHERE</replaceable>.</para>

    <para>In many ways, <command>systemd-mount</command> is similar to the lower-level
    <citerefentry project='man-pages'><refentrytitle>mount</refentrytitle><manvolnum>8</manvolnum></citerefentry>
    command, however instead of executing the mount operation directly and immediately,
    <command>systemd-mount</command> schedules it through the service manager job queue, so that it may pull
    in further dependencies (such as parent mounts, or a file system checker to execute a priori), and may
    make use of the auto-mounting logic.</para>

    <para>The command takes either one or two arguments. If only one argument is specified it should refer to
    a block device or regular file containing a file system (e.g. <literal>/dev/sdb1</literal> or
    <literal>/path/to/disk.img</literal>). The block device or image file is then probed for a file system
    label and other metadata, and is mounted to a directory below <filename>/run/media/system/</filename>
    whose name is generated from the file system label. In this mode the block device or image file must
    exist at the time of invocation of the command, so that it may be probed. If the device is found to be a
    removable block device (e.g. a USB stick), an automount point is created instead of a regular mount point
    (i.e. the <option>--automount=</option> option is implied, see below).</para>

    <para>If two arguments are specified, the first indicates the mount source (the
    <replaceable>WHAT</replaceable>) and the second indicates the path to mount it on (the
    <replaceable>WHERE</replaceable>). In this mode no probing of the source is attempted, and a backing
    device node doesn't have to exist. However, if this mode is combined with <option>--discover</option>,
    device node probing for additional metadata is enabled, and – much like in the single-argument case
    discussed above – the specified device has to exist at the time of invocation of the command.</para>

    <para>Use the <option>--list</option> command to show a terse table of all local, known block devices with file
    systems that may be mounted with this command.</para>

    <para><command>systemd-umount</command> can be used to unmount a mount or automount point. It is the same
    as <command>systemd-mount</command> <option>--umount</option>.</para>
  </refsect1>

  <refsect1>
    <title>Options</title>

    <para>The following options are understood:</para>

    <variablelist>

      <varlistentry>
        <term><option>--no-block</option></term>

        <listitem>
          <para>Do not synchronously wait for the requested operation to finish. If this is not specified, the job will
          be verified, enqueued and <command>systemd-mount</command> will wait until the mount or automount unit's
          start-up is completed. By passing this argument, it is only verified and enqueued.</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><option>-l</option></term>
        <term><option>--full</option></term>

        <listitem>
          <para>Do not ellipsize the output when <option>--list</option> is specified.</para>
        </listitem>
      </varlistentry>

      <xi:include href="standard-options.xml" xpointer="no-pager"/>
      <xi:include href="standard-options.xml" xpointer="no-legend" />
      <xi:include href="standard-options.xml" xpointer="no-ask-password"/>

      <varlistentry>
        <term><option>--quiet</option></term>
        <term><option>-q</option></term>

        <listitem><para>Suppresses additional informational output while running.</para></listitem>
      </varlistentry>

      <varlistentry>
        <term><option>--discover</option></term>

        <listitem><para>Enable probing of the mount source. This switch is implied if a single argument is specified on
        the command line. If passed, additional metadata is read from the device to enhance the unit to create. For
        example, a descriptive string for the transient units is generated from the file system label and device
        model. Moreover if a removable block device (e.g. USB stick) is detected an automount unit instead of a regular
        mount unit is created, with a short idle timeout, in order to ensure the file-system is placed in a clean
        state quickly after each access.</para></listitem>
      </varlistentry>

      <varlistentry>
        <term><option>--type=</option></term>
        <term><option>-t</option></term>

        <listitem><para>Specifies the file system type to mount (e.g. <literal>vfat</literal> or
        <literal>ext4</literal>). If omitted or set to <literal>auto</literal>, the file system type is
        determined automatically.</para></listitem>
      </varlistentry>

      <varlistentry>
        <term><option>--options=</option></term>
        <term><option>-o</option></term>

        <listitem><para>Additional mount options for the mount point.</para></listitem>
      </varlistentry>

      <varlistentry>
        <term><option>--owner=<replaceable>USER</replaceable></option></term>

        <listitem><para>Let the specified user <replaceable>USER</replaceable> own the mounted file system.
        This is done by appending <option>uid=</option> and <option>gid=</option> options to the list
        of mount options. Only certain file systems support this option.</para></listitem>
      </varlistentry>

      <varlistentry>
        <term><option>--fsck=</option></term>

        <listitem><para>Takes a boolean argument, defaults to on. Controls whether to run a file system check
        immediately before the mount operation. In the automount case (see <option>--automount=</option> below) the
        check will be run the moment the first access to the device is made, which might slightly delay the
        access.</para></listitem>
      </varlistentry>

      <varlistentry>
        <term><option>--description=</option></term>

        <listitem><para>Provide a description for the mount or automount unit. See <varname>Description=</varname> in
        <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
        </para></listitem>
      </varlistentry>

      <varlistentry>
        <term><option>--property=</option></term>
        <term><option>-p</option></term>

        <listitem><para>Sets a unit property for the mount unit that is created. This takes an assignment in the same
        format as <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s
        <command>set-property</command> command.</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><option>--automount=</option></term>

        <listitem><para>Takes a boolean argument. Controls whether to create an automount point or a regular mount
        point. If true an automount point is created that is backed by the actual file system at the time of first
        access. If false a plain mount point is created that is backed by the actual file system immediately. Automount
        points have the benefit that the file system stays unmounted and hence in clean state until it is first
        accessed. In automount mode the <option>--timeout-idle-sec=</option> switch (see below) may be used to ensure
        the mount point is unmounted automatically after the last access and an idle period passed.</para>

        <para>If this switch is not specified it defaults to false. If not specified and <option>--discover</option> is
        used (or only a single argument passed, which implies <option>--discover</option>, see above), and the file
        system block device is detected to be removable, it is set to true, in order to increase the chance that the
        file system is in a fully clean state if the device is unplugged abruptly.</para></listitem>
      </varlistentry>

      <varlistentry>
        <term><option>-A</option></term>

        <listitem><para>Equivalent to <option>--automount=yes</option>.</para></listitem>
      </varlistentry>

      <varlistentry>
        <term><option>--timeout-idle-sec=</option></term>

        <listitem><para>Takes a time value that controls the idle timeout in automount mode. If set to
        <literal>infinity</literal> (the default) no automatic unmounts are done. Otherwise the file system backing the
        automount point is detached after the last access and the idle timeout passed. See
        <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry> for details on
        the time syntax supported. This option has no effect if only a regular mount is established, and automounting
        is not used.</para>

        <para>Note that if <option>--discover</option> is used (or only a single argument passed, which implies
        <option>--discover</option>, see above), and the file system block device is detected to be removable,
        <option>--timeout-idle-sec=1s</option> is implied.</para></listitem>
      </varlistentry>

      <varlistentry>
        <term><option>--automount-property=</option></term>

        <listitem><para>Similar to <option>--property=</option>, but applies additional properties to the automount
        unit created, instead of the mount unit.</para></listitem>
      </varlistentry>

      <varlistentry>
        <term><option>--bind-device</option></term>

        <listitem><para>This option only has an effect in automount mode,
        and controls whether the automount unit shall be bound to the backing device's lifetime. If set, the
        automount unit will be stopped automatically when the backing device vanishes. By default the automount unit
        stays around, and subsequent accesses will block until backing device is replugged. This option has no effect
        in case of non-device mounts, such as network or virtual file system mounts.</para>

        <para>Note that if <option>--discover</option> is used (or only a single argument passed, which implies
        <option>--discover</option>, see above), and the file system block device is detected to be removable, this
        option is implied.</para></listitem>
      </varlistentry>

      <varlistentry>
        <term><option>--list</option></term>

        <listitem><para>Instead of establishing a mount or automount point, print a terse list of block devices
        containing file systems that may be mounted with <literal>systemd-mount</literal>, along with useful metadata
        such as labels, etc.</para></listitem>
      </varlistentry>

      <varlistentry>
        <term><option>-u</option></term>
        <term><option>--umount</option></term>

        <listitem><para>Stop the mount and automount units corresponding to the specified mount points
        <replaceable>WHERE</replaceable> or the devices <replaceable>WHAT</replaceable>.
        <command>systemd-mount</command> with this option or <command>systemd-umount</command> can take multiple arguments
        which can be mount points, devices, <filename>/etc/fstab</filename> style node names, or backing files
        corresponding to loop devices, like
        <command>systemd-mount --umount /path/to/umount /dev/sda1 UUID=xxxxxx-xxxx LABEL=xxxxx /path/to/disk.img</command>.
        Note that when <option>-H</option> or <option>-M</option> is specified, only absolute paths to mount points are
        supported.</para></listitem>
      </varlistentry>

      <varlistentry>
        <term><option>-G</option></term>
        <term><option>--collect</option></term>

        <listitem><para>Unload the transient unit after it completed, even if it failed. Normally, without this option,
        all mount units that mount and failed are kept in memory until the user explicitly resets their failure state with
        <command>systemctl reset-failed</command> or an equivalent command. On the other hand, units that stopped
        successfully are unloaded immediately. If this option is turned on the "garbage collection" of units is more
        aggressive, and unloads units regardless if they exited successfully or failed. This option is a shortcut for
        <command>--property=CollectMode=inactive-or-failed</command>, see the explanation for
        <varname>CollectMode=</varname> in
        <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry> for further
        information.</para></listitem>
      </varlistentry>

      <xi:include href="user-system-options.xml" xpointer="user" />
      <xi:include href="user-system-options.xml" xpointer="system" />
      <xi:include href="user-system-options.xml" xpointer="host" />
      <xi:include href="user-system-options.xml" xpointer="machine" />

      <xi:include href="standard-options.xml" xpointer="help" />
      <xi:include href="standard-options.xml" xpointer="version" />
    </variablelist>

  </refsect1>

  <refsect1>
    <title>Exit status</title>

    <para>On success, 0 is returned, a non-zero failure
    code otherwise.</para>
  </refsect1>

  <refsect1>
    <title>The udev Database</title>

    <para>If <option>--discover</option> is used, <command>systemd-mount</command> honors a couple of additional udev
    properties of block devices:</para>

    <variablelist class='udev-directives'>
      <varlistentry>
        <term><varname>SYSTEMD_MOUNT_OPTIONS=</varname></term>

        <listitem><para>The mount options to use, if <option>--options=</option> is not used.</para></listitem>
      </varlistentry>

      <varlistentry>
        <term><varname>SYSTEMD_MOUNT_WHERE=</varname></term>

        <listitem><para>The file system path to place the mount point at, instead of the automatically generated
        one.</para></listitem>
      </varlistentry>
    </variablelist>
  </refsect1>

  <refsect1>
    <title>Example</title>

    <para>Use a udev rule like the following to automatically mount all USB storage plugged in:</para>

    <programlisting>ACTION=="add", SUBSYSTEMS=="usb", SUBSYSTEM=="block", ENV{ID_FS_USAGE}=="filesystem", \
        RUN{program}+="/usr/bin/systemd-mount --no-block --automount=yes --collect $devnode"</programlisting>
  </refsect1>

  <refsect1>
    <title>See Also</title>
    <para>
      <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
      <citerefentry project='man-pages'><refentrytitle>mount</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
      <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
      <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
      <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
      <citerefentry><refentrytitle>systemd.automount</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
      <citerefentry><refentrytitle>systemd-run</refentrytitle><manvolnum>1</manvolnum></citerefentry>
    </para>
  </refsect1>

</refentry>