3 <!DOCTYPE refentry PUBLIC
"-//OASIS//DTD DocBook XML V4.5//EN"
4 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
6 SPDX-License-Identifier: LGPL-2.1+
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
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>
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>
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>
63 <para>The third field specifies an absolute path to a file to read the encryption key from. Optionally,
64 the path may be followed by
<literal>:
</literal> and an fstab device specification (e.g. starting with
65 <literal>LABEL=
</literal> or similar); in which case, the path is relative to the device file system
66 root. If the field is not present or set to
<literal>none
</literal> or
<literal>-
</literal>, a key file
67 named after the volume to unlock (i.e. the first column of the line), suffixed with
68 <filename>.key
</filename> is automatically loaded from the
<filename>/etc/cryptsetup-keys.d/
</filename>
69 and
<filename>/run/cryptsetup-keys.d/
</filename> directories, if present. Otherwise, the password has to
70 be manually entered during system boot. For swap encryption,
<filename>/dev/urandom
</filename> may be
71 used as key file.
</para>
73 <para>The fourth field, if present, is a comma-delimited list of
74 options. The following options are recognized:
</para>
76 <variablelist class='fstab-options'
>
79 <term><option>cipher=
</option></term>
81 <listitem><para>Specifies the cipher to use. See
82 <citerefentry project='die-net'
><refentrytitle>cryptsetup
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
83 for possible values and the default value of this option. A
84 cipher with unpredictable IV values, such as
85 <literal>aes-cbc-essiv:sha256
</literal>, is
86 recommended.
</para></listitem>
90 <term><option>discard
</option></term>
92 <listitem><para>Allow discard requests to be passed through the encrypted block
93 device. This improves performance on SSD storage but has security implications.
98 <term><option>hash=
</option></term>
100 <listitem><para>Specifies the hash to use for password
102 <citerefentry project='die-net'
><refentrytitle>cryptsetup
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
103 for possible values and the default value of this
104 option.
</para></listitem>
108 <term><option>header=
</option></term>
110 <listitem><para>Use a detached (separated) metadata device or
111 file where the LUKS header is stored. This option is only
112 relevant for LUKS devices. See
113 <citerefentry project='die-net'
><refentrytitle>cryptsetup
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
114 for possible values and the default value of this
115 option.
</para></listitem>
119 <term><option>keyfile-offset=
</option></term>
121 <listitem><para>Specifies the number of bytes to skip at the
122 start of the key file. See
123 <citerefentry project='die-net'
><refentrytitle>cryptsetup
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
124 for possible values and the default value of this
125 option.
</para></listitem>
129 <term><option>keyfile-size=
</option></term>
131 <listitem><para>Specifies the maximum number of bytes to read
132 from the key file. See
133 <citerefentry project='die-net'
><refentrytitle>cryptsetup
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
134 for possible values and the default value of this option. This
135 option is ignored in plain encryption mode, as the key file
136 size is then given by the key size.
</para></listitem>
140 <term><option>keyfile-erase
</option></term>
142 <listitem><para>If enabled, the specified key file is erased after the volume is activated or when
143 activation fails. This is in particular useful when the key file is only acquired transiently before
144 activation (e.g. via a file in
<filename>/run/
</filename>, generated by a service running before
145 activation), and shall be removed after use. Defaults to off.
</para></listitem>
149 <term><option>key-slot=
</option></term>
151 <listitem><para>Specifies the key slot to compare the
152 passphrase or key against. If the key slot does not match the
153 given passphrase or key, but another would, the setup of the
154 device will fail regardless. This option implies
155 <option>luks
</option>. See
156 <citerefentry project='die-net'
><refentrytitle>cryptsetup
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
157 for possible values. The default is to try all key slots in
158 sequential order.
</para></listitem>
162 <term><option>keyfile-timeout=
</option></term>
164 <listitem><para> Specifies the timeout for the device on
165 which the key file resides and falls back to a password if
166 it could not be mounted. See
167 <citerefentry><refentrytitle>systemd-cryptsetup-generator
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
168 for key files on external devices.
173 <term><option>luks
</option></term>
175 <listitem><para>Force LUKS mode. When this mode is used, the
176 following options are ignored since they are provided by the
177 LUKS header on the device:
<option>cipher=
</option>,
178 <option>hash=
</option>,
179 <option>size=
</option>.
</para></listitem>
183 <term><option>bitlk
</option></term>
185 <listitem><para>Decrypt Bitlocker drive. Encryption parameters
186 are deduced by cryptsetup from Bitlocker header.
</para></listitem>
190 <term><option>_netdev
</option></term>
192 <listitem><para>Marks this cryptsetup device as requiring network. It will be
193 started after the network is available, similarly to
194 <citerefentry><refentrytitle>systemd.mount
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
195 units marked with
<option>_netdev
</option>. The service unit to set up this device
196 will be ordered between
<filename>remote-fs-pre.target
</filename> and
197 <filename>remote-cryptsetup.target
</filename>, instead of
198 <filename>cryptsetup-pre.target
</filename> and
199 <filename>cryptsetup.target
</filename>.
</para>
201 <para>Hint: if this device is used for a mount point that is specified in
202 <citerefentry project='man-pages'
><refentrytitle>fstab
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
203 the
<option>_netdev
</option> option should also be used for the mount
204 point. Otherwise, a dependency loop might be created where the mount point
205 will be pulled in by
<filename>local-fs.target
</filename>, while the
206 service to configure the network is usually only started
<emphasis>after
</emphasis>
207 the local file system has been mounted.
</para>
212 <term><option>noauto
</option></term>
214 <listitem><para>This device will not be added to
<filename>cryptsetup.target
</filename>.
215 This means that it will not be automatically unlocked on boot, unless something else pulls
216 it in. In particular, if the device is used for a mount point, it'll be unlocked
217 automatically during boot, unless the mount point itself is also disabled with
218 <option>noauto
</option>.
</para></listitem>
222 <term><option>nofail
</option></term>
224 <listitem><para>This device will not be a hard dependency of
225 <filename>cryptsetup.target
</filename>. It'll still be pulled in and started, but the system
226 will not wait for the device to show up and be unlocked, and boot will not fail if this is
227 unsuccessful. Note that other units that depend on the unlocked device may still fail. In
228 particular, if the device is used for a mount point, the mount point itself also needs to
229 have the
<option>nofail
</option> option, or the boot will fail if the device is not unlocked
230 successfully.
</para></listitem>
234 <term><option>offset=
</option></term>
236 <listitem><para>Start offset in the backend device, in
512-byte sectors. This
237 option is only relevant for plain devices.
</para></listitem>
241 <term><option>plain
</option></term>
243 <listitem><para>Force plain encryption mode.
</para></listitem>
247 <term><option>read-only
</option></term><term><option>readonly
</option></term>
249 <listitem><para>Set up the encrypted block device in read-only
250 mode.
</para></listitem>
254 <term><option>same-cpu-crypt
</option></term>
256 <listitem><para>Perform encryption using the same cpu that IO was submitted on. The default is to use
257 an unbound workqueue so that encryption work is automatically balanced between available CPUs.
</para>
258 <para>This requires kernel
4.0 or newer.
</para>
263 <term><option>submit-from-crypt-cpus
</option></term>
265 <listitem><para>Disable offloading writes to a separate thread after encryption. There are some
266 situations where offloading write bios from the encryption threads to a single thread degrades
267 performance significantly. The default is to offload write bios to the same thread because it benefits
268 CFQ to have writes submitted using the same context.
</para>
269 <para>This requires kernel
4.0 or newer.
</para>
274 <term><option>skip=
</option></term>
276 <listitem><para>How many
512-byte sectors of the encrypted data to skip at the
277 beginning. This is different from the
<option>offset=
</option> option with respect
278 to the sector numbers used in initialization vector (IV) calculation. Using
279 <option>offset=
</option> will shift the IV calculation by the same negative
280 amount. Hence, if
<option>offset=
<replaceable>n
</replaceable></option> is given,
281 sector
<replaceable>n
</replaceable> will get a sector number of
0 for the IV
282 calculation. Using
<option>skip=
</option> causes sector
283 <replaceable>n
</replaceable> to also be the first sector of the mapped device, but
284 with its number for IV generation being
<replaceable>n
</replaceable>.
</para>
286 <para>This option is only relevant for plain devices.
</para>
291 <term><option>size=
</option></term>
293 <listitem><para>Specifies the key size in bits. See
294 <citerefentry project='die-net'
><refentrytitle>cryptsetup
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
295 for possible values and the default value of this
296 option.
</para></listitem>
300 <term><option>sector-size=
</option></term>
302 <listitem><para>Specifies the sector size in bytes. See
303 <citerefentry project='die-net'
><refentrytitle>cryptsetup
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
304 for possible values and the default value of this
305 option.
</para></listitem>
309 <term><option>swap
</option></term>
311 <listitem><para>The encrypted block device will be used as a
312 swap device, and will be formatted accordingly after setting
313 up the encrypted block device, with
314 <citerefentry project='man-pages'
><refentrytitle>mkswap
</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
315 This option implies
<option>plain
</option>.
</para>
317 <para>WARNING: Using the
<option>swap
</option> option will
318 destroy the contents of the named partition during every boot,
319 so make sure the underlying block device is specified
320 correctly.
</para></listitem>
324 <term><option>tcrypt
</option></term>
326 <listitem><para>Use TrueCrypt encryption mode. When this mode
327 is used, the following options are ignored since they are
328 provided by the TrueCrypt header on the device or do not
330 <option>cipher=
</option>,
331 <option>hash=
</option>,
332 <option>keyfile-offset=
</option>,
333 <option>keyfile-size=
</option>,
334 <option>size=
</option>.
</para>
336 <para>When this mode is used, the passphrase is read from the
337 key file given in the third field. Only the first line of this
338 file is read, excluding the new line character.
</para>
340 <para>Note that the TrueCrypt format uses both passphrase and
341 key files to derive a password for the volume. Therefore, the
342 passphrase and all key files need to be provided. Use
343 <option>tcrypt-keyfile=
</option> to provide the absolute path
344 to all key files. When using an empty passphrase in
345 combination with one or more key files, use
346 <literal>/dev/null
</literal> as the password file in the third
347 field.
</para></listitem>
351 <term><option>tcrypt-hidden
</option></term>
353 <listitem><para>Use the hidden TrueCrypt volume. This option
354 implies
<option>tcrypt
</option>.
</para>
356 <para>This will map the hidden volume that is inside of the
357 volume provided in the second field. Please note that there is
358 no protection for the hidden volume if the outer volume is
360 <citerefentry project='die-net'
><refentrytitle>cryptsetup
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
361 for more information on this limitation.
</para></listitem>
365 <term><option>tcrypt-keyfile=
</option></term>
367 <listitem><para>Specifies the absolute path to a key file to
368 use for a TrueCrypt volume. This implies
369 <option>tcrypt
</option> and can be used more than once to
370 provide several key files.
</para>
372 <para>See the entry for
<option>tcrypt
</option> on the
373 behavior of the passphrase and key files when using TrueCrypt
374 encryption mode.
</para></listitem>
378 <term><option>tcrypt-system
</option></term>
380 <listitem><para>Use TrueCrypt in system encryption mode. This
381 option implies
<option>tcrypt
</option>.
</para></listitem>
385 <term><option>tcrypt-veracrypt
</option></term>
387 <listitem><para>Check for a VeraCrypt volume. VeraCrypt is a fork of
388 TrueCrypt that is mostly compatible, but uses different, stronger key
389 derivation algorithms that cannot be detected without this flag.
390 Enabling this option could substantially slow down unlocking, because
391 VeraCrypt's key derivation takes much longer than TrueCrypt's. This
392 option implies
<option>tcrypt
</option>.
</para></listitem>
396 <term><option>timeout=
</option></term>
398 <listitem><para>Specifies the timeout for querying for a
399 password. If no unit is specified, seconds is used. Supported
400 units are s, ms, us, min, h, d. A timeout of
0 waits
401 indefinitely (which is the default).
</para></listitem>
405 <term><option>tmp=
</option></term>
407 <listitem><para>The encrypted block device will be prepared for using it as
408 <filename>/tmp/
</filename>; it will be formatted using
<citerefentry
409 project='man-pages'
><refentrytitle>mkfs
</refentrytitle><manvolnum>8</manvolnum></citerefentry>. Takes
410 a file system type as argument, such as
<literal>ext4
</literal>,
<literal>xfs
</literal> or
411 <literal>btrfs
</literal>. If no argument is specified defaults to
<literal>ext4
</literal>. This
412 option implies
<option>plain
</option>.
</para>
414 <para>WARNING: Using the
<option>tmp
</option> option will destroy the contents of the named partition
415 during every boot, so make sure the underlying block device is specified correctly.
</para></listitem>
419 <term><option>tries=
</option></term>
421 <listitem><para>Specifies the maximum number of times the user
422 is queried for a password. The default is
3. If set to
0, the
423 user is queried for a password indefinitely.
</para></listitem>
427 <term><option>verify
</option></term>
429 <listitem><para>If the encryption password is read from console, it has to be entered twice to
430 prevent typos.
</para></listitem>
434 <term><option>pkcs11-uri=
</option></term>
436 <listitem><para>Takes a
<ulink url=
"https://tools.ietf.org/html/rfc7512">RFC7512 PKCS#
11 URI
</ulink>
437 pointing to a private RSA key which is used to decrypt the key specified in the third column of the
438 line. This is useful for unlocking encrypted volumes through security tokens or smartcards. See below
439 for an example how to set up this mechanism for unlocking a LUKS volume with a YubiKey security
440 token. The specified URI can refer directly to a private RSA key stored on a token or alternatively
441 just to a slot or token, in which case a search for a suitable private RSA key will be performed. In
442 this case if multiple suitable objects are found the token is refused. The key configured in the
443 third column is passed as is to RSA decryption. The resulting decrypted key is then base64 encoded
444 before it is used to unlock the LUKS volume.
</para></listitem>
448 <term><option>try-empty-password=
</option></term>
450 <listitem><para>Takes a boolean argument. If enabled, right before asking the user for a password it
451 is first attempted to unlock the volume with an empty password. This is useful for systems that are
452 initialized with an encrypted volume with only an empty password set, which shall be replaced with a
453 suitable password during first boot, but after activation.
</para></listitem>
457 <term><option>x-systemd.device-timeout=
</option></term>
459 <listitem><para>Specifies how long systemd should wait for a device to show up
460 before giving up on the entry. The argument is a time in seconds or explicitly
462 <literal>s
</literal>,
463 <literal>min
</literal>,
464 <literal>h
</literal>,
465 <literal>ms
</literal>.
470 <term><option>x-initrd.attach
</option></term>
472 <listitem><para>Setup this encrypted block device in the initramfs, similarly to
473 <citerefentry><refentrytitle>systemd.mount
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
474 units marked with
<option>x-initrd.mount
</option>.
</para>
476 <para>Although it's not necessary to mark the mount entry for the root file system with
477 <option>x-initrd.mount
</option>,
<option>x-initrd.attach
</option> is still recommended with
478 the encrypted block device containing the root file system as otherwise systemd will
479 attempt to detach the device during the regular system shutdown while it's still in
480 use. With this option the device will still be detached but later after the root file
481 system is unmounted.
</para>
483 <para>All other encrypted block devices that contain file systems mounted in the initramfs
484 should use this option.
</para>
490 <para>At early boot and when the system manager configuration is
491 reloaded, this file is translated into native systemd units by
492 <citerefentry><refentrytitle>systemd-cryptsetup-generator
</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
</para>
496 <title>Examples
</title>
498 <title>/etc/crypttab example
</title>
499 <para>Set up four encrypted block devices. One using LUKS for
500 normal storage, another one for usage as a swap device and two
501 TrueCrypt volumes.
</para>
503 <programlisting>luks UUID=
2505567a-
9e27-
4efe-a4d5-
15ad146c258b
504 swap /dev/sda7 /dev/urandom swap
505 truecrypt /dev/sda2 /etc/container_password tcrypt
506 hidden /mnt/tc_hidden /dev/null tcrypt-hidden,tcrypt-keyfile=/etc/keyfile
507 external /dev/sda3 keyfile:LABEL=keydev keyfile-timeout=
10s
</programlisting>
511 <title>Yubikey-based Volume Unlocking Example
</title>
513 <para>The PKCS#
11 logic allows hooking up any compatible security token that is capable of storing RSA
514 decryption keys. Here's an example how to set up a Yubikey security token for this purpose, using
515 <command>ykman
</command> from the yubikey-manager project:
</para>
517 <programlisting><xi:include href=
"yubikey-crypttab.sh" parse=
"text" /></programlisting>
519 <para>A few notes on the above:
</para>
522 <listitem><para>We use RSA (and not ECC), since Yubikeys support PKCS#
11 Decrypt() only for RSA keys
</para></listitem>
523 <listitem><para>We use RSA2048, which is the longest key size current Yubikeys support
</para></listitem>
524 <listitem><para>LUKS key size must be shorter than
2048bit due to RSA padding, hence we use
128 bytes
</para></listitem>
525 <listitem><para>We use Yubikey key slot
9d, since that's apparently the keyslot to use for decryption purposes,
526 <ulink url=
"https://developers.yubico.com/PIV/Introduction/Certificate_slots.html">see
527 documentation
</ulink>.
</para></listitem>
534 <title>See Also
</title>
536 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
537 <citerefentry><refentrytitle>systemd-cryptsetup@.service
</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
538 <citerefentry><refentrytitle>systemd-cryptsetup-generator
</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
539 <citerefentry project='man-pages'
><refentrytitle>fstab
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
540 <citerefentry project='die-net'
><refentrytitle>cryptsetup
</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
541 <citerefentry project='man-pages'
><refentrytitle>mkswap
</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
542 <citerefentry project='man-pages'
><refentrytitle>mke2fs
</refentrytitle><manvolnum>8</manvolnum></citerefentry>