]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/crypttab.xml
virt: detect WSL environment as a container (id: wsl)
[thirdparty/systemd.git] / man / crypttab.xml
CommitLineData
45ae1a05
LP
1<?xml version="1.0"?>
2<!--*-nxml-*-->
12b42c76 3<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
45ae1a05 4<!--
572eb058
ZJS
5 SPDX-License-Identifier: LGPL-2.1+
6
45ae1a05
LP
7 This is based on crypttab(5) from Fedora's initscripts package, which in
8 turn is based on Debian's version.
9
10 The Red Hat version has been written by Miloslav Trmac <mitr@redhat.com>.
45ae1a05 11-->
56ba3c78 12<refentry id="crypttab" conditional='HAVE_LIBCRYPTSETUP'>
45ae1a05 13
798d3a52
ZJS
14 <refentryinfo>
15 <title>crypttab</title>
16 <productname>systemd</productname>
798d3a52
ZJS
17 </refentryinfo>
18
19 <refmeta>
20 <refentrytitle>crypttab</refentrytitle>
21 <manvolnum>5</manvolnum>
22 </refmeta>
23
24 <refnamediv>
25 <refname>crypttab</refname>
26 <refpurpose>Configuration for encrypted block devices</refpurpose>
27 </refnamediv>
28
29 <refsynopsisdiv>
30 <para><filename>/etc/crypttab</filename></para>
31 </refsynopsisdiv>
32
33 <refsect1>
34 <title>Description</title>
35
36 <para>The <filename>/etc/crypttab</filename> file describes
37 encrypted block devices that are set up during system boot.</para>
38
39 <para>Empty lines and lines starting with the <literal>#</literal>
40 character are ignored. Each of the remaining lines describes one
ed3657d5 41 encrypted block device. Fields are delimited by white space.</para>
b2a1a5c7
ZJS
42
43 <para>Each line is in the form<programlisting><replaceable>name</replaceable> <replaceable>encrypted-device</replaceable> <replaceable>password</replaceable> <replaceable>options</replaceable></programlisting>
44 The first two fields are mandatory, the remaining two are
798d3a52
ZJS
45 optional.</para>
46
47 <para>Setting up encrypted block devices using this file supports
48 three encryption modes: LUKS, TrueCrypt and plain. See
3ba3a79d 49 <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
798d3a52
ZJS
50 for more information about each mode. When no mode is specified in
51 the options field and the block device contains a LUKS signature,
52 it is opened as a LUKS device; otherwise, it is assumed to be in
53 raw dm-crypt (plain mode) format.</para>
54
55 <para>The first field contains the name of the resulting encrypted
56 block device; the device is set up within
57 <filename>/dev/mapper/</filename>.</para>
58
59 <para>The second field contains a path to the underlying block
60 device or file, or a specification of a block device via
61 <literal>UUID=</literal> followed by the UUID.</para>
62
63 <para>The third field specifies the encryption password. If the
64 field is not present or the password is set to
65 <literal>none</literal> or <literal>-</literal>, the password has
66 to be manually entered during system boot. Otherwise, the field is
037a3ded 67 interpreted as an absolute path to a file containing the encryption
798d3a52
ZJS
68 password. For swap encryption, <filename>/dev/urandom</filename>
69 or the hardware device <filename>/dev/hw_random</filename> can be
70 used as the password file; using <filename>/dev/random</filename>
71 may prevent boot completion if the system does not have enough
72 entropy to generate a truly random encryption key.</para>
73
74 <para>The fourth field, if present, is a comma-delimited list of
75 options. The following options are recognized:</para>
76
77 <variablelist class='fstab-options'>
78
798d3a52
ZJS
79 <varlistentry>
80 <term><option>cipher=</option></term>
81
82 <listitem><para>Specifies the cipher to use. See
3ba3a79d 83 <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
798d3a52
ZJS
84 for possible values and the default value of this option. A
85 cipher with unpredictable IV values, such as
86 <literal>aes-cbc-essiv:sha256</literal>, is
87 recommended.</para></listitem>
88 </varlistentry>
89
ed3657d5
ZJS
90 <varlistentry>
91 <term><option>discard</option></term>
92
93 <listitem><para>Allow discard requests to be passed through the encrypted block
94 device. This improves performance on SSD storage but has security implications.
95 </para></listitem>
96 </varlistentry>
97
798d3a52
ZJS
98 <varlistentry>
99 <term><option>hash=</option></term>
100
101 <listitem><para>Specifies the hash to use for password
102 hashing. See
3ba3a79d 103 <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
798d3a52
ZJS
104 for possible values and the default value of this
105 option.</para></listitem>
106 </varlistentry>
107
108 <varlistentry>
109 <term><option>header=</option></term>
110
111 <listitem><para>Use a detached (separated) metadata device or
112 file where the LUKS header is stored. This option is only
113 relevant for LUKS devices. See
3ba3a79d 114 <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
798d3a52
ZJS
115 for possible values and the default value of this
116 option.</para></listitem>
117 </varlistentry>
118
119 <varlistentry>
120 <term><option>keyfile-offset=</option></term>
121
122 <listitem><para>Specifies the number of bytes to skip at the
123 start of the key file. See
3ba3a79d 124 <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
798d3a52
ZJS
125 for possible values and the default value of this
126 option.</para></listitem>
127 </varlistentry>
128
129 <varlistentry>
130 <term><option>keyfile-size=</option></term>
131
132 <listitem><para>Specifies the maximum number of bytes to read
133 from the key file. See
3ba3a79d 134 <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
798d3a52
ZJS
135 for possible values and the default value of this option. This
136 option is ignored in plain encryption mode, as the key file
137 size is then given by the key size.</para></listitem>
138 </varlistentry>
139
140 <varlistentry>
141 <term><option>key-slot=</option></term>
142
143 <listitem><para>Specifies the key slot to compare the
144 passphrase or key against. If the key slot does not match the
145 given passphrase or key, but another would, the setup of the
146 device will fail regardless. This option implies
147 <option>luks</option>. See
3ba3a79d 148 <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
798d3a52
ZJS
149 for possible values. The default is to try all key slots in
150 sequential order.</para></listitem>
151 </varlistentry>
152
153 <varlistentry>
154 <term><option>luks</option></term>
155
156 <listitem><para>Force LUKS mode. When this mode is used, the
157 following options are ignored since they are provided by the
158 LUKS header on the device: <option>cipher=</option>,
159 <option>hash=</option>,
160 <option>size=</option>.</para></listitem>
161 </varlistentry>
162
b001ad61
ZJS
163 <varlistentry>
164 <term><option>_netdev</option></term>
165
166 <listitem><para>Marks this cryptsetup device as requiring network. It will be
167 started after the network is available, similarly to
168 <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>
169 units marked with <option>_netdev</option>. The service unit to set up this device
a0dd2097 170 will be ordered between <filename>remote-fs-pre.target</filename> and
b001ad61
ZJS
171 <filename>remote-cryptsetup.target</filename>, instead of
172 <filename>cryptsetup-pre.target</filename> and
288c2616
ZJS
173 <filename>cryptsetup.target</filename>.</para>
174
175 <para>Hint: if this device is used for a mount point that is specified in
176 <citerefentry project='man-pages'><refentrytitle>fstab</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
177 the <option>_netdev</option> option should also be used for the mount
178 point. Otherwise, a dependency loop might be created where the mount point
179 will be pulled in by <filename>local-fs.target</filename>, while the
180 service to configure the network is usually only started <emphasis>after</emphasis>
181 the local file system has been mounted.</para>
182 </listitem>
b001ad61
ZJS
183 </varlistentry>
184
798d3a52
ZJS
185 <varlistentry>
186 <term><option>noauto</option></term>
187
5d0e4851
ZJS
188 <listitem><para>This device will not be added to <filename>cryptsetup.target</filename>.
189 This means that it will not be automatically unlocked on boot, unless something else pulls
190 it in. In particular, if the device is used for a mount point, it'll be unlocked
191 automatically during boot, unless the mount point itself is also disabled with
192 <option>noauto</option>.</para></listitem>
798d3a52
ZJS
193 </varlistentry>
194
195 <varlistentry>
196 <term><option>nofail</option></term>
197
5d0e4851
ZJS
198 <listitem><para>This device will not be a hard dependency of
199 <filename>cryptsetup.target</filename>. It'll be still pulled in and started, but the system
200 will not wait for the device to show up and be unlocked, and boot will not fail if this is
201 unsuccessful. Note that other units that depend on the unlocked device may still fail. In
202 particular, if the device is used for a mount point, the mount point itself is also needs to
203 have <option>noauto</option> option, or the boot will fail if the device is not unlocked
204 successfully.</para></listitem>
798d3a52
ZJS
205 </varlistentry>
206
ed3657d5
ZJS
207 <varlistentry>
208 <term><option>offset=</option></term>
209
210 <listitem><para>Start offset in the backend device, in 512-byte sectors. This
211 option is only relevant for plain devices.</para></listitem>
212 </varlistentry>
213
798d3a52
ZJS
214 <varlistentry>
215 <term><option>plain</option></term>
216
217 <listitem><para>Force plain encryption mode.</para></listitem>
218 </varlistentry>
219
220 <varlistentry>
221 <term><option>read-only</option></term><term><option>readonly</option></term>
222
223 <listitem><para>Set up the encrypted block device in read-only
224 mode.</para></listitem>
225 </varlistentry>
226
2c65512e
YW
227 <varlistentry>
228 <term><option>same-cpu-crypt</option></term>
229
230 <listitem><para>Perform encryption using the same cpu that IO was submitted on. The default is to use
231 an unbound workqueue so that encryption work is automatically balanced between available CPUs.</para>
232 <para>This requires kernel 4.0 or newer.</para>
233 </listitem>
234 </varlistentry>
235
236 <varlistentry>
237 <term><option>submit-from-crypt-cpus</option></term>
238
239 <listitem><para>Disable offloading writes to a separate thread after encryption. There are some
240 situations where offloading write bios from the encryption threads to a single thread degrades
241 performance significantly. The default is to offload write bios to the same thread because it benefits
242 CFQ to have writes submitted using the same context.</para>
243 <para>This requires kernel 4.0 or newer.</para>
244 </listitem>
245 </varlistentry>
246
ed3657d5
ZJS
247 <varlistentry>
248 <term><option>skip=</option></term>
249
250 <listitem><para>How many 512-byte sectors of the encrypted data to skip at the
251 beginning. This is different from the <option>offset=</option> option with respect
252 to the sector numbers used in initialization vector (IV) calculation. Using
253 <option>offset=</option> will shift the IV calculation by the same negative
254 amount. Hence, if <option>offset=<replaceable>n</replaceable></option> is given,
255 sector <replaceable>n</replaceable> will get a sector number of 0 for the IV
256 calculation. Using <option>skip=</option> causes sector
257 <replaceable>n</replaceable> to also be the first sector of the mapped device, but
258 with its number for IV generation being <replaceable>n</replaceable>.</para>
259
260 <para>This option is only relevant for plain devices.</para>
261 </listitem>
262 </varlistentry>
263
798d3a52
ZJS
264 <varlistentry>
265 <term><option>size=</option></term>
266
267 <listitem><para>Specifies the key size in bits. See
3ba3a79d 268 <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
798d3a52
ZJS
269 for possible values and the default value of this
270 option.</para></listitem>
271 </varlistentry>
272
a9fc6406
DJL
273 <varlistentry>
274 <term><option>sector-size=</option></term>
275
276 <listitem><para>Specifies the sector size in bytes. See
277 <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
278 for possible values and the default value of this
279 option.</para></listitem>
280 </varlistentry>
281
798d3a52
ZJS
282 <varlistentry>
283 <term><option>swap</option></term>
284
285 <listitem><para>The encrypted block device will be used as a
286 swap device, and will be formatted accordingly after setting
287 up the encrypted block device, with
288 <citerefentry project='man-pages'><refentrytitle>mkswap</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
289 This option implies <option>plain</option>.</para>
290
291 <para>WARNING: Using the <option>swap</option> option will
292 destroy the contents of the named partition during every boot,
293 so make sure the underlying block device is specified
294 correctly.</para></listitem>
295 </varlistentry>
296
297 <varlistentry>
298 <term><option>tcrypt</option></term>
299
300 <listitem><para>Use TrueCrypt encryption mode. When this mode
301 is used, the following options are ignored since they are
302 provided by the TrueCrypt header on the device or do not
303 apply:
304 <option>cipher=</option>,
305 <option>hash=</option>,
306 <option>keyfile-offset=</option>,
307 <option>keyfile-size=</option>,
308 <option>size=</option>.</para>
309
310 <para>When this mode is used, the passphrase is read from the
311 key file given in the third field. Only the first line of this
312 file is read, excluding the new line character.</para>
313
314 <para>Note that the TrueCrypt format uses both passphrase and
315 key files to derive a password for the volume. Therefore, the
316 passphrase and all key files need to be provided. Use
317 <option>tcrypt-keyfile=</option> to provide the absolute path
318 to all key files. When using an empty passphrase in
319 combination with one or more key files, use
320 <literal>/dev/null</literal> as the password file in the third
321 field.</para></listitem>
322 </varlistentry>
323
324 <varlistentry>
325 <term><option>tcrypt-hidden</option></term>
326
327 <listitem><para>Use the hidden TrueCrypt volume. This option
328 implies <option>tcrypt</option>.</para>
329
330 <para>This will map the hidden volume that is inside of the
331 volume provided in the second field. Please note that there is
332 no protection for the hidden volume if the outer volume is
333 mounted instead. See
3ba3a79d 334 <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
798d3a52
ZJS
335 for more information on this limitation.</para></listitem>
336 </varlistentry>
337
338 <varlistentry>
339 <term><option>tcrypt-keyfile=</option></term>
340
341 <listitem><para>Specifies the absolute path to a key file to
342 use for a TrueCrypt volume. This implies
343 <option>tcrypt</option> and can be used more than once to
344 provide several key files.</para>
345
346 <para>See the entry for <option>tcrypt</option> on the
347 behavior of the passphrase and key files when using TrueCrypt
348 encryption mode.</para></listitem>
349 </varlistentry>
350
351 <varlistentry>
352 <term><option>tcrypt-system</option></term>
353
354 <listitem><para>Use TrueCrypt in system encryption mode. This
355 option implies <option>tcrypt</option>.</para></listitem>
356 </varlistentry>
357
52028838
GH
358 <varlistentry>
359 <term><option>tcrypt-veracrypt</option></term>
360
361 <listitem><para>Check for a VeraCrypt volume. VeraCrypt is a fork of
362 TrueCrypt that is mostly compatible, but uses different, stronger key
363 derivation algorithms that cannot be detected without this flag.
364 Enabling this option could substantially slow down unlocking, because
365 VeraCrypt's key derivation takes much longer than TrueCrypt's. This
366 option implies <option>tcrypt</option>.</para></listitem>
367 </varlistentry>
368
798d3a52
ZJS
369 <varlistentry>
370 <term><option>timeout=</option></term>
371
372 <listitem><para>Specifies the timeout for querying for a
373 password. If no unit is specified, seconds is used. Supported
374 units are s, ms, us, min, h, d. A timeout of 0 waits
375 indefinitely (which is the default).</para></listitem>
376 </varlistentry>
377
798d3a52
ZJS
378 <varlistentry>
379 <term><option>tmp</option></term>
380
381 <listitem><para>The encrypted block device will be prepared
382 for using it as <filename>/tmp</filename>; it will be
383 formatted using
384 <citerefentry project='man-pages'><refentrytitle>mke2fs</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
385 This option implies <option>plain</option>.</para>
386
387 <para>WARNING: Using the <option>tmp</option> option will
388 destroy the contents of the named partition during every boot,
389 so make sure the underlying block device is specified
390 correctly.</para></listitem>
391 </varlistentry>
392
393 <varlistentry>
394 <term><option>tries=</option></term>
395
396 <listitem><para>Specifies the maximum number of times the user
397 is queried for a password. The default is 3. If set to 0, the
398 user is queried for a password indefinitely.</para></listitem>
399 </varlistentry>
400
401 <varlistentry>
402 <term><option>verify</option></term>
403
404 <listitem><para> If the encryption password is read from
405 console, it has to be entered twice to prevent
406 typos.</para></listitem>
407 </varlistentry>
408
ed3657d5
ZJS
409 <varlistentry>
410 <term><option>x-systemd.device-timeout=</option></term>
411
412 <listitem><para>Specifies how long systemd should wait for a device to show up
413 before giving up on the entry. The argument is a time in seconds or explicitly
414 specified units of
415 <literal>s</literal>,
416 <literal>min</literal>,
417 <literal>h</literal>,
418 <literal>ms</literal>.
419 </para></listitem>
420 </varlistentry>
421
798d3a52
ZJS
422 </variablelist>
423
424 <para>At early boot and when the system manager configuration is
425 reloaded, this file is translated into native systemd units by
426 <citerefentry><refentrytitle>systemd-cryptsetup-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
427 </refsect1>
428
429 <refsect1>
430 <title>Example</title>
431 <example>
432 <title>/etc/crypttab example</title>
433 <para>Set up four encrypted block devices. One using LUKS for
434 normal storage, another one for usage as a swap device and two
435 TrueCrypt volumes.</para>
436
437 <programlisting>luks UUID=2505567a-9e27-4efe-a4d5-15ad146c258b
438swap /dev/sda7 /dev/urandom swap
8cf3ca80 439truecrypt /dev/sda2 /etc/container_password tcrypt
798d3a52
ZJS
440hidden /mnt/tc_hidden /dev/null tcrypt-hidden,tcrypt-keyfile=/etc/keyfile</programlisting>
441 </example>
442 </refsect1>
443
444 <refsect1>
445 <title>See Also</title>
446 <para>
447 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
448 <citerefentry><refentrytitle>systemd-cryptsetup@.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
449 <citerefentry><refentrytitle>systemd-cryptsetup-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
288c2616 450 <citerefentry project='man-pages'><refentrytitle>fstab</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
3ba3a79d 451 <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
798d3a52
ZJS
452 <citerefentry project='man-pages'><refentrytitle>mkswap</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
453 <citerefentry project='man-pages'><refentrytitle>mke2fs</refentrytitle><manvolnum>8</manvolnum></citerefentry>
454 </para>
455 </refsect1>
45ae1a05
LP
456
457</refentry>