Debian Codegraph @

man/systemd-fstab-generator.xml

raw
1 <?xml version="1.0"?>
2 <!--*-nxml-*-->
3 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
4 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
5 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
6 <refentry id="systemd-fstab-generator" xmlns:xi="http://www.w3.org/2001/XInclude">
7
8 <refentryinfo>
9 <title>systemd-fstab-generator</title>
10 <productname>systemd</productname>
11 </refentryinfo>
12
13 <refmeta>
14 <refentrytitle>systemd-fstab-generator</refentrytitle>
15 <manvolnum>8</manvolnum>
16 </refmeta>
17
18 <refnamediv>
19 <refname>systemd-fstab-generator</refname>
20 <refpurpose>Unit generator for /etc/fstab</refpurpose>
21 </refnamediv>
22
23 <refsynopsisdiv>
24 <para><filename>/usr/lib/systemd/system-generators/systemd-fstab-generator</filename></para>
25 </refsynopsisdiv>
26
27 <refsect1>
28 <title>Description</title>
29
30 <para><filename>systemd-fstab-generator</filename> is a generator
31 that translates <filename>/etc/fstab</filename> (see
32 <citerefentry project='man-pages'><refentrytitle>fstab</refentrytitle><manvolnum>5</manvolnum></citerefentry>
33 for details) into native systemd units early at boot and when
34 configuration of the system manager is reloaded. This will
35 instantiate mount and swap units as necessary.</para>
36
37 <para>The <varname>passno</varname> field is treated like a simple
38 boolean, and the ordering information is discarded. However, if
39 the root file system is checked, it is checked before all the
40 other file systems.</para>
41
42 <para>See
43 <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>
44 and
45 <citerefentry><refentrytitle>systemd.swap</refentrytitle><manvolnum>5</manvolnum></citerefentry>
46 for more information about special <filename>/etc/fstab</filename>
47 mount options this generator understands.</para>
48
49 <para>One special topic is handling of symbolic links. Historical init
50 implementations supported symlinks in <filename>/etc/fstab</filename>.
51 Because mount units will refuse mounts where the target is a symbolic link,
52 this generator will resolve any symlinks as far as possible when processing
53 <filename>/etc/fstab</filename> in order to enhance backwards compatibility.
54 If a symlink target does not exist at the time that this generator runs, it
55 is assumed that the symlink target is the final target of the mount.</para>
56
57 <para><filename>systemd-fstab-generator</filename> implements
58 <citerefentry><refentrytitle>systemd.generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para>
59 </refsect1>
60
61 <refsect1>
62 <title>Kernel Command Line</title>
63
64 <para><filename>systemd-fstab-generator</filename> understands the
65 following kernel command line parameters:</para>
66
67 <variablelist class='kernel-commandline-options'>
68
69 <varlistentry>
70 <term><varname>fstab=</varname></term>
71 <term><varname>rd.fstab=</varname></term>
72
73 <listitem><para>Takes a boolean argument. Defaults to <literal>yes</literal>. If
74 <literal>no</literal>, causes the generator to ignore any mounts or swap devices configured in
75 <filename>/etc/fstab</filename>. <varname>rd.fstab=</varname> is honored only in the initrd, while
76 <varname>fstab=</varname> is honored by both the main system and the initrd.</para>
77
78 <xi:include href="version-info.xml" xpointer="v186"/></listitem>
79 </varlistentry>
80
81 <varlistentry>
82 <term><varname>root=</varname></term>
83
84 <listitem><para>Configures the operating system's root filesystem to mount when running in the
85 initrd. This accepts a device node path (usually <filename>/dev/disk/by-uuid/…</filename> or
86 <filename>/dev/disk/by-label/…</filename> or similar), or the special values
87 <literal>gpt-auto</literal>, <literal>gpt-auto-force</literal>, <literal>dissect</literal>,
88 <literal>dissect-force</literal>, <literal>fstab</literal>, <literal>tmpfs</literal>,
89 <literal>bind:…</literal>, and <literal>off</literal>.</para>
90
91 <para>Set to <literal>gpt-auto</literal>, <literal>gpt-auto-force</literal>,
92 <literal>dissect</literal>, <literal>dissect-force</literal> to explicitly request automatic root
93 file system discovery, implemented in
94 <citerefentry><refentrytitle>systemd-gpt-auto-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
95
96 <para>Use <literal>fstab</literal> to explicitly request automatic root file system discovery via
97 the initrd <filename>/etc/fstab</filename> rather than via kernel command line.</para>
98
99 <para>Use <literal>tmpfs</literal> in order to mount a <citerefentry
100 project='man-pages'><refentrytitle>tmpfs</refentrytitle><manvolnum>5</manvolnum></citerefentry> file
101 system as root file system of the OS. This is useful in combination with
102 <varname>mount.usr=</varname> (see below) in order to combine a volatile root file system with a
103 separate, immutable <filename>/usr/</filename> file system. Also see
104 <varname>systemd.volatile=</varname> below.</para>
105
106 <para>Use <literal>bind:…</literal> to bind mount another directory as operating system root
107 filesystems (added in v258). Expects an absolute path name referencing an existing directory within the initrd's file
108 hierarchy to boot into. Since the resulting root file system is supposed to behave like a regular OS
109 root, the bind mount is established with the <option>dev</option>, <option>suid</option> and
110 <option>exec</option> options (i.e. the <option>nodev</option>, <option>nosuid</option> and
111 <option>noexec</option> flags that would otherwise be inherited from the file system the source
112 directory resides on, such as <filename>/run/</filename>, are cleared), unless overridden via
113 <varname>rootflags=</varname>.</para>
114
115 <para>Set to <literal>off</literal> to turn off mounting of a root file system.</para>
116
117 <para>Note that further <varname>root=</varname> values may be supported, implemented in additional
118 packages.</para>
119
120 <xi:include href="version-info.xml" xpointer="v217"/></listitem>
121 </varlistentry>
122
123 <varlistentry>
124 <term><varname>rootfstype=</varname></term>
125
126 <listitem><para>Takes the root filesystem type that will be
127 passed to the mount command. <varname>rootfstype=</varname> is
128 honored by the initrd.</para>
129
130 <xi:include href="version-info.xml" xpointer="v217"/></listitem>
131 </varlistentry>
132
133 <varlistentry>
134 <term><varname>rootflags=</varname></term>
135
136 <listitem><para>Takes the root filesystem mount options to use. <varname>rootflags=</varname> is
137 honored by the initrd.</para>
138
139 <para>Note that unlike most kernel command line options this setting does not override settings made
140 in configuration files (specifically: the mount option string in
141 <filename>/etc/fstab</filename>). See
142 <citerefentry><refentrytitle>systemd-remount-fs.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
143
144 <xi:include href="version-info.xml" xpointer="v217"/></listitem>
145 </varlistentry>
146
147 <varlistentry>
148 <term><varname>mount.usr=</varname></term>
149
150 <listitem><para>Takes the <filename>/usr/</filename> filesystem to be mounted by the initrd. If
151 <varname>mount.usrfstype=</varname> or <varname>mount.usrflags=</varname> is set, then the mount
152 configured via <varname>mount.usr=</varname> will default to the the same value set in
153 <varname>root=</varname>.</para>
154
155 <para>Set to <literal>dissect</literal> to explicitly request automatic <filename>/usr/</filename>
156 file system discovery, implemented in
157 <citerefentry><refentrytitle>systemd-gpt-auto-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
158
159 <para>Set to <literal>off</literal> to turn off mounting of a separate <filename>/usr/</filename> file system.</para>
160
161 <para><varname>mount.usr=</varname> is honored by the initrd.</para>
162 <xi:include href="version-info.xml" xpointer="v217"/></listitem>
163 </varlistentry>
164
165 <varlistentry>
166 <term><varname>mount.usrfstype=</varname></term>
167
168 <listitem><para>Takes the <filename>/usr/</filename> filesystem
169 type that will be passed to the mount command. If
170 <varname>mount.usr=</varname> or
171 <varname>mount.usrflags=</varname> is set, then
172 <varname>mount.usrfstype=</varname> will default to the value
173 set in <varname>rootfstype=</varname>.</para>
174
175 <para>Otherwise, this value will be read from the
176 <filename>/usr/</filename> entry in
177 <filename>/etc/fstab</filename> on the root filesystem.</para>
178
179 <para><varname>mount.usrfstype=</varname> is honored by the
180 initrd.</para>
181
182 <xi:include href="version-info.xml" xpointer="v217"/></listitem>
183 </varlistentry>
184
185 <varlistentry>
186 <term><varname>mount.usrflags=</varname></term>
187
188 <listitem><para>Takes the <filename>/usr/</filename> filesystem
189 mount options to use. If <varname>mount.usr=</varname> or
190 <varname>mount.usrfstype=</varname> is set, then
191 <varname>mount.usrflags=</varname> will default to the value
192 set in <varname>rootflags=</varname>.</para>
193
194 <para>Otherwise, this value will be read from the
195 <filename>/usr/</filename> entry in
196 <filename>/etc/fstab</filename> on the root filesystem.</para>
197
198 <para><varname>mount.usrflags=</varname> is honored by the
199 initrd.</para>
200
201 <xi:include href="version-info.xml" xpointer="v217"/></listitem>
202 </varlistentry>
203
204 <varlistentry>
205 <term><varname>roothash=</varname></term>
206 <term><varname>usrhash=</varname></term>
207
208 <listitem><para>These options are primarily read by
209 <citerefentry><refentrytitle>systemd-veritysetup-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>. When
210 set this indicates that the root file system (or <filename>/usr/</filename>) shall be mounted from
211 Verity volumes with the specified hashes. If these kernel command line options are set the root (or
212 <filename>/usr/</filename>) file system is thus mounted from a device mapper volume
213 <filename>/dev/mapper/root</filename> (or <filename>/dev/mapper/usr</filename>).</para>
214
215 <xi:include href="version-info.xml" xpointer="v251"/></listitem>
216 </varlistentry>
217
218 <varlistentry>
219 <term><varname>systemd.volatile=</varname></term>
220
221 <listitem><para>Controls whether the system shall boot up in volatile mode. Takes a boolean argument or the
222 special values <literal>state</literal> and <literal>overlay</literal>.</para>
223
224 <para>If <literal>no</literal> (the default), this generator makes no changes to the mount tree and the system
225 is booted up in normal mode.</para>
226
227 <para>If <literal>yes</literal> the generator ensures
228 <citerefentry><refentrytitle>systemd-volatile-root.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
229 is run in the initrd. This service changes the mount table before transitioning to the host system,
230 so that a volatile memory file system (<literal>tmpfs</literal>) is used as root directory, with only
231 <filename>/usr/</filename> mounted into it from the configured root file system, in read-only mode.
232 This way the system operates in fully stateless mode, with all configuration and state reset at boot
233 and lost at shutdown, as <filename>/etc/</filename> and <filename>/var/</filename> will be served
234 from the (initially unpopulated) volatile memory file system.</para>
235
236 <para>If set to <literal>state</literal> the generator will leave the root directory mount point unaltered,
237 however will mount a <literal>tmpfs</literal> file system to <filename>/var/</filename>. In this mode the normal
238 system configuration (i.e. the contents of <literal>/etc/</literal>) is in effect (and may be modified during
239 system runtime), however the system state (i.e. the contents of <literal>/var/</literal>) is reset at boot and
240 lost at shutdown.</para>
241
242 <para>If this setting is set to <literal>overlay</literal> the root file system is set up as
243 <literal>overlayfs</literal> mount combining the read-only root directory with a writable
244 <literal>tmpfs</literal>, so that no modifications are made to disk, but the file system may be modified
245 nonetheless with all changes being lost at reboot.</para>
246
247 <para>Note that in none of these modes the root directory, <filename>/etc/</filename>, <filename>/var/</filename>
248 or any other resources stored in the root file system are physically removed. It's thus safe to boot a system
249 that is normally operated in non-volatile mode temporarily into volatile mode, without losing data.</para>
250
251 <para>Note that with the exception of <literal>overlay</literal> mode, enabling this setting will
252 only work correctly on operating systems that can boot up with only <filename>/usr/</filename>
253 mounted, and are able to automatically populate <filename>/etc/</filename>, and also
254 <filename>/var/</filename> in case of <literal>systemd.volatile=yes</literal>.</para>
255
256 <para>Also see <varname>root=tmpfs</varname> above, for a method to combine a
257 <literal>tmpfs</literal> file system with a regular <filename>/usr/</filename> file system (as
258 configured via <varname>mount.usr=</varname>). The main distinction between
259 <varname>systemd.volatile=yes</varname>, and <varname>root=tmpfs</varname> in combination
260 <varname>mount.usr=</varname> is that the former operates on top of a regular root file system and
261 temporarily obstructs the files and directories above its <filename>/usr/</filename> subdirectory,
262 while the latter does not hide any files, but simply mounts a unpopulated tmpfs as root file system
263 and combines it with a user picked <filename>/usr/</filename> file system.</para>
264
265 <xi:include href="version-info.xml" xpointer="v233"/></listitem>
266 </varlistentry>
267
268 <varlistentry>
269 <term><varname>systemd.swap=</varname></term>
270
271 <listitem><para>Takes a boolean argument or enables the option if specified
272 without an argument. If disabled, causes the generator to ignore
273 any swap devices configured in <filename>/etc/fstab</filename>.
274 Defaults to enabled.</para>
275
276 <xi:include href="version-info.xml" xpointer="v246"/></listitem>
277 </varlistentry>
278
279 <varlistentry>
280 <term><varname>systemd.mount-extra=<replaceable>WHAT</replaceable>:<replaceable>WHERE</replaceable>[:<replaceable>FSTYPE</replaceable>[:<replaceable>OPTIONS</replaceable>]]</varname></term>
281 <term><varname>rd.systemd.mount-extra=<replaceable>WHAT</replaceable>:<replaceable>WHERE</replaceable>[:<replaceable>FSTYPE</replaceable>[:<replaceable>OPTIONS</replaceable>]]</varname></term>
282
283 <listitem>
284 <para>Specifies the mount unit. Takes at least two and at most four fields separated with a colon
285 (<literal>:</literal>). Each field is handled as the corresponding fstab field. This option can be
286 specified multiple times. <varname>rd.systemd.mount-extra=</varname> is honored only in the initrd,
287 while <varname>systemd.mount-extra=</varname> is honored by both the main system and the initrd.
288 In the initrd, the mount point (and also source path if the mount is bind mount) specified in
289 <varname>systemd.mount-extra=</varname> is prefixed with <filename>/sysroot/</filename>.</para>
290 <para>Example:
291 <programlisting>
292 systemd.mount-extra=/dev/sda1:/mount-point:ext4:rw,noatime</programlisting>
293 </para>
294
295 <xi:include href="version-info.xml" xpointer="v254"/>
296 </listitem>
297 </varlistentry>
298
299 <varlistentry>
300 <term><varname>systemd.swap-extra=<replaceable>WHAT</replaceable>[:<replaceable>OPTIONS</replaceable>]</varname></term>
301 <term><varname>rd.systemd.swap-extra=<replaceable>WHAT</replaceable>[:<replaceable>OPTIONS</replaceable>]</varname></term>
302
303 <listitem>
304 <para>Specifies the swap unit. Takes the block device to be used as a swap device, and optionally
305 takes mount options followed by a colon (<literal>:</literal>). This option can be specified
306 multiple times. <varname>rd.systemd.swap-extra=</varname> is honored only in the initrd, while
307 <varname>systemd.swap-extra=</varname> is honored by both the main system and the initrd.</para>
308 <para>Example:
309 <programlisting>
310 systemd.swap-extra=/dev/sda2:x-systemd.makefs</programlisting>
311 </para>
312
313 <xi:include href="version-info.xml" xpointer="v254"/>
314 </listitem>
315 </varlistentry>
316 </variablelist>
317 </refsect1>
318
319 <refsect1>
320 <title>System Credentials</title>
321
322 <variablelist class='system-credentials'>
323 <varlistentry>
324 <term><varname>fstab.extra</varname></term>
325
326 <listitem><para>This credential may contain addition mounts to establish, in the same format as
327 <citerefentry
328 project='man-pages'><refentrytitle>fstab</refentrytitle><manvolnum>5</manvolnum></citerefentry>, with
329 one mount per line. It is read in addition to <filename>/etc/fstab</filename>.</para>
330
331 <xi:include href="version-info.xml" xpointer="v254"/></listitem>
332 </varlistentry>
333 </variablelist>
334 </refsect1>
335
336 <refsect1>
337 <title>See Also</title>
338 <para><simplelist type="inline">
339 <member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
340 <member><citerefentry project='man-pages'><refentrytitle>fstab</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
341 <member><citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
342 <member><citerefentry><refentrytitle>systemd.swap</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
343 <member><citerefentry><refentrytitle>systemd-cryptsetup-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
344 <member><citerefentry><refentrytitle>systemd-gpt-auto-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
345 <member><citerefentry><refentrytitle>kernel-command-line</refentrytitle><manvolnum>7</manvolnum></citerefentry></member>
346 <member><ulink url="https://systemd.io/ENVIRONMENT/">Known Environment Variables</ulink></member>
347 </simplelist></para>
348 </refsect1>
349 </refentry>