3 <!DOCTYPE refentry PUBLIC
"-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
5 SPDX-License-Identifier: LGPL-2.1+
7 This file is part of systemd.
9 Copyright 2012 Lennart Poettering
11 This is based on crypttab(5) from Fedora's initscripts package, which in
12 turn is based on Debian's version.
14 The Red Hat version has been written by Miloslav Trmac <mitr@redhat.com>.
17 <refentry id=
"crypttab" conditional='HAVE_LIBCRYPTSETUP'
>
20 <title>crypttab
</title>
21 <productname>systemd
</productname>
25 <contrib>Documentation
</contrib>
26 <firstname>Miloslav
</firstname>
27 <surname>Trmac
</surname>
28 <email>mitr@redhat.com
</email>
31 <contrib>Documentation
</contrib>
32 <firstname>Lennart
</firstname>
33 <surname>Poettering
</surname>
34 <email>lennart@poettering.net
</email>
40 <refentrytitle>crypttab
</refentrytitle>
41 <manvolnum>5</manvolnum>
45 <refname>crypttab
</refname>
46 <refpurpose>Configuration for encrypted block devices
</refpurpose>
50 <para><filename>/etc/crypttab
</filename></para>
54 <title>Description
</title>
56 <para>The
<filename>/etc/crypttab
</filename> file describes
57 encrypted block devices that are set up during system boot.
</para>
59 <para>Empty lines and lines starting with the
<literal>#
</literal>
60 character are ignored. Each of the remaining lines describes one
61 encrypted block device. Fields are delimited by white space.
</para>
63 <para>Each line is in the form
<programlisting><replaceable>name
</replaceable> <replaceable>encrypted-device
</replaceable> <replaceable>password
</replaceable> <replaceable>options
</replaceable></programlisting>
64 The first two fields are mandatory, the remaining two are
67 <para>Setting up encrypted block devices using this file supports
68 three encryption modes: LUKS, TrueCrypt and plain. See
69 <citerefentry project='die-net'
><refentrytitle>cryptsetup
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
70 for more information about each mode. When no mode is specified in
71 the options field and the block device contains a LUKS signature,
72 it is opened as a LUKS device; otherwise, it is assumed to be in
73 raw dm-crypt (plain mode) format.
</para>
75 <para>The first field contains the name of the resulting encrypted
76 block device; the device is set up within
77 <filename>/dev/mapper/
</filename>.
</para>
79 <para>The second field contains a path to the underlying block
80 device or file, or a specification of a block device via
81 <literal>UUID=
</literal> followed by the UUID.
</para>
83 <para>The third field specifies the encryption password. If the
84 field is not present or the password is set to
85 <literal>none
</literal> or
<literal>-
</literal>, the password has
86 to be manually entered during system boot. Otherwise, the field is
87 interpreted as an absolute path to a file containing the encryption
88 password. For swap encryption,
<filename>/dev/urandom
</filename>
89 or the hardware device
<filename>/dev/hw_random
</filename> can be
90 used as the password file; using
<filename>/dev/random
</filename>
91 may prevent boot completion if the system does not have enough
92 entropy to generate a truly random encryption key.
</para>
94 <para>The fourth field, if present, is a comma-delimited list of
95 options. The following options are recognized:
</para>
97 <variablelist class='fstab-options'
>
100 <term><option>cipher=
</option></term>
102 <listitem><para>Specifies the cipher to use. See
103 <citerefentry project='die-net'
><refentrytitle>cryptsetup
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
104 for possible values and the default value of this option. A
105 cipher with unpredictable IV values, such as
106 <literal>aes-cbc-essiv:sha256
</literal>, is
107 recommended.
</para></listitem>
111 <term><option>discard
</option></term>
113 <listitem><para>Allow discard requests to be passed through the encrypted block
114 device. This improves performance on SSD storage but has security implications.
119 <term><option>hash=
</option></term>
121 <listitem><para>Specifies the hash to use for password
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>header=
</option></term>
131 <listitem><para>Use a detached (separated) metadata device or
132 file where the LUKS header is stored. This option is only
133 relevant for LUKS devices. See
134 <citerefentry project='die-net'
><refentrytitle>cryptsetup
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
135 for possible values and the default value of this
136 option.
</para></listitem>
140 <term><option>keyfile-offset=
</option></term>
142 <listitem><para>Specifies the number of bytes to skip at the
143 start of the key file. See
144 <citerefentry project='die-net'
><refentrytitle>cryptsetup
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
145 for possible values and the default value of this
146 option.
</para></listitem>
150 <term><option>keyfile-size=
</option></term>
152 <listitem><para>Specifies the maximum number of bytes to read
153 from the key file. See
154 <citerefentry project='die-net'
><refentrytitle>cryptsetup
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
155 for possible values and the default value of this option. This
156 option is ignored in plain encryption mode, as the key file
157 size is then given by the key size.
</para></listitem>
161 <term><option>key-slot=
</option></term>
163 <listitem><para>Specifies the key slot to compare the
164 passphrase or key against. If the key slot does not match the
165 given passphrase or key, but another would, the setup of the
166 device will fail regardless. This option implies
167 <option>luks
</option>. See
168 <citerefentry project='die-net'
><refentrytitle>cryptsetup
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
169 for possible values. The default is to try all key slots in
170 sequential order.
</para></listitem>
174 <term><option>luks
</option></term>
176 <listitem><para>Force LUKS mode. When this mode is used, the
177 following options are ignored since they are provided by the
178 LUKS header on the device:
<option>cipher=
</option>,
179 <option>hash=
</option>,
180 <option>size=
</option>.
</para></listitem>
184 <term><option>_netdev
</option></term>
186 <listitem><para>Marks this cryptsetup device as requiring network. It will be
187 started after the network is available, similarly to
188 <citerefentry><refentrytitle>systemd.mount
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
189 units marked with
<option>_netdev
</option>. The service unit to set up this device
190 will be ordered between
<filename>remote-fs-pre.target
</filename> and
191 <filename>remote-cryptsetup.target
</filename>, instead of
192 <filename>cryptsetup-pre.target
</filename> and
193 <filename>cryptsetup.target
</filename>.
</para>
195 <para>Hint: if this device is used for a mount point that is specified in
196 <citerefentry project='man-pages'
><refentrytitle>fstab
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
197 the
<option>_netdev
</option> option should also be used for the mount
198 point. Otherwise, a dependency loop might be created where the mount point
199 will be pulled in by
<filename>local-fs.target
</filename>, while the
200 service to configure the network is usually only started
<emphasis>after
</emphasis>
201 the local file system has been mounted.
</para>
206 <term><option>noauto
</option></term>
208 <listitem><para>This device will not be added to
<filename>cryptsetup.target
</filename>.
209 This means that it will not be automatically unlocked on boot, unless something else pulls
210 it in. In particular, if the device is used for a mount point, it'll be unlocked
211 automatically during boot, unless the mount point itself is also disabled with
212 <option>noauto
</option>.
</para></listitem>
216 <term><option>nofail
</option></term>
218 <listitem><para>This device will not be a hard dependency of
219 <filename>cryptsetup.target
</filename>. It'll be still pulled in and started, but the system
220 will not wait for the device to show up and be unlocked, and boot will not fail if this is
221 unsuccessful. Note that other units that depend on the unlocked device may still fail. In
222 particular, if the device is used for a mount point, the mount point itself is also needs to
223 have
<option>noauto
</option> option, or the boot will fail if the device is not unlocked
224 successfully.
</para></listitem>
228 <term><option>offset=
</option></term>
230 <listitem><para>Start offset in the backend device, in
512-byte sectors. This
231 option is only relevant for plain devices.
</para></listitem>
235 <term><option>plain
</option></term>
237 <listitem><para>Force plain encryption mode.
</para></listitem>
241 <term><option>read-only
</option></term><term><option>readonly
</option></term>
243 <listitem><para>Set up the encrypted block device in read-only
244 mode.
</para></listitem>
248 <term><option>skip=
</option></term>
250 <listitem><para>How many
512-byte sectors of the encrypted data to skip at the
251 beginning. This is different from the
<option>offset=
</option> option with respect
252 to the sector numbers used in initialization vector (IV) calculation. Using
253 <option>offset=
</option> will shift the IV calculation by the same negative
254 amount. Hence, if
<option>offset=
<replaceable>n
</replaceable></option> is given,
255 sector
<replaceable>n
</replaceable> will get a sector number of
0 for the IV
256 calculation. Using
<option>skip=
</option> causes sector
257 <replaceable>n
</replaceable> to also be the first sector of the mapped device, but
258 with its number for IV generation being
<replaceable>n
</replaceable>.
</para>
260 <para>This option is only relevant for plain devices.
</para>
265 <term><option>size=
</option></term>
267 <listitem><para>Specifies the key size in bits. See
268 <citerefentry project='die-net'
><refentrytitle>cryptsetup
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
269 for possible values and the default value of this
270 option.
</para></listitem>
274 <term><option>swap
</option></term>
276 <listitem><para>The encrypted block device will be used as a
277 swap device, and will be formatted accordingly after setting
278 up the encrypted block device, with
279 <citerefentry project='man-pages'
><refentrytitle>mkswap
</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
280 This option implies
<option>plain
</option>.
</para>
282 <para>WARNING: Using the
<option>swap
</option> option will
283 destroy the contents of the named partition during every boot,
284 so make sure the underlying block device is specified
285 correctly.
</para></listitem>
289 <term><option>tcrypt
</option></term>
291 <listitem><para>Use TrueCrypt encryption mode. When this mode
292 is used, the following options are ignored since they are
293 provided by the TrueCrypt header on the device or do not
295 <option>cipher=
</option>,
296 <option>hash=
</option>,
297 <option>keyfile-offset=
</option>,
298 <option>keyfile-size=
</option>,
299 <option>size=
</option>.
</para>
301 <para>When this mode is used, the passphrase is read from the
302 key file given in the third field. Only the first line of this
303 file is read, excluding the new line character.
</para>
305 <para>Note that the TrueCrypt format uses both passphrase and
306 key files to derive a password for the volume. Therefore, the
307 passphrase and all key files need to be provided. Use
308 <option>tcrypt-keyfile=
</option> to provide the absolute path
309 to all key files. When using an empty passphrase in
310 combination with one or more key files, use
311 <literal>/dev/null
</literal> as the password file in the third
312 field.
</para></listitem>
316 <term><option>tcrypt-hidden
</option></term>
318 <listitem><para>Use the hidden TrueCrypt volume. This option
319 implies
<option>tcrypt
</option>.
</para>
321 <para>This will map the hidden volume that is inside of the
322 volume provided in the second field. Please note that there is
323 no protection for the hidden volume if the outer volume is
325 <citerefentry project='die-net'
><refentrytitle>cryptsetup
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
326 for more information on this limitation.
</para></listitem>
330 <term><option>tcrypt-keyfile=
</option></term>
332 <listitem><para>Specifies the absolute path to a key file to
333 use for a TrueCrypt volume. This implies
334 <option>tcrypt
</option> and can be used more than once to
335 provide several key files.
</para>
337 <para>See the entry for
<option>tcrypt
</option> on the
338 behavior of the passphrase and key files when using TrueCrypt
339 encryption mode.
</para></listitem>
343 <term><option>tcrypt-system
</option></term>
345 <listitem><para>Use TrueCrypt in system encryption mode. This
346 option implies
<option>tcrypt
</option>.
</para></listitem>
350 <term><option>tcrypt-veracrypt
</option></term>
352 <listitem><para>Check for a VeraCrypt volume. VeraCrypt is a fork of
353 TrueCrypt that is mostly compatible, but uses different, stronger key
354 derivation algorithms that cannot be detected without this flag.
355 Enabling this option could substantially slow down unlocking, because
356 VeraCrypt's key derivation takes much longer than TrueCrypt's. This
357 option implies
<option>tcrypt
</option>.
</para></listitem>
361 <term><option>timeout=
</option></term>
363 <listitem><para>Specifies the timeout for querying for a
364 password. If no unit is specified, seconds is used. Supported
365 units are s, ms, us, min, h, d. A timeout of
0 waits
366 indefinitely (which is the default).
</para></listitem>
370 <term><option>tmp
</option></term>
372 <listitem><para>The encrypted block device will be prepared
373 for using it as
<filename>/tmp
</filename>; it will be
375 <citerefentry project='man-pages'
><refentrytitle>mke2fs
</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
376 This option implies
<option>plain
</option>.
</para>
378 <para>WARNING: Using the
<option>tmp
</option> option will
379 destroy the contents of the named partition during every boot,
380 so make sure the underlying block device is specified
381 correctly.
</para></listitem>
385 <term><option>tries=
</option></term>
387 <listitem><para>Specifies the maximum number of times the user
388 is queried for a password. The default is
3. If set to
0, the
389 user is queried for a password indefinitely.
</para></listitem>
393 <term><option>verify
</option></term>
395 <listitem><para> If the encryption password is read from
396 console, it has to be entered twice to prevent
397 typos.
</para></listitem>
401 <term><option>x-systemd.device-timeout=
</option></term>
403 <listitem><para>Specifies how long systemd should wait for a device to show up
404 before giving up on the entry. The argument is a time in seconds or explicitly
406 <literal>s
</literal>,
407 <literal>min
</literal>,
408 <literal>h
</literal>,
409 <literal>ms
</literal>.
415 <para>At early boot and when the system manager configuration is
416 reloaded, this file is translated into native systemd units by
417 <citerefentry><refentrytitle>systemd-cryptsetup-generator
</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
</para>
421 <title>Example
</title>
423 <title>/etc/crypttab example
</title>
424 <para>Set up four encrypted block devices. One using LUKS for
425 normal storage, another one for usage as a swap device and two
426 TrueCrypt volumes.
</para>
428 <programlisting>luks UUID=
2505567a-
9e27-
4efe-a4d5-
15ad146c258b
429 swap /dev/sda7 /dev/urandom swap
430 truecrypt /dev/sda2 /etc/container_password tcrypt
431 hidden /mnt/tc_hidden /dev/null tcrypt-hidden,tcrypt-keyfile=/etc/keyfile
</programlisting>
436 <title>See Also
</title>
438 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
439 <citerefentry><refentrytitle>systemd-cryptsetup@.service
</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
440 <citerefentry><refentrytitle>systemd-cryptsetup-generator
</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
441 <citerefentry project='man-pages'
><refentrytitle>fstab
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
442 <citerefentry project='die-net'
><refentrytitle>cryptsetup
</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
443 <citerefentry project='man-pages'
><refentrytitle>mkswap
</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
444 <citerefentry project='man-pages'
><refentrytitle>mke2fs
</refentrytitle><manvolnum>8</manvolnum></citerefentry>