]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/crypttab.xml
Merge pull request #15953 from keszybz/gdb-script
[thirdparty/systemd.git] / man / crypttab.xml
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.2/docbookx.dtd">
5 <!--
6 SPDX-License-Identifier: LGPL-2.1+
7
8 This is based on crypttab(5) from Fedora's initscripts package, which in
9 turn is based on Debian's version.
10
11 The Red Hat version has been written by Miloslav Trmac <mitr@redhat.com>.
12 -->
13 <refentry id="crypttab" conditional='HAVE_LIBCRYPTSETUP' xmlns:xi="http://www.w3.org/2001/XInclude">
14
15 <refentryinfo>
16 <title>crypttab</title>
17 <productname>systemd</productname>
18 </refentryinfo>
19
20 <refmeta>
21 <refentrytitle>crypttab</refentrytitle>
22 <manvolnum>5</manvolnum>
23 </refmeta>
24
25 <refnamediv>
26 <refname>crypttab</refname>
27 <refpurpose>Configuration for encrypted block devices</refpurpose>
28 </refnamediv>
29
30 <refsynopsisdiv>
31 <para><filename>/etc/crypttab</filename></para>
32 </refsynopsisdiv>
33
34 <refsect1>
35 <title>Description</title>
36
37 <para>The <filename>/etc/crypttab</filename> file describes
38 encrypted block devices that are set up during system boot.</para>
39
40 <para>Empty lines and lines starting with the <literal>#</literal>
41 character are ignored. Each of the remaining lines describes one
42 encrypted block device. Fields are delimited by white space.</para>
43
44 <para>Each line is in the form<programlisting><replaceable>volume-name</replaceable> <replaceable>encrypted-device</replaceable> <replaceable>key-file</replaceable> <replaceable>options</replaceable></programlisting>
45 The first two fields are mandatory, the remaining two are
46 optional.</para>
47
48 <para>Setting up encrypted block devices using this file supports
49 three encryption modes: LUKS, TrueCrypt and plain. See
50 <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
51 for more information about each mode. When no mode is specified in
52 the options field and the block device contains a LUKS signature,
53 it is opened as a LUKS device; otherwise, it is assumed to be in
54 raw dm-crypt (plain mode) format.</para>
55
56 <para>The first field contains the name of the resulting encrypted volume; its block device is set up
57 below <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 an absolute path to a file to read the encryption key from. If the field
64 is not present or set to <literal>none</literal> or <literal>-</literal>, a key file named after the
65 volume to unlock (i.e. the first column of the line), suffixed with <filename>.key</filename> is
66 automatically loaded from the <filename>/etc/cryptsetup-keys.d/</filename> and
67 <filename>/run/cryptsetup-keys.d/</filename> directories, if present. Otherwise, the password has to be
68 manually entered during system boot. For swap encryption, <filename>/dev/urandom</filename> may be used
69 as key file.</para>
70
71 <para>The fourth field, if present, is a comma-delimited list of
72 options. The following options are recognized:</para>
73
74 <variablelist class='fstab-options'>
75
76 <varlistentry>
77 <term><option>cipher=</option></term>
78
79 <listitem><para>Specifies the cipher to use. See
80 <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
81 for possible values and the default value of this option. A
82 cipher with unpredictable IV values, such as
83 <literal>aes-cbc-essiv:sha256</literal>, is
84 recommended.</para></listitem>
85 </varlistentry>
86
87 <varlistentry>
88 <term><option>discard</option></term>
89
90 <listitem><para>Allow discard requests to be passed through the encrypted block
91 device. This improves performance on SSD storage but has security implications.
92 </para></listitem>
93 </varlistentry>
94
95 <varlistentry>
96 <term><option>hash=</option></term>
97
98 <listitem><para>Specifies the hash to use for password
99 hashing. See
100 <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
101 for possible values and the default value of this
102 option.</para></listitem>
103 </varlistentry>
104
105 <varlistentry>
106 <term><option>header=</option></term>
107
108 <listitem><para>Use a detached (separated) metadata device or
109 file where the LUKS header is stored. This option is only
110 relevant for LUKS devices. See
111 <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
112 for possible values and the default value of this
113 option.</para></listitem>
114 </varlistentry>
115
116 <varlistentry>
117 <term><option>keyfile-offset=</option></term>
118
119 <listitem><para>Specifies the number of bytes to skip at the
120 start of the key file. See
121 <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
122 for possible values and the default value of this
123 option.</para></listitem>
124 </varlistentry>
125
126 <varlistentry>
127 <term><option>keyfile-size=</option></term>
128
129 <listitem><para>Specifies the maximum number of bytes to read
130 from the key file. See
131 <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
132 for possible values and the default value of this option. This
133 option is ignored in plain encryption mode, as the key file
134 size is then given by the key size.</para></listitem>
135 </varlistentry>
136
137 <varlistentry>
138 <term><option>keyfile-erase</option></term>
139
140 <listitem><para>If enabled, the specified key file is erased after the volume is activated or when
141 activation fails. This is in particular useful when the key file is only acquired transiently before
142 activation (e.g. via a file in <filename>/run/</filename>, generated by a service running before
143 activation), and shall be removed after use. Defaults to off.</para></listitem>
144 </varlistentry>
145
146 <varlistentry>
147 <term><option>key-slot=</option></term>
148
149 <listitem><para>Specifies the key slot to compare the
150 passphrase or key against. If the key slot does not match the
151 given passphrase or key, but another would, the setup of the
152 device will fail regardless. This option implies
153 <option>luks</option>. See
154 <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
155 for possible values. The default is to try all key slots in
156 sequential order.</para></listitem>
157 </varlistentry>
158
159 <varlistentry>
160 <term><option>keyfile-timeout=</option></term>
161
162 <listitem><para> Specifies the timeout for the device on
163 which the key file resides and falls back to a password if
164 it could not be mounted. See
165 <citerefentry><refentrytitle>systemd-cryptsetup-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>
166 for key files on external devices.
167 </para></listitem>
168 </varlistentry>
169
170 <varlistentry>
171 <term><option>luks</option></term>
172
173 <listitem><para>Force LUKS mode. When this mode is used, the
174 following options are ignored since they are provided by the
175 LUKS header on the device: <option>cipher=</option>,
176 <option>hash=</option>,
177 <option>size=</option>.</para></listitem>
178 </varlistentry>
179
180 <varlistentry>
181 <term><option>bitlk</option></term>
182
183 <listitem><para>Decrypt Bitlocker drive. Encryption parameters
184 are deduced by cryptsetup from Bitlocker header.</para></listitem>
185 </varlistentry>
186
187 <varlistentry>
188 <term><option>_netdev</option></term>
189
190 <listitem><para>Marks this cryptsetup device as requiring network. It will be
191 started after the network is available, similarly to
192 <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>
193 units marked with <option>_netdev</option>. The service unit to set up this device
194 will be ordered between <filename>remote-fs-pre.target</filename> and
195 <filename>remote-cryptsetup.target</filename>, instead of
196 <filename>cryptsetup-pre.target</filename> and
197 <filename>cryptsetup.target</filename>.</para>
198
199 <para>Hint: if this device is used for a mount point that is specified in
200 <citerefentry project='man-pages'><refentrytitle>fstab</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
201 the <option>_netdev</option> option should also be used for the mount
202 point. Otherwise, a dependency loop might be created where the mount point
203 will be pulled in by <filename>local-fs.target</filename>, while the
204 service to configure the network is usually only started <emphasis>after</emphasis>
205 the local file system has been mounted.</para>
206 </listitem>
207 </varlistentry>
208
209 <varlistentry>
210 <term><option>noauto</option></term>
211
212 <listitem><para>This device will not be added to <filename>cryptsetup.target</filename>.
213 This means that it will not be automatically unlocked on boot, unless something else pulls
214 it in. In particular, if the device is used for a mount point, it'll be unlocked
215 automatically during boot, unless the mount point itself is also disabled with
216 <option>noauto</option>.</para></listitem>
217 </varlistentry>
218
219 <varlistentry>
220 <term><option>nofail</option></term>
221
222 <listitem><para>This device will not be a hard dependency of
223 <filename>cryptsetup.target</filename>. It'll still be pulled in and started, but the system
224 will not wait for the device to show up and be unlocked, and boot will not fail if this is
225 unsuccessful. Note that other units that depend on the unlocked device may still fail. In
226 particular, if the device is used for a mount point, the mount point itself also needs to
227 have the <option>nofail</option> option, or the boot will fail if the device is not unlocked
228 successfully.</para></listitem>
229 </varlistentry>
230
231 <varlistentry>
232 <term><option>offset=</option></term>
233
234 <listitem><para>Start offset in the backend device, in 512-byte sectors. This
235 option is only relevant for plain devices.</para></listitem>
236 </varlistentry>
237
238 <varlistentry>
239 <term><option>plain</option></term>
240
241 <listitem><para>Force plain encryption mode.</para></listitem>
242 </varlistentry>
243
244 <varlistentry>
245 <term><option>read-only</option></term><term><option>readonly</option></term>
246
247 <listitem><para>Set up the encrypted block device in read-only
248 mode.</para></listitem>
249 </varlistentry>
250
251 <varlistentry>
252 <term><option>same-cpu-crypt</option></term>
253
254 <listitem><para>Perform encryption using the same cpu that IO was submitted on. The default is to use
255 an unbound workqueue so that encryption work is automatically balanced between available CPUs.</para>
256 <para>This requires kernel 4.0 or newer.</para>
257 </listitem>
258 </varlistentry>
259
260 <varlistentry>
261 <term><option>submit-from-crypt-cpus</option></term>
262
263 <listitem><para>Disable offloading writes to a separate thread after encryption. There are some
264 situations where offloading write bios from the encryption threads to a single thread degrades
265 performance significantly. The default is to offload write bios to the same thread because it benefits
266 CFQ to have writes submitted using the same context.</para>
267 <para>This requires kernel 4.0 or newer.</para>
268 </listitem>
269 </varlistentry>
270
271 <varlistentry>
272 <term><option>skip=</option></term>
273
274 <listitem><para>How many 512-byte sectors of the encrypted data to skip at the
275 beginning. This is different from the <option>offset=</option> option with respect
276 to the sector numbers used in initialization vector (IV) calculation. Using
277 <option>offset=</option> will shift the IV calculation by the same negative
278 amount. Hence, if <option>offset=<replaceable>n</replaceable></option> is given,
279 sector <replaceable>n</replaceable> will get a sector number of 0 for the IV
280 calculation. Using <option>skip=</option> causes sector
281 <replaceable>n</replaceable> to also be the first sector of the mapped device, but
282 with its number for IV generation being <replaceable>n</replaceable>.</para>
283
284 <para>This option is only relevant for plain devices.</para>
285 </listitem>
286 </varlistentry>
287
288 <varlistentry>
289 <term><option>size=</option></term>
290
291 <listitem><para>Specifies the key size in bits. See
292 <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
293 for possible values and the default value of this
294 option.</para></listitem>
295 </varlistentry>
296
297 <varlistentry>
298 <term><option>sector-size=</option></term>
299
300 <listitem><para>Specifies the sector size in bytes. See
301 <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
302 for possible values and the default value of this
303 option.</para></listitem>
304 </varlistentry>
305
306 <varlistentry>
307 <term><option>swap</option></term>
308
309 <listitem><para>The encrypted block device will be used as a
310 swap device, and will be formatted accordingly after setting
311 up the encrypted block device, with
312 <citerefentry project='man-pages'><refentrytitle>mkswap</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
313 This option implies <option>plain</option>.</para>
314
315 <para>WARNING: Using the <option>swap</option> option will
316 destroy the contents of the named partition during every boot,
317 so make sure the underlying block device is specified
318 correctly.</para></listitem>
319 </varlistentry>
320
321 <varlistentry>
322 <term><option>tcrypt</option></term>
323
324 <listitem><para>Use TrueCrypt encryption mode. When this mode
325 is used, the following options are ignored since they are
326 provided by the TrueCrypt header on the device or do not
327 apply:
328 <option>cipher=</option>,
329 <option>hash=</option>,
330 <option>keyfile-offset=</option>,
331 <option>keyfile-size=</option>,
332 <option>size=</option>.</para>
333
334 <para>When this mode is used, the passphrase is read from the
335 key file given in the third field. Only the first line of this
336 file is read, excluding the new line character.</para>
337
338 <para>Note that the TrueCrypt format uses both passphrase and
339 key files to derive a password for the volume. Therefore, the
340 passphrase and all key files need to be provided. Use
341 <option>tcrypt-keyfile=</option> to provide the absolute path
342 to all key files. When using an empty passphrase in
343 combination with one or more key files, use
344 <literal>/dev/null</literal> as the password file in the third
345 field.</para></listitem>
346 </varlistentry>
347
348 <varlistentry>
349 <term><option>tcrypt-hidden</option></term>
350
351 <listitem><para>Use the hidden TrueCrypt volume. This option
352 implies <option>tcrypt</option>.</para>
353
354 <para>This will map the hidden volume that is inside of the
355 volume provided in the second field. Please note that there is
356 no protection for the hidden volume if the outer volume is
357 mounted instead. See
358 <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
359 for more information on this limitation.</para></listitem>
360 </varlistentry>
361
362 <varlistentry>
363 <term><option>tcrypt-keyfile=</option></term>
364
365 <listitem><para>Specifies the absolute path to a key file to
366 use for a TrueCrypt volume. This implies
367 <option>tcrypt</option> and can be used more than once to
368 provide several key files.</para>
369
370 <para>See the entry for <option>tcrypt</option> on the
371 behavior of the passphrase and key files when using TrueCrypt
372 encryption mode.</para></listitem>
373 </varlistentry>
374
375 <varlistentry>
376 <term><option>tcrypt-system</option></term>
377
378 <listitem><para>Use TrueCrypt in system encryption mode. This
379 option implies <option>tcrypt</option>.</para></listitem>
380 </varlistentry>
381
382 <varlistentry>
383 <term><option>tcrypt-veracrypt</option></term>
384
385 <listitem><para>Check for a VeraCrypt volume. VeraCrypt is a fork of
386 TrueCrypt that is mostly compatible, but uses different, stronger key
387 derivation algorithms that cannot be detected without this flag.
388 Enabling this option could substantially slow down unlocking, because
389 VeraCrypt's key derivation takes much longer than TrueCrypt's. This
390 option implies <option>tcrypt</option>.</para></listitem>
391 </varlistentry>
392
393 <varlistentry>
394 <term><option>timeout=</option></term>
395
396 <listitem><para>Specifies the timeout for querying for a
397 password. If no unit is specified, seconds is used. Supported
398 units are s, ms, us, min, h, d. A timeout of 0 waits
399 indefinitely (which is the default).</para></listitem>
400 </varlistentry>
401
402 <varlistentry>
403 <term><option>tmp=</option></term>
404
405 <listitem><para>The encrypted block device will be prepared for using it as
406 <filename>/tmp/</filename>; it will be formatted using <citerefentry
407 project='man-pages'><refentrytitle>mkfs</refentrytitle><manvolnum>8</manvolnum></citerefentry>. Takes
408 a file system type as argument, such as <literal>ext4</literal>, <literal>xfs</literal> or
409 <literal>btrfs</literal>. If no argument is specified defaults to <literal>ext4</literal>. This
410 option implies <option>plain</option>.</para>
411
412 <para>WARNING: Using the <option>tmp</option> option will destroy the contents of the named partition
413 during every boot, so make sure the underlying block device is specified correctly.</para></listitem>
414 </varlistentry>
415
416 <varlistentry>
417 <term><option>tries=</option></term>
418
419 <listitem><para>Specifies the maximum number of times the user
420 is queried for a password. The default is 3. If set to 0, the
421 user is queried for a password indefinitely.</para></listitem>
422 </varlistentry>
423
424 <varlistentry>
425 <term><option>verify</option></term>
426
427 <listitem><para>If the encryption password is read from console, it has to be entered twice to
428 prevent typos.</para></listitem>
429 </varlistentry>
430
431 <varlistentry>
432 <term><option>pkcs11-uri=</option></term>
433
434 <listitem><para>Takes a <ulink url="https://tools.ietf.org/html/rfc7512">RFC7512 PKCS#11 URI</ulink>
435 pointing to a private RSA key which is used to decrypt the key specified in the third column of the
436 line. This is useful for unlocking encrypted volumes through security tokens or smartcards. See below
437 for an example how to set up this mechanism for unlocking a LUKS volume with a YubiKey security
438 token. The specified URI can refer directly to a private RSA key stored on a token or alternatively
439 just to a slot or token, in which case a search for a suitable private RSA key will be performed. In
440 this case if multiple suitable objects are found the token is refused. The key configured in the
441 third column is passed as is to RSA decryption. The resulting decrypted key is then base64 encoded
442 before it is used to unlock the LUKS volume.</para></listitem>
443 </varlistentry>
444
445 <varlistentry>
446 <term><option>try-empty-password=</option></term>
447
448 <listitem><para>Takes a boolean argument. If enabled, right before asking the user for a password it
449 is first attempted to unlock the volume with an empty password. This is useful for systems that are
450 initialized with an encrypted volume with only an empty password set, which shall be replaced with a
451 suitable password during first boot, but after activation.</para></listitem>
452 </varlistentry>
453
454 <varlistentry>
455 <term><option>x-systemd.device-timeout=</option></term>
456
457 <listitem><para>Specifies how long systemd should wait for a device to show up
458 before giving up on the entry. The argument is a time in seconds or explicitly
459 specified units of
460 <literal>s</literal>,
461 <literal>min</literal>,
462 <literal>h</literal>,
463 <literal>ms</literal>.
464 </para></listitem>
465 </varlistentry>
466
467 <varlistentry>
468 <term><option>x-initrd.attach</option></term>
469
470 <listitem><para>Setup this encrypted block device in the initramfs, similarly to
471 <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>
472 units marked with <option>x-initrd.mount</option>.</para>
473
474 <para>Although it's not necessary to mark the mount entry for the root file system with
475 <option>x-initrd.mount</option>, <option>x-initrd.attach</option> is still recommended with
476 the encrypted block device containing the root file system as otherwise systemd will
477 attempt to detach the device during the regular system shutdown while it's still in
478 use. With this option the device will still be detached but later after the root file
479 system is unmounted.</para>
480
481 <para>All other encrypted block devices that contain file systems mounted in the initramfs
482 should use this option.</para>
483 </listitem>
484 </varlistentry>
485
486 </variablelist>
487
488 <para>At early boot and when the system manager configuration is
489 reloaded, this file is translated into native systemd units by
490 <citerefentry><refentrytitle>systemd-cryptsetup-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
491 </refsect1>
492
493 <refsect1>
494 <title>Examples</title>
495 <example>
496 <title>/etc/crypttab example</title>
497 <para>Set up four encrypted block devices. One using LUKS for
498 normal storage, another one for usage as a swap device and two
499 TrueCrypt volumes.</para>
500
501 <programlisting>luks UUID=2505567a-9e27-4efe-a4d5-15ad146c258b
502 swap /dev/sda7 /dev/urandom swap
503 truecrypt /dev/sda2 /etc/container_password tcrypt
504 hidden /mnt/tc_hidden /dev/null tcrypt-hidden,tcrypt-keyfile=/etc/keyfile
505 external /dev/sda3 keyfile:LABEL=keydev keyfile-timeout=10s</programlisting>
506 </example>
507
508 <example>
509 <title>Yubikey-based Volume Unlocking Example</title>
510
511 <para>The PKCS#11 logic allows hooking up any compatible security token that is capable of storing RSA
512 decryption keys. Here's an example how to set up a Yubikey security token for this purpose, using
513 <command>ykman</command> from the yubikey-manager project:</para>
514
515 <programlisting><xi:include href="yubikey-crypttab.sh" parse="text" /></programlisting>
516
517 <para>A few notes on the above:</para>
518
519 <itemizedlist>
520 <listitem><para>We use RSA (and not ECC), since Yubikeys support PKCS#11 Decrypt() only for RSA keys</para></listitem>
521 <listitem><para>We use RSA2048, which is the longest key size current Yubikeys support</para></listitem>
522 <listitem><para>LUKS key size must be shorter than 2048bit due to RSA padding, hence we use 128 bytes</para></listitem>
523 <listitem><para>We use Yubikey key slot 9d, since that's apparently the keyslot to use for decryption purposes,
524 <ulink url="https://developers.yubico.com/PIV/Introduction/Certificate_slots.html">see
525 documentation</ulink>.</para></listitem>
526 </itemizedlist>
527
528 </example>
529 </refsect1>
530
531 <refsect1>
532 <title>See Also</title>
533 <para>
534 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
535 <citerefentry><refentrytitle>systemd-cryptsetup@.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
536 <citerefentry><refentrytitle>systemd-cryptsetup-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
537 <citerefentry project='man-pages'><refentrytitle>fstab</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
538 <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
539 <citerefentry project='man-pages'><refentrytitle>mkswap</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
540 <citerefentry project='man-pages'><refentrytitle>mke2fs</refentrytitle><manvolnum>8</manvolnum></citerefentry>
541 </para>
542 </refsect1>
543
544 </refentry>