3 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
4 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
6 SPDX-License-Identifier: LGPL-2.1-or-later
8 This is based on crypttab(5) from Fedora's initscripts package, which in
9 turn is based on Debian's version.
11 The Red Hat version has been written by Miloslav Trmac <mitr@redhat.com>.
13 <refentry id="crypttab" conditional='HAVE_LIBCRYPTSETUP' xmlns:xi="http://www.w3.org/2001/XInclude">
16 <title>crypttab</title>
17 <productname>systemd</productname>
21 <refentrytitle>crypttab</refentrytitle>
22 <manvolnum>5</manvolnum>
26 <refname>crypttab</refname>
27 <refpurpose>Configuration for encrypted block devices</refpurpose>
31 <para><filename>/etc/crypttab</filename></para>
35 <title>Description</title>
37 <para>The <filename>/etc/crypttab</filename> file describes
38 encrypted block devices that are set up during system boot.</para>
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>
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
48 <para>Setting up encrypted block devices using this file supports four encryption modes: LUKS, TrueCrypt,
49 BitLocker and plain. See <citerefentry
50 project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry> for
51 more information about each mode. When no mode is specified in the options field and the block device
52 contains a LUKS signature, it is opened as a LUKS device; otherwise, it is assumed to be in raw dm-crypt
53 (plain mode) format.</para>
55 <para>The four fields of <filename>/etc/crypttab</filename> are defined as follows:</para>
59 <listitem><para>The first field contains the name of the resulting volume with decrypted data; its
60 block device is set up below <filename>/dev/mapper/</filename>.</para></listitem>
62 <listitem><para>The second field contains a path to the underlying block
63 device or file, or a specification of a block device via
64 <literal>UUID=</literal> followed by the UUID.</para></listitem>
66 <listitem><para>The third field specifies an absolute path to a file with the encryption
67 key. Optionally, the path may be followed by <literal>:</literal> and an
68 <filename>/etc/fstab</filename> style device specification (e.g. starting with
69 <literal>LABEL=</literal> or similar); in which case the path is taken relative to the specified
70 device's file system root. If the field is not present or is <literal>none</literal> or
71 <literal>-</literal>, a key file named after the volume to unlock (i.e. the first column of the line),
72 suffixed with <filename>.key</filename> is automatically loaded from the
73 <filename>/etc/cryptsetup-keys.d/</filename> and <filename>/run/cryptsetup-keys.d/</filename>
74 directories, if present. Otherwise, the password has to be manually entered during system boot. For
75 swap encryption, <filename>/dev/urandom</filename> may be used as key file, resulting in a randomized
78 <para>If the specified key file path refers to an <constant>AF_UNIX</constant> stream socket in the
79 file system, the key is acquired by connecting to the socket and reading it from the connection. This
80 allows the implementation of a service to provide key information dynamically, at the moment when it is
81 needed. For details see below.</para></listitem>
83 <listitem><para>The fourth field, if present, is a comma-delimited list of options. The supported
84 options are listed below.</para></listitem>
89 <title>Key Acquisition</title>
91 <para>Six different mechanisms for acquiring the decryption key or passphrase unlocking the encrypted
92 volume are supported. Specifically:</para>
96 <listitem><para>Most prominently, the user may be queried interactively during volume activation
97 (i.e. typically at boot), asking them to type in the necessary passphrases.</para></listitem>
99 <listitem><para>The (unencrypted) key may be read from a file on disk, possibly on removable media. The third field
100 of each line encodes the location, for details see above.</para></listitem>
102 <listitem><para>The (unencrypted) key may be requested from another service, by specifying an
103 <constant>AF_UNIX</constant> file system socket in place of a key file in the third field. For details
104 see above and below.</para></listitem>
106 <listitem><para>The key may be acquired via a PKCS#11 compatible hardware security token or
107 smartcard. In this case, a saved key used in unlock process is stored on disk/removable media, acquired via
108 <constant>AF_UNIX</constant>, or stored in the LUKS2 JSON token metadata header. For RSA, the saved key
109 is an encrypted volume key. The encrypted volume key is then decrypted by the PKCS#11 token with an RSA
110 private key stored on it, and used to unlock the encrypted volume. For elliptic-curve (EC) cryptography,
111 the saved key is the public key generated in enrollment process. The public key is then used to derive
112 a shared secret with a private key stored in the PKCS#11 token. The derived shared secret is then used
113 to unlock the volume. Use the <option>pkcs11-uri=</option> option described below to use this mechanism.
116 <listitem><para>Similarly, the key may be acquired via a FIDO2 compatible hardware security token
117 (which must implement the "hmac-secret" extension). In this case, a key generated randomly during
118 enrollment is stored on disk/removable media, acquired via <constant>AF_UNIX</constant>, or stored in
119 the LUKS2 JSON token metadata header. The random key is hashed via a keyed hash function (HMAC) on the
120 FIDO2 token, using a secret key stored on the token that never leaves it. The resulting hash value is
121 then used as key to unlock the encrypted volume. Use the <option>fido2-device=</option> option
122 described below to use this mechanism.</para></listitem>
124 <listitem><para>Similarly, the key may be acquired via a TPM2 security chip. In this case, a (during
125 enrollment) randomly generated key — encrypted by an asymmetric key derived from the TPM2 chip's seed
126 key — is stored on disk/removable media, acquired via <constant>AF_UNIX</constant>, or stored in the
127 LUKS2 JSON token metadata header. Use the <option>tpm2-device=</option> option described below to use
128 this mechanism.</para></listitem>
131 <para>For the latter five mechanisms the source for the key material used for unlocking the volume is
132 primarily configured in the third field of each <filename>/etc/crypttab</filename> line, but may also
133 be configured in <filename>/etc/cryptsetup-keys.d/</filename> and
134 <filename>/run/cryptsetup-keys.d/</filename> (see above) or in the LUKS2 JSON token header (in case of
135 the latter three). Use the
136 <citerefentry><refentrytitle>systemd-cryptenroll</refentrytitle><manvolnum>1</manvolnum></citerefentry>
137 tool to enroll PKCS#11, FIDO2 and TPM2 devices in LUKS2 volumes.</para>
141 <title>Supported Options</title>
143 <para>The following options may be used in the fourth field of each line:</para>
145 <variablelist class='fstab-options'>
148 <term><option>cipher=</option></term>
150 <listitem><para>Specifies the cipher to use. See <citerefentry
151 project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
152 for possible values and the default value of this option. A cipher with unpredictable IV values, such
153 as <literal>aes-cbc-essiv:sha256</literal>, is recommended. Embedded commas in the cipher
154 specification need to be escaped by preceding them with a backslash, see example below.</para>
156 <xi:include href="version-info.xml" xpointer="v186"/>
161 <term><option>discard</option></term>
163 <listitem><para>Allow discard requests to be passed through the encrypted block
164 device. This improves performance on SSD storage but has security implications.
167 <xi:include href="version-info.xml" xpointer="v207"/></listitem>
171 <term><option>hash=</option></term>
173 <listitem><para>Specifies the hash to use for password
175 <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
176 for possible values and the default value of this
179 <xi:include href="version-info.xml" xpointer="v186"/></listitem>
183 <term><option>header=</option></term>
185 <listitem><para>Use a detached (separated) metadata device or file
186 where the header containing the master key(s) is stored. This
187 option is only relevant for LUKS and TrueCrypt/VeraCrypt devices. See
188 <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
189 for possible values and the default value of this option.</para>
191 <para>Optionally, the path may be followed by <literal>:</literal> and an
192 <filename>/etc/fstab</filename> device specification (e.g. starting with <literal>UUID=</literal> or
193 similar); in which case, the path is relative to the device file system root. The device gets mounted
194 automatically for LUKS device activation duration only.</para>
196 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
200 <term><option>keyfile-offset=</option></term>
202 <listitem><para>Specifies the number of bytes to skip at the
203 start of the key file. See
204 <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
205 for possible values and the default value of this
208 <xi:include href="version-info.xml" xpointer="v187"/></listitem>
212 <term><option>keyfile-size=</option></term>
214 <listitem><para>Specifies the maximum number of bytes to read
215 from the key file. See
216 <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
217 for possible values and the default value of this option. This
218 option is ignored in plain encryption mode, where the key file
219 size is determined by the key size. It is also ignored when
220 the key file is used as a salt file for a FIDO2 token, as the
221 salt size in that case is defined by the FIDO2 specification
222 to be exactly 32 bytes.</para>
224 <xi:include href="version-info.xml" xpointer="v188"/></listitem>
228 <term><option>keyfile-erase</option></term>
230 <listitem><para>If enabled, the specified key file is erased after the volume is activated or when
231 activation fails. This is in particular useful when the key file is only acquired transiently before
232 activation (e.g. via a file in <filename>/run/</filename>, generated by a service running before
233 activation), and shall be removed after use. Defaults to off.</para>
235 <xi:include href="version-info.xml" xpointer="v246"/></listitem>
239 <term><option>key-slot=</option></term>
241 <listitem><para>Specifies the key slot to compare the
242 passphrase or key against. If the key slot does not match the
243 given passphrase or key, but another would, the setup of the
244 device will fail regardless. This option implies
245 <option>luks</option>. See
246 <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
247 for possible values. The default is to try all key slots in
248 sequential order.</para>
250 <xi:include href="version-info.xml" xpointer="v209"/></listitem>
254 <term><option>keyfile-timeout=</option></term>
256 <listitem><para> Specifies the timeout for the device on
257 which the key file resides or the device used as the key file,
258 and falls back to a password if it could not be accessed. See
259 <citerefentry><refentrytitle>systemd-cryptsetup-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>
260 for key files on external devices.
263 <xi:include href="version-info.xml" xpointer="v243"/></listitem>
267 <term><option>link-volume-key=</option></term>
269 <listitem><para>Specifies the kernel keyring and key description
270 (see <citerefentry project='man-pages'><refentrytitle>keyrings</refentrytitle><manvolnum>7</manvolnum></citerefentry>)
271 where LUKS2 volume key gets linked during device activation. The kernel keyring
272 description and key description must be separated by <literal>::</literal>.</para>
274 <para>The kernel keyring part can be a string description or a predefined
275 kernel keyring prefixed with <literal>@</literal> (e.g.: to use <literal>@s</literal> session or
276 <literal>@u</literal> user keyring directly). The type prefix text in the kernel keyring description
277 is not required. The specified kernel keyring must already exist at the time of device activation.</para>
279 <para>The key part is a string description optionally prefixed by a <literal>%key_type:</literal>.
280 If no type is specified, the <literal>user</literal> type key is linked by default. See
281 <citerefentry project='man-pages'><refentrytitle>keyctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
282 for more information on key descriptions (KEY IDENTIFIERS section).</para>
284 <para>Note that the linked volume key is not cleaned up automatically when the device is detached.</para>
286 <xi:include href="version-info.xml" xpointer="v256"/></listitem>
290 <term><option>luks</option></term>
292 <listitem><para>Force LUKS mode. When this mode is used, the
293 following options are ignored since they are provided by the
294 LUKS header on the device: <option>cipher=</option>,
295 <option>hash=</option>,
296 <option>size=</option>.</para>
298 <xi:include href="version-info.xml" xpointer="v186"/></listitem>
302 <term><option>bitlk</option></term>
304 <listitem><para>Decrypt BitLocker drive. Encryption parameters
305 are deduced by cryptsetup from BitLocker header.</para>
307 <xi:include href="version-info.xml" xpointer="v246"/></listitem>
311 <term><option>_netdev</option></term>
313 <listitem><para>Marks this cryptsetup device as requiring network. It will be
314 started after the network is available, similarly to
315 <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>
316 units marked with <option>_netdev</option>. The service unit to set up this device
317 will be ordered between <filename>remote-fs-pre.target</filename> and
318 <filename>remote-cryptsetup.target</filename>, instead of
319 <filename>cryptsetup-pre.target</filename> and
320 <filename>cryptsetup.target</filename>.</para>
322 <para>Hint: if this device is used for a mount point that is specified in
323 <citerefentry project='man-pages'><refentrytitle>fstab</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
324 the <option>_netdev</option> option should also be used for the mount
325 point. Otherwise, a dependency loop might be created where the mount point
326 will be pulled in by <filename>local-fs.target</filename>, while the
327 service to configure the network is usually only started <emphasis>after</emphasis>
328 the local file system has been mounted.</para>
330 <xi:include href="version-info.xml" xpointer="v235"/>
335 <term><option>noauto</option></term>
337 <listitem><para>This device will not be added to <filename>cryptsetup.target</filename>.
338 This means that it will not be automatically unlocked on boot, unless something else pulls
339 it in. In particular, if the device is used for a mount point, it'll be unlocked
340 automatically during boot, unless the mount point itself is also disabled with
341 <option>noauto</option>.</para>
343 <xi:include href="version-info.xml" xpointer="v186"/></listitem>
347 <term><option>nofail</option></term>
349 <listitem><para>This device will not be a hard dependency of
350 <filename>cryptsetup.target</filename>. It'll still be pulled in and started, but the system
351 will not wait for the device to show up and be unlocked, and boot will not fail if this is
352 unsuccessful. Note that other units that depend on the unlocked device may still fail. In
353 particular, if the device is used for a mount point, the mount point itself also needs to
354 have the <option>nofail</option> option, or the boot will fail if the device is not unlocked
355 successfully. If a keyfile and/or a <option>header</option> are specified, the dependencies on
356 their respective directories will also not be fatal, so that umounting said directories will
357 not cause the generated cryptset unit to be deactivated.</para>
359 <xi:include href="version-info.xml" xpointer="v186"/></listitem>
363 <term><option>offset=</option></term>
365 <listitem><para>Start offset in the backend device, in 512-byte sectors. This
366 option is only relevant for plain devices.</para>
368 <xi:include href="version-info.xml" xpointer="v220"/></listitem>
372 <term><option>plain</option></term>
374 <listitem><para>Force plain encryption mode.</para>
376 <xi:include href="version-info.xml" xpointer="v186"/></listitem>
380 <term><option>read-only</option></term><term><option>readonly</option></term>
382 <listitem><para>Set up the encrypted block device in read-only
385 <xi:include href="version-info.xml" xpointer="v186"/></listitem>
389 <term><option>same-cpu-crypt</option></term>
391 <listitem><para>Perform encryption using the same CPU that IO was submitted on. The default is to use
392 an unbound workqueue so that encryption work is automatically balanced between available CPUs.</para>
394 <para>This requires kernel 4.0 or newer.</para>
396 <xi:include href="version-info.xml" xpointer="v242"/>
401 <term><option>submit-from-crypt-cpus</option></term>
403 <listitem><para>Disable offloading writes to a separate thread after encryption. There are some
404 situations where offloading write requests from the encryption threads to a dedicated thread degrades
405 performance significantly. The default is to offload write requests to a dedicated thread because it
406 benefits the CFQ scheduler to have writes submitted using the same context.</para>
408 <para>This requires kernel 4.0 or newer.</para>
410 <xi:include href="version-info.xml" xpointer="v242"/>
415 <term><option>no-read-workqueue</option></term>
417 <listitem><para>Bypass dm-crypt internal workqueue and process read requests synchronously. The
418 default is to queue these requests and process them asynchronously.</para>
420 <para>This requires kernel 5.9 or newer.</para>
422 <xi:include href="version-info.xml" xpointer="v248"/>
426 <term><option>no-write-workqueue</option></term>
428 <listitem><para>Bypass dm-crypt internal workqueue and process write requests synchronously. The
429 default is to queue these requests and process them asynchronously.</para>
431 <para>This requires kernel 5.9 or newer.</para>
433 <xi:include href="version-info.xml" xpointer="v248"/>
438 <term><option>skip=</option></term>
440 <listitem><para>How many 512-byte sectors of the encrypted data to skip at the
441 beginning. This is different from the <option>offset=</option> option with respect
442 to the sector numbers used in initialization vector (IV) calculation. Using
443 <option>offset=</option> will shift the IV calculation by the same negative
444 amount. Hence, if <option>offset=<replaceable>n</replaceable></option> is given,
445 sector <replaceable>n</replaceable> will get a sector number of 0 for the IV
446 calculation. Using <option>skip=</option> causes sector
447 <replaceable>n</replaceable> to also be the first sector of the mapped device, but
448 with its number for IV generation being <replaceable>n</replaceable>.</para>
450 <para>This option is only relevant for plain devices.</para>
452 <xi:include href="version-info.xml" xpointer="v220"/>
457 <term><option>size=</option></term>
459 <listitem><para>Specifies the key size in bits. See
460 <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
461 for possible values and the default value of this
464 <xi:include href="version-info.xml" xpointer="v186"/></listitem>
468 <term><option>sector-size=</option></term>
470 <listitem><para>Specifies the sector size in bytes. See
471 <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
472 for possible values and the default value of this
475 <xi:include href="version-info.xml" xpointer="v240"/></listitem>
479 <term><option>swap</option></term>
481 <listitem><para>The encrypted block device will be used as a
482 swap device, and will be formatted accordingly after setting
483 up the encrypted block device, with
484 <citerefentry project='man-pages'><refentrytitle>mkswap</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
485 This option implies <option>plain</option>.</para>
488 <para>Using the <option>swap</option> option will
489 destroy the contents of the named partition during every boot,
490 so make sure the underlying block device is specified
494 <xi:include href="version-info.xml" xpointer="v186"/></listitem>
498 <term><option>tcrypt</option></term>
500 <listitem><para>Use TrueCrypt encryption mode. When this mode
501 is used, the following options are ignored since they are
502 provided by the TrueCrypt header on the device or do not
504 <option>cipher=</option>,
505 <option>hash=</option>,
506 <option>keyfile-offset=</option>,
507 <option>keyfile-size=</option>,
508 <option>size=</option>.</para>
510 <para>When this mode is used, the passphrase is read from the
511 key file given in the third field. Only the first line of this
512 file is read, excluding the new line character.</para>
514 <para>Note that the TrueCrypt format uses both passphrase and
515 key files to derive a password for the volume. Therefore, the
516 passphrase and all key files need to be provided. Use
517 <option>tcrypt-keyfile=</option> to provide the absolute path
518 to all key files. When using an empty passphrase in
519 combination with one or more key files, use
520 <literal>/dev/null</literal> as the password file in the third
523 <xi:include href="version-info.xml" xpointer="v206"/></listitem>
527 <term><option>tcrypt-hidden</option></term>
529 <listitem><para>Use the hidden TrueCrypt volume. This option
530 implies <option>tcrypt</option>.</para>
532 <para>This will map the hidden volume that is inside of the
533 volume provided in the second field. Please note that there is
534 no protection for the hidden volume if the outer volume is
536 <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
537 for more information on this limitation.</para>
539 <xi:include href="version-info.xml" xpointer="v206"/></listitem>
543 <term><option>tcrypt-keyfile=</option></term>
545 <listitem><para>Specifies the absolute path to a key file to
546 use for a TrueCrypt volume. This implies
547 <option>tcrypt</option> and can be used more than once to
548 provide several key files.</para>
550 <para>See the entry for <option>tcrypt</option> on the
551 behavior of the passphrase and key files when using TrueCrypt
552 encryption mode.</para>
554 <xi:include href="version-info.xml" xpointer="v206"/></listitem>
558 <term><option>tcrypt-system</option></term>
560 <listitem><para>Use TrueCrypt in system encryption mode. This
561 option implies <option>tcrypt</option>.</para>
563 <xi:include href="version-info.xml" xpointer="v206"/></listitem>
567 <term><option>tcrypt-veracrypt</option></term>
569 <listitem><para>Check for a VeraCrypt volume. VeraCrypt is a fork of
570 TrueCrypt that is mostly compatible, but uses different, stronger key
571 derivation algorithms that cannot be detected without this flag.
572 Enabling this option could substantially slow down unlocking, because
573 VeraCrypt's key derivation takes much longer than TrueCrypt's. This
574 option implies <option>tcrypt</option>.</para>
576 <xi:include href="version-info.xml" xpointer="v232"/></listitem>
580 <term><option>veracrypt-pim=</option></term>
582 <listitem><para>Specifies a custom Personal Iteration Multiplier (PIM)
583 value, which can range from 0..2147468 for standard veracrypt volumes
584 and 0..65535 for veracrypt system volumes. A value of 0 will imply the
587 This option is only effective when <option>tcrypt-veracrypt</option> is
590 <para>Note that VeraCrypt enforces a minimal allowed PIM value depending on the
591 password strength and the hash algorithm used for key derivation, however
592 <option>veracrypt-pim=</option> is not checked against these bounds.
594 <ulink url="https://www.veracrypt.fr/en/Personal%20Iterations%20Multiplier%20%28PIM%29.html">Veracrypt Personal Iterations Multiplier</ulink>
595 documentation for more information.</para>
597 <xi:include href="version-info.xml" xpointer="v254"/>
602 <term><option>timeout=</option></term>
604 <listitem><para>Specifies the timeout for querying for a
605 password. If no unit is specified, seconds is used. Supported
606 units are s, ms, us, min, h, d. A timeout of 0 waits
607 indefinitely (which is the default).</para>
609 <xi:include href="version-info.xml" xpointer="v186"/></listitem>
613 <term><option>tmp=</option></term>
615 <listitem><para>The encrypted block device will be prepared for using it as
616 <filename>/tmp/</filename>; it will be formatted using <citerefentry
617 project='man-pages'><refentrytitle>mkfs</refentrytitle><manvolnum>8</manvolnum></citerefentry>. Takes
618 a file system type as argument, such as <literal>ext4</literal>, <literal>xfs</literal> or
619 <literal>btrfs</literal>. If no argument is specified defaults to <literal>ext4</literal>. This
620 option implies <option>plain</option>.</para>
623 <para>Using the <option>tmp</option> option will destroy the contents of the named partition
624 during every boot, so make sure the underlying block device is specified correctly.</para>
627 <xi:include href="version-info.xml" xpointer="v186"/></listitem>
631 <term><option>tries=</option></term>
633 <listitem><para>Specifies the maximum number of times the user
634 is queried for a password. The default is 3. If set to 0, the
635 user is queried for a password indefinitely.</para>
637 <xi:include href="version-info.xml" xpointer="v186"/></listitem>
641 <term><option>headless=</option></term>
643 <listitem><para>Takes a boolean argument, defaults to false. If true, never query interactively
644 for the password/PIN. Useful for headless systems.</para>
646 <xi:include href="version-info.xml" xpointer="v249"/></listitem>
650 <term><option>verify</option></term>
652 <listitem><para>If the encryption password is read from console, it has to be entered twice to
653 prevent typos.</para>
655 <xi:include href="version-info.xml" xpointer="v186"/></listitem>
659 <term><option>password-echo=yes|no|masked</option></term>
661 <listitem><para>Controls whether to echo passwords or security token PINs
662 that are read from console. Takes a boolean or the special string <literal>masked</literal>.
663 The default is <option>password-echo=masked</option>.</para>
665 <para>If enabled, the typed characters are echoed literally. If disabled,
666 the typed characters are not echoed in any form, the user will not get
667 feedback on their input. If set to <literal>masked</literal>, an asterisk
668 (<literal>*</literal>) is echoed for each character typed. Regardless of
669 which mode is chosen, if the user hits the tabulator key (<literal>↹</literal>)
670 at any time, or the backspace key (<literal>⌫</literal>) before any other
671 data has been entered, then echo is turned off.</para>
673 <xi:include href="version-info.xml" xpointer="v249"/></listitem>
677 <term><option>password-cache=yes|no|read-only</option></term>
679 <listitem><para>Controls whether to use cache for passwords or security token PINs.
680 Takes a boolean or the special string <literal>read-only</literal>. Defaults to
681 <literal>yes</literal>.</para>
683 <para>If set to <literal>read-only</literal>, the kernel keyring is checked for a
684 password/PIN before requesting one interactively. If set to <literal>yes</literal>,
685 in addition to checking the keyring, any password/PIN entered interactively is cached
686 in the keyring with a 2.5-minute timeout before being purged.</para>
688 <para>Note that this option is not permitted for PKCS#11 security tokens. The reasoning
689 behind this is that PKCS#11 security tokens are usually configured to lock after being
690 supplied an invalid PIN multiple times, so using the cache might inadvertently lock the
693 <xi:include href="version-info.xml" xpointer="v257"/></listitem>
697 <term><option>pkcs11-uri=</option></term>
699 <listitem><para>Takes either the special value <literal>auto</literal> or an <ulink
700 url="https://tools.ietf.org/html/rfc7512">RFC7512 PKCS#11 URI</ulink> pointing to a private key
701 which is used to decrypt the encrypted key specified in the third column of the line. This is useful
702 for unlocking encrypted volumes through PKCS#11 compatible security tokens or smartcards. See below
703 for an example how to set up this mechanism for unlocking a LUKS2 volume with a YubiKey security
706 <para>If specified as <literal>auto</literal> the volume must be of type LUKS2 and must carry PKCS#11
707 security token metadata in its LUKS2 JSON token section. In this mode the URI and the encrypted key
708 are automatically read from the LUKS2 JSON token header. Use
709 <citerefentry><refentrytitle>systemd-cryptenroll</refentrytitle><manvolnum>1</manvolnum></citerefentry>
710 as a simple tool for enrolling PKCS#11 security tokens or smartcards in a way compatible with
711 <literal>auto</literal>. In this mode the third column of the line should remain empty (that is,
712 specified as <literal>-</literal>).</para>
714 <para>The specified URI can refer directly to a private key stored on a token or alternatively
715 just to a slot or token, in which case a search for a suitable private key will be performed. In
716 this case, if multiple suitable objects are found, the token is refused. The keyfile configured
717 in the third column of the line is used as is (i.e. in binary form, unprocessed). The resulting
718 decrypted key (for RSA) or derived shared secret (for ECC) is then Base64 encoded before it is used
719 to unlock the LUKS volume.</para>
721 <para>Use <command>systemd-cryptenroll --pkcs11-token-uri=list</command> to list all suitable PKCS#11
722 security tokens currently plugged in, along with their URIs.</para>
724 <para>Note that many newer security tokens that may be used as PKCS#11 security token typically also
725 implement the newer and simpler FIDO2 standard. Consider using <option>fido2-device=</option>
726 (described below) to enroll it via FIDO2 instead. Note that a security token enrolled via PKCS#11
727 cannot be used to unlock the volume via FIDO2, unless also enrolled via FIDO2, and vice
730 <xi:include href="version-info.xml" xpointer="v245"/></listitem>
734 <term><option>fido2-device=</option></term>
736 <listitem><para>Takes either the special value <literal>auto</literal> or the path to a
737 <literal>hidraw</literal> device node (e.g. <filename>/dev/hidraw1</filename>) referring to a FIDO2
738 security token that implements the <literal>hmac-secret</literal> extension (most current hardware
739 security tokens do). See below for an example how to set up this mechanism for unlocking an encrypted
740 volume with a FIDO2 security token.</para>
742 <para>If specified as <literal>auto</literal> the FIDO2 token device is automatically discovered, as
743 it is plugged in.</para>
745 <para>FIDO2 volume unlocking requires a client ID hash (CID) to be configured via
746 <option>fido2-cid=</option> (see below) and a key to pass to the security token's HMAC functionality
747 (configured in the line's third column) to operate. If not configured and the volume is of type
748 LUKS2, the CID and the key are read from LUKS2 JSON token metadata instead. Use
749 <citerefentry><refentrytitle>systemd-cryptenroll</refentrytitle><manvolnum>1</manvolnum></citerefentry>
750 as simple tool for enrolling FIDO2 security tokens for LUKS2 volumes.</para>
752 <para>Use <command>systemd-cryptenroll --fido2-device=list</command> to list all suitable FIDO2
753 security tokens currently plugged in, along with their device nodes.</para>
755 <para>This option implements the following mechanism: the configured key is hashed via they HMAC
756 keyed hash function the FIDO2 device implements, keyed by a secret key embedded on the device. The
757 resulting hash value is Base64 encoded and used to unlock the LUKS2 volume. As it should not be
758 possible to extract the secret from the hardware token, it should not be possible to retrieve the
759 hashed key given the configured key — without possessing the hardware token.</para>
761 <para>Note that many security tokens that implement FIDO2 also implement PKCS#11, suitable for
762 unlocking volumes via the <option>pkcs11-uri=</option> option described above. Typically the newer,
763 simpler FIDO2 standard is preferable.</para>
765 <xi:include href="version-info.xml" xpointer="v248"/></listitem>
769 <term><option>fido2-cid=</option></term>
771 <listitem><para>Takes a Base64 encoded FIDO2 client ID to use for the FIDO2 unlock operation. If
772 specified, but <option>fido2-device=</option> is not, <option>fido2-device=auto</option> is
773 implied. If <option>fido2-device=</option> is used but <option>fido2-cid=</option> is not, the volume
774 must be of LUKS2 type, and the CID is read from the LUKS2 JSON token header. Use
775 <citerefentry><refentrytitle>systemd-cryptenroll</refentrytitle><manvolnum>1</manvolnum></citerefentry>
776 for enrolling a FIDO2 token in the LUKS2 header compatible with this automatic
779 <xi:include href="version-info.xml" xpointer="v248"/></listitem>
783 <term><option>fido2-rp=</option></term>
785 <listitem><para>Takes a string, configuring the FIDO2 Relying Party (rp) for the FIDO2 unlock
786 operation. If not specified, <literal>io.systemd.cryptsetup</literal> is used, except if the LUKS2
787 JSON token header contains a different value. It should normally not be necessary to override
790 <xi:include href="version-info.xml" xpointer="v248"/></listitem>
794 <term><option>fido2-pin=</option></term>
796 <listitem><para>Controls whether to require the user to enter a PIN when unlocking the volume (the
797 FIDO2 <literal>clientPin</literal> feature). This option only applies when in manual mode, i.e.
798 when <option>fido2-cid=</option> option is set. Defaults to neither true or false, but rather to
799 <constant>v248</constant> behavior, that is: try with no PIN first, but if token reports that PIN
800 is required, try again asking for PIN.</para>
802 <xi:include href="version-info.xml" xpointer="v257"/></listitem>
806 <term><option>fido2-up=</option></term>
808 <listitem><para>Controls whether to require the user to verify presence (tap the token, the FIDO2
809 <literal>up</literal> feature) when unlocking the volume. This option only applies when in manual
810 mode, i.e. when <option>fido2-cid=</option> option is set. Defaults to neither true or false,
811 but rather to <constant>v248</constant> behavior, that is: try with no UP first, but if token reports
812 that UP is required, try again with UP enabled.</para>
814 <xi:include href="version-info.xml" xpointer="v257"/></listitem>
818 <term><option>fido2-uv=</option></term>
820 <listitem><para>Controls whether to require user verification (the FIDO2 <literal>uv</literal> feature)
821 when unlocking the volume. This option only applies when in manual mode, i.e. when
822 <option>fido2-cid=</option> option is set. Defaults to neither true or false, but rather to
823 <constant>v248</constant> behavior, that is: omit configuring UV whatsoever.</para>
825 <xi:include href="version-info.xml" xpointer="v257"/></listitem>
829 <term><option>tpm2-device=</option></term>
831 <listitem><para>Takes either the special value <literal>auto</literal> or the path to a device node
832 (e.g. <filename>/dev/tpmrm0</filename>) referring to a TPM2 security chip. See below for an example
833 how to set up this mechanism for unlocking an encrypted volume with a TPM2 chip.</para>
835 <para>Use <option>tpm2-pcrs=</option> (see below) to configure the set of TPM2 PCRs to bind the
836 volume unlocking to. Use
837 <citerefentry><refentrytitle>systemd-cryptenroll</refentrytitle><manvolnum>1</manvolnum></citerefentry>
838 as simple tool for enrolling TPM2 security chips in LUKS2 volumes.</para>
840 <para>If specified as <literal>auto</literal> the TPM2 device is automatically discovered. Use
841 <command>systemd-cryptenroll --tpm2-device=list</command> to list all suitable TPM2 devices currently
842 available, along with their device nodes.</para>
844 <para>This option implements the following mechanism: when enrolling a TPM2 device via
845 <command>systemd-cryptenroll</command> on a LUKS2 volume, a randomized key unlocking the volume is
846 generated on the host and loaded into the TPM2 chip where it is encrypted with an asymmetric
847 "primary" key pair derived from the TPM2's internal "seed" key. Neither the seed key nor the primary
848 key are permitted to ever leave the TPM2 chip — however, the now encrypted randomized key may. It is
849 saved in the LUKS2 volume JSON token header. When unlocking the encrypted volume, the primary key
850 pair is generated on the TPM2 chip again (which works as long as the chip's seed key is correctly
851 maintained by the TPM2 chip), which is then used to decrypt (on the TPM2 chip) the encrypted key from
852 the LUKS2 volume JSON token header saved there during enrollment. The resulting decrypted key is then
853 used to unlock the volume. When the randomized key is encrypted the current values of the selected
854 PCRs (see below) are included in the operation, so that different PCR state results in different
855 encrypted keys and the decrypted key can only be recovered if the same PCR state is
858 <xi:include href="version-info.xml" xpointer="v248"/></listitem>
862 <term><option>tpm2-pcrs=</option></term>
864 <listitem><para>Takes a <literal>+</literal> separated list of numeric TPM2 PCR (i.e. "Platform
865 Configuration Register") indexes to bind the TPM2 volume unlocking to. This option is only useful
866 when TPM2 enrollment metadata is not available in the LUKS2 JSON token header already, the way
867 <command>systemd-cryptenroll</command> writes it there. If not used (and no metadata in the LUKS2
868 JSON token header defines it), defaults to a list of a single entry: PCR 7. Assign an empty string to
869 encode a policy that binds the key to no PCRs, making the key accessible to local programs regardless
870 of the current PCR state.</para>
872 <xi:include href="version-info.xml" xpointer="v248"/></listitem>
876 <term><option>tpm2-pin=</option></term>
878 <listitem><para>Takes a boolean argument, defaults to <literal>false</literal>. Controls whether
879 TPM2 volume unlocking is bound to a PIN in addition to PCRs. Similarly, this option is only useful
880 when TPM2 enrollment metadata is not available.</para>
882 <xi:include href="version-info.xml" xpointer="v251"/></listitem>
886 <term><option>tpm2-signature=</option></term>
888 <listitem><para>Takes an absolute path to a TPM2 PCR JSON signature file, as produced by the
889 <citerefentry><refentrytitle>systemd-measure</refentrytitle><manvolnum>1</manvolnum></citerefentry>
890 tool. This permits locking LUKS2 volumes to any PCR values for which a valid signature matching a
891 public key specified at key enrollment time can be provided. See
892 <citerefentry><refentrytitle>systemd-cryptenroll</refentrytitle><manvolnum>1</manvolnum></citerefentry>
893 for details on enrolling TPM2 PCR public keys. If this option is not specified but it is attempted to
894 unlock a LUKS2 volume with a signed TPM2 PCR enrollment, a suitable signature file
895 <filename>tpm2-pcr-signature.json</filename> is searched for in <filename>/etc/systemd/</filename>,
896 <filename>/run/systemd/</filename>, <filename>/usr/lib/systemd/</filename> (in this
899 <xi:include href="version-info.xml" xpointer="v252"/></listitem>
903 <term><option>tpm2-pcrlock=</option></term>
905 <listitem><para>Takes an absolute path to a TPM2 pcrlock policy file, as produced by the
906 <citerefentry><refentrytitle>systemd-pcrlock</refentrytitle><manvolnum>8</manvolnum></citerefentry>
907 tool. This permits locking LUKS2 volumes to a local policy of allowed PCR values with
909 <citerefentry><refentrytitle>systemd-cryptenroll</refentrytitle><manvolnum>1</manvolnum></citerefentry>
910 for details on enrolling TPM2 pcrlock policies. If this option is not specified but it is attempted
911 to unlock a LUKS2 volume with a TPM2 pcrlock enrollment, a suitable signature file
912 <filename>pcrlock.json</filename> is searched for in <filename>/run/systemd/</filename> and
913 <filename>/var/lib/systemd/</filename> (in this order).</para>
915 <xi:include href="version-info.xml" xpointer="v255"/></listitem>
919 <term><option>tpm2-measure-pcr=</option></term>
921 <listitem><para>Controls whether to measure the volume key of the encrypted volume to a TPM2 PCR. If
922 set to "no" (which is the default) no PCR extension is done. If set to "yes" the volume key is
923 measured into PCR 15. If set to a decimal integer in the range 0…23 the volume key is measured into
924 the specified PCR. The volume key is measured along with the activated volume name and its UUID. This
925 functionality is particularly useful for the encrypted volume backing the root file system, as it
926 then allows later TPM objects to be securely bound to the root file system and hence the specific
929 <xi:include href="version-info.xml" xpointer="v253"/></listitem>
933 <term><option>tpm2-measure-bank=</option></term>
935 <listitem><para>Selects one or more TPM2 PCR banks to measure the volume key into, as configured with
936 <option>tpm2-measure-pcr=</option> above. Multiple banks may be specified, separated by a colon
937 character. If not specified, automatically determines available and used banks. Expects a message
938 digest name (e.g. <literal>sha1</literal>, <literal>sha256</literal>, …) as argument, to identify the
941 <xi:include href="version-info.xml" xpointer="v253"/></listitem>
945 <term><option>token-timeout=</option></term>
947 <listitem><para>Specifies how long to wait at most for configured security devices (i.e. FIDO2,
948 PKCS#11, TPM2) to show up. Takes a time value in seconds (but other time units may be specified too,
949 see <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry>
950 for supported formats). Defaults to 30s. Once the specified timeout elapsed authentication via
951 password is attempted. Note that this timeout applies to waiting for the security device to show up —
952 it does not apply to the PIN prompt for the device (should one be needed) or similar. Pass 0 to turn
953 off the timeout and wait forever.</para>
955 <xi:include href="version-info.xml" xpointer="v250"/></listitem>
959 <term><option>try-empty-password=</option></term>
961 <listitem><para>Takes a boolean argument. If enabled, right before asking the user for a password it
962 is first attempted to unlock the volume with an empty password. This is useful for systems that are
963 initialized with an encrypted volume with only an empty password set, which shall be replaced with a
964 suitable password during first boot, but after activation.</para>
966 <xi:include href="version-info.xml" xpointer="v246"/></listitem>
970 <term><option>x-systemd.device-timeout=</option></term>
972 <listitem><para>Specifies how long systemd should wait for a block device to show up before
973 giving up on the entry. The argument is a time in seconds or explicitly specified units of
974 <literal>s</literal>, <literal>min</literal>, <literal>h</literal>, <literal>ms</literal>.
977 <xi:include href="version-info.xml" xpointer="v216"/></listitem>
981 <term><option>x-initrd.attach</option></term>
983 <listitem><para>Setup this encrypted block device in the initrd, similarly to
984 <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>
985 units marked with <option>x-initrd.mount</option>.</para>
987 <para>Although it is not necessary to mark the mount entry for the root file system with
988 <option>x-initrd.mount</option>, <option>x-initrd.attach</option> is still recommended with
989 the encrypted block device containing the root file system as otherwise systemd will
990 attempt to detach the device during the regular system shutdown while it is still in
991 use. With this option the device will still be detached but later after the root file
992 system is unmounted.</para>
994 <para>All other encrypted block devices that contain file systems mounted in the initrd should use
997 <xi:include href="version-info.xml" xpointer="v245"/>
1003 <para>At early boot and when the system manager configuration is
1004 reloaded, this file is translated into native systemd units by
1005 <citerefentry><refentrytitle>systemd-cryptsetup-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
1009 <title><constant>AF_UNIX</constant> Key Files</title>
1011 <para>If the key file path (as specified in the third column of <filename>/etc/crypttab</filename>
1012 entries, see above) refers to an <constant>AF_UNIX</constant> stream socket in the file system, the key
1013 is acquired by connecting to the socket and reading the key from the connection. The connection is made
1014 from an <constant>AF_UNIX</constant> socket name in the abstract namespace, see <citerefentry
1015 project='man-pages'><refentrytitle>unix</refentrytitle><manvolnum>7</manvolnum></citerefentry> for
1016 details. The source socket name is chosen according to the following format:</para>
1018 <programlisting><constant>NUL</constant> <replaceable>RANDOM</replaceable> /cryptsetup/ <replaceable>VOLUME</replaceable></programlisting>
1020 <para>In other words: a <constant>NUL</constant> byte (as required for abstract namespace sockets),
1021 followed by a random string (consisting of alphanumeric characters only), followed by the literal
1022 string <literal>/cryptsetup/</literal>, followed by the name of the volume to acquire they key
1023 for. For example, for the volume <literal>myvol</literal>:</para>
1025 <programlisting>\0d7067f78d9827418/cryptsetup/myvol</programlisting>
1027 <para>Services listening on the <constant>AF_UNIX</constant> stream socket may query the source socket
1028 name with <citerefentry
1029 project='man-pages'><refentrytitle>getpeername</refentrytitle><manvolnum>2</manvolnum></citerefentry>,
1030 and use this to determine which key to send, allowing a single listening socket to serve keys for
1031 multiple volumes. If the PKCS#11 logic is used (see above), the socket source name is picked in similar
1032 fashion, except that the literal string <literal>/cryptsetup-pkcs11/</literal> is used. And similarly for
1033 FIDO2 (<literal>/cryptsetup-fido2-salt/</literal>) and TPM2 (<literal>/cryptsetup-tpm2/</literal>).
1034 A different path component is used so that services providing key material know that the secret key was
1035 not requested directly, but instead an encrypted key that will be decrypted via the PKCS#11/FIDO2/TPM2
1036 logic to acquire the final secret key.</para>
1040 <title>Examples</title>
1042 <title>/etc/crypttab example</title>
1043 <para>Set up four encrypted block devices. One using LUKS for normal storage, another one for usage as
1044 a swap device and two TrueCrypt volumes. For the fourth device, the option string is interpreted as two
1045 options <literal>cipher=xchacha12,aes-adiantum-plain64</literal>,
1046 <literal>keyfile-timeout=10s</literal>.</para>
1048 <programlisting>luks UUID=2505567a-9e27-4efe-a4d5-15ad146c258b
1049 swap /dev/sda7 /dev/urandom swap
1050 truecrypt /dev/sda2 /etc/container_password tcrypt
1051 hidden /mnt/tc_hidden /dev/null tcrypt-hidden,tcrypt-keyfile=/etc/keyfile
1052 external /dev/sda3 keyfile:LABEL=keydev keyfile-timeout=10s,cipher=xchacha12\,aes-adiantum-plain64
1057 <title>Yubikey-based PKCS#11 Volume Unlocking Example</title>
1059 <para>The PKCS#11 logic allows hooking up any compatible security token that is capable of storing RSA
1060 or EC cryptographic keys for unlocking an encrypted volume. Here's an example how to set up a Yubikey
1061 security token for this purpose on a LUKS2 volume, using <citerefentry
1062 project='debian'><refentrytitle>ykmap</refentrytitle><manvolnum>1</manvolnum></citerefentry> from the
1063 yubikey-manager project to initialize the token and
1064 <citerefentry><refentrytitle>systemd-cryptenroll</refentrytitle><manvolnum>1</manvolnum></citerefentry>
1065 to add it in the LUKS2 volume:</para>
1067 <programlisting><xi:include href="yubikey-crypttab.sh" parse="text" /></programlisting>
1069 <para>A few notes on the above:</para>
1072 <listitem><para>We use RSA2048, which is the longest key size current Yubikeys support</para></listitem>
1073 <listitem><para>We use Yubikey key slot 9d, since that's apparently the keyslot to use for decryption purposes,
1075 <ulink url="https://developers.yubico.com/PIV/Introduction/Certificate_slots.html">Yubico PIV certificate slots</ulink>.
1081 <title>FIDO2 Volume Unlocking Example</title>
1083 <para>The FIDO2 logic allows using any compatible FIDO2 security token that implements the
1084 <literal>hmac-secret</literal> extension for unlocking an encrypted volume. Here's an example how to
1085 set up a FIDO2 security token for this purpose for a LUKS2 volume, using
1086 <citerefentry><refentrytitle>systemd-cryptenroll</refentrytitle><manvolnum>1</manvolnum></citerefentry>:</para>
1088 <programlisting><xi:include href="fido2-crypttab.sh" parse="text" /></programlisting>
1092 <title>TPM2 Volume Unlocking Example</title>
1094 <para>The TPM2 logic allows using any TPM2 chip supported by the Linux kernel for unlocking an
1095 encrypted volume. Here's an example how to set up a TPM2 chip for this purpose for a LUKS2 volume,
1097 <citerefentry><refentrytitle>systemd-cryptenroll</refentrytitle><manvolnum>1</manvolnum></citerefentry>:</para>
1099 <programlisting><xi:include href="tpm2-crypttab.sh" parse="text" /></programlisting>
1104 <title>See Also</title>
1105 <para><simplelist type="inline">
1106 <member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
1107 <member><citerefentry><refentrytitle>systemd-cryptsetup@.service</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
1108 <member><citerefentry><refentrytitle>systemd-cryptsetup-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
1109 <member><citerefentry><refentrytitle>systemd-cryptenroll</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
1110 <member><citerefentry project='man-pages'><refentrytitle>fstab</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
1111 <member><citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
1112 <member><citerefentry project='man-pages'><refentrytitle>mkswap</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
1113 <member><citerefentry project='man-pages'><refentrytitle>mke2fs</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
1114 </simplelist></para>