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 systemd is free software; you can redistribute it and/or modify it
12 under the terms of the GNU Lesser General Public License as published by
13 the Free Software Foundation; either version 2.1 of the License, or
14 (at your option) any later version.
16 systemd is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 Lesser General Public License for more details.
21 You should have received a copy of the GNU Lesser General Public License
22 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24 This is based on crypttab(5) from Fedora's initscripts package, which in
25 turn is based on Debian's version.
27 The Red Hat version has been written by Miloslav Trmac <mitr@redhat.com>.
30 <refentry id=
"crypttab" conditional='HAVE_LIBCRYPTSETUP'
>
33 <title>crypttab
</title>
34 <productname>systemd
</productname>
38 <contrib>Documentation
</contrib>
39 <firstname>Miloslav
</firstname>
40 <surname>Trmac
</surname>
41 <email>mitr@redhat.com
</email>
44 <contrib>Documentation
</contrib>
45 <firstname>Lennart
</firstname>
46 <surname>Poettering
</surname>
47 <email>lennart@poettering.net
</email>
53 <refentrytitle>crypttab
</refentrytitle>
54 <manvolnum>5</manvolnum>
58 <refname>crypttab
</refname>
59 <refpurpose>Configuration for encrypted block devices
</refpurpose>
63 <para><filename>/etc/crypttab
</filename></para>
67 <title>Description
</title>
69 <para>The
<filename>/etc/crypttab
</filename> file describes
70 encrypted block devices that are set up during system boot.
</para>
72 <para>Empty lines and lines starting with the
<literal>#
</literal>
73 character are ignored. Each of the remaining lines describes one
74 encrypted block device. Fields are delimited by white space.
</para>
76 <para>Each line is in the form
<programlisting><replaceable>name
</replaceable> <replaceable>encrypted-device
</replaceable> <replaceable>password
</replaceable> <replaceable>options
</replaceable></programlisting>
77 The first two fields are mandatory, the remaining two are
80 <para>Setting up encrypted block devices using this file supports
81 three encryption modes: LUKS, TrueCrypt and plain. See
82 <citerefentry project='die-net'
><refentrytitle>cryptsetup
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
83 for more information about each mode. When no mode is specified in
84 the options field and the block device contains a LUKS signature,
85 it is opened as a LUKS device; otherwise, it is assumed to be in
86 raw dm-crypt (plain mode) format.
</para>
88 <para>The first field contains the name of the resulting encrypted
89 block device; the device is set up within
90 <filename>/dev/mapper/
</filename>.
</para>
92 <para>The second field contains a path to the underlying block
93 device or file, or a specification of a block device via
94 <literal>UUID=
</literal> followed by the UUID.
</para>
96 <para>The third field specifies the encryption password. If the
97 field is not present or the password is set to
98 <literal>none
</literal> or
<literal>-
</literal>, the password has
99 to be manually entered during system boot. Otherwise, the field is
100 interpreted as an absolute path to a file containing the encryption
101 password. For swap encryption,
<filename>/dev/urandom
</filename>
102 or the hardware device
<filename>/dev/hw_random
</filename> can be
103 used as the password file; using
<filename>/dev/random
</filename>
104 may prevent boot completion if the system does not have enough
105 entropy to generate a truly random encryption key.
</para>
107 <para>The fourth field, if present, is a comma-delimited list of
108 options. The following options are recognized:
</para>
110 <variablelist class='fstab-options'
>
113 <term><option>cipher=
</option></term>
115 <listitem><para>Specifies the cipher to use. See
116 <citerefentry project='die-net'
><refentrytitle>cryptsetup
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
117 for possible values and the default value of this option. A
118 cipher with unpredictable IV values, such as
119 <literal>aes-cbc-essiv:sha256
</literal>, is
120 recommended.
</para></listitem>
124 <term><option>discard
</option></term>
126 <listitem><para>Allow discard requests to be passed through the encrypted block
127 device. This improves performance on SSD storage but has security implications.
132 <term><option>hash=
</option></term>
134 <listitem><para>Specifies the hash to use for password
136 <citerefentry project='die-net'
><refentrytitle>cryptsetup
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
137 for possible values and the default value of this
138 option.
</para></listitem>
142 <term><option>header=
</option></term>
144 <listitem><para>Use a detached (separated) metadata device or
145 file where the LUKS header is stored. This option is only
146 relevant for LUKS devices. See
147 <citerefentry project='die-net'
><refentrytitle>cryptsetup
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
148 for possible values and the default value of this
149 option.
</para></listitem>
153 <term><option>keyfile-offset=
</option></term>
155 <listitem><para>Specifies the number of bytes to skip at the
156 start of the key file. See
157 <citerefentry project='die-net'
><refentrytitle>cryptsetup
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
158 for possible values and the default value of this
159 option.
</para></listitem>
163 <term><option>keyfile-size=
</option></term>
165 <listitem><para>Specifies the maximum number of bytes to read
166 from the key file. See
167 <citerefentry project='die-net'
><refentrytitle>cryptsetup
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
168 for possible values and the default value of this option. This
169 option is ignored in plain encryption mode, as the key file
170 size is then given by the key size.
</para></listitem>
174 <term><option>key-slot=
</option></term>
176 <listitem><para>Specifies the key slot to compare the
177 passphrase or key against. If the key slot does not match the
178 given passphrase or key, but another would, the setup of the
179 device will fail regardless. This option implies
180 <option>luks
</option>. See
181 <citerefentry project='die-net'
><refentrytitle>cryptsetup
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
182 for possible values. The default is to try all key slots in
183 sequential order.
</para></listitem>
187 <term><option>luks
</option></term>
189 <listitem><para>Force LUKS mode. When this mode is used, the
190 following options are ignored since they are provided by the
191 LUKS header on the device:
<option>cipher=
</option>,
192 <option>hash=
</option>,
193 <option>size=
</option>.
</para></listitem>
197 <term><option>_netdev
</option></term>
199 <listitem><para>Marks this cryptsetup device as requiring network. It will be
200 started after the network is available, similarly to
201 <citerefentry><refentrytitle>systemd.mount
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
202 units marked with
<option>_netdev
</option>. The service unit to set up this device
203 will be ordered between
<filename>remote-fs-pre.target
</filename> and
204 <filename>remote-cryptsetup.target
</filename>, instead of
205 <filename>cryptsetup-pre.target
</filename> and
206 <filename>cryptsetup.target
</filename>.
</para>
208 <para>Hint: if this device is used for a mount point that is specified in
209 <citerefentry project='man-pages'
><refentrytitle>fstab
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
210 the
<option>_netdev
</option> option should also be used for the mount
211 point. Otherwise, a dependency loop might be created where the mount point
212 will be pulled in by
<filename>local-fs.target
</filename>, while the
213 service to configure the network is usually only started
<emphasis>after
</emphasis>
214 the local file system has been mounted.
</para>
219 <term><option>noauto
</option></term>
221 <listitem><para>This device will not be added to
<filename>cryptsetup.target
</filename>.
222 This means that it will not be automatically unlocked on boot, unless something else pulls
223 it in. In particular, if the device is used for a mount point, it'll be unlocked
224 automatically during boot, unless the mount point itself is also disabled with
225 <option>noauto
</option>.
</para></listitem>
229 <term><option>nofail
</option></term>
231 <listitem><para>This device will not be a hard dependency of
232 <filename>cryptsetup.target
</filename>. It'll be still pulled in and started, but the system
233 will not wait for the device to show up and be unlocked, and boot will not fail if this is
234 unsuccessful. Note that other units that depend on the unlocked device may still fail. In
235 particular, if the device is used for a mount point, the mount point itself is also needs to
236 have
<option>noauto
</option> option, or the boot will fail if the device is not unlocked
237 successfully.
</para></listitem>
241 <term><option>offset=
</option></term>
243 <listitem><para>Start offset in the backend device, in
512-byte sectors. This
244 option is only relevant for plain devices.
</para></listitem>
248 <term><option>plain
</option></term>
250 <listitem><para>Force plain encryption mode.
</para></listitem>
254 <term><option>read-only
</option></term><term><option>readonly
</option></term>
256 <listitem><para>Set up the encrypted block device in read-only
257 mode.
</para></listitem>
261 <term><option>skip=
</option></term>
263 <listitem><para>How many
512-byte sectors of the encrypted data to skip at the
264 beginning. This is different from the
<option>offset=
</option> option with respect
265 to the sector numbers used in initialization vector (IV) calculation. Using
266 <option>offset=
</option> will shift the IV calculation by the same negative
267 amount. Hence, if
<option>offset=
<replaceable>n
</replaceable></option> is given,
268 sector
<replaceable>n
</replaceable> will get a sector number of
0 for the IV
269 calculation. Using
<option>skip=
</option> causes sector
270 <replaceable>n
</replaceable> to also be the first sector of the mapped device, but
271 with its number for IV generation being
<replaceable>n
</replaceable>.
</para>
273 <para>This option is only relevant for plain devices.
</para>
278 <term><option>size=
</option></term>
280 <listitem><para>Specifies the key size in bits. See
281 <citerefentry project='die-net'
><refentrytitle>cryptsetup
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
282 for possible values and the default value of this
283 option.
</para></listitem>
287 <term><option>swap
</option></term>
289 <listitem><para>The encrypted block device will be used as a
290 swap device, and will be formatted accordingly after setting
291 up the encrypted block device, with
292 <citerefentry project='man-pages'
><refentrytitle>mkswap
</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
293 This option implies
<option>plain
</option>.
</para>
295 <para>WARNING: Using the
<option>swap
</option> option will
296 destroy the contents of the named partition during every boot,
297 so make sure the underlying block device is specified
298 correctly.
</para></listitem>
302 <term><option>tcrypt
</option></term>
304 <listitem><para>Use TrueCrypt encryption mode. When this mode
305 is used, the following options are ignored since they are
306 provided by the TrueCrypt header on the device or do not
308 <option>cipher=
</option>,
309 <option>hash=
</option>,
310 <option>keyfile-offset=
</option>,
311 <option>keyfile-size=
</option>,
312 <option>size=
</option>.
</para>
314 <para>When this mode is used, the passphrase is read from the
315 key file given in the third field. Only the first line of this
316 file is read, excluding the new line character.
</para>
318 <para>Note that the TrueCrypt format uses both passphrase and
319 key files to derive a password for the volume. Therefore, the
320 passphrase and all key files need to be provided. Use
321 <option>tcrypt-keyfile=
</option> to provide the absolute path
322 to all key files. When using an empty passphrase in
323 combination with one or more key files, use
324 <literal>/dev/null
</literal> as the password file in the third
325 field.
</para></listitem>
329 <term><option>tcrypt-hidden
</option></term>
331 <listitem><para>Use the hidden TrueCrypt volume. This option
332 implies
<option>tcrypt
</option>.
</para>
334 <para>This will map the hidden volume that is inside of the
335 volume provided in the second field. Please note that there is
336 no protection for the hidden volume if the outer volume is
338 <citerefentry project='die-net'
><refentrytitle>cryptsetup
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
339 for more information on this limitation.
</para></listitem>
343 <term><option>tcrypt-keyfile=
</option></term>
345 <listitem><para>Specifies the absolute path to a key file to
346 use for a TrueCrypt volume. This implies
347 <option>tcrypt
</option> and can be used more than once to
348 provide several key files.
</para>
350 <para>See the entry for
<option>tcrypt
</option> on the
351 behavior of the passphrase and key files when using TrueCrypt
352 encryption mode.
</para></listitem>
356 <term><option>tcrypt-system
</option></term>
358 <listitem><para>Use TrueCrypt in system encryption mode. This
359 option implies
<option>tcrypt
</option>.
</para></listitem>
363 <term><option>tcrypt-veracrypt
</option></term>
365 <listitem><para>Check for a VeraCrypt volume. VeraCrypt is a fork of
366 TrueCrypt that is mostly compatible, but uses different, stronger key
367 derivation algorithms that cannot be detected without this flag.
368 Enabling this option could substantially slow down unlocking, because
369 VeraCrypt's key derivation takes much longer than TrueCrypt's. This
370 option implies
<option>tcrypt
</option>.
</para></listitem>
374 <term><option>timeout=
</option></term>
376 <listitem><para>Specifies the timeout for querying for a
377 password. If no unit is specified, seconds is used. Supported
378 units are s, ms, us, min, h, d. A timeout of
0 waits
379 indefinitely (which is the default).
</para></listitem>
383 <term><option>tmp
</option></term>
385 <listitem><para>The encrypted block device will be prepared
386 for using it as
<filename>/tmp
</filename>; it will be
388 <citerefentry project='man-pages'
><refentrytitle>mke2fs
</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
389 This option implies
<option>plain
</option>.
</para>
391 <para>WARNING: Using the
<option>tmp
</option> option will
392 destroy the contents of the named partition during every boot,
393 so make sure the underlying block device is specified
394 correctly.
</para></listitem>
398 <term><option>tries=
</option></term>
400 <listitem><para>Specifies the maximum number of times the user
401 is queried for a password. The default is
3. If set to
0, the
402 user is queried for a password indefinitely.
</para></listitem>
406 <term><option>verify
</option></term>
408 <listitem><para> If the encryption password is read from
409 console, it has to be entered twice to prevent
410 typos.
</para></listitem>
414 <term><option>x-systemd.device-timeout=
</option></term>
416 <listitem><para>Specifies how long systemd should wait for a device to show up
417 before giving up on the entry. The argument is a time in seconds or explicitly
419 <literal>s
</literal>,
420 <literal>min
</literal>,
421 <literal>h
</literal>,
422 <literal>ms
</literal>.
428 <para>At early boot and when the system manager configuration is
429 reloaded, this file is translated into native systemd units by
430 <citerefentry><refentrytitle>systemd-cryptsetup-generator
</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
</para>
434 <title>Example
</title>
436 <title>/etc/crypttab example
</title>
437 <para>Set up four encrypted block devices. One using LUKS for
438 normal storage, another one for usage as a swap device and two
439 TrueCrypt volumes.
</para>
441 <programlisting>luks UUID=
2505567a-
9e27-
4efe-a4d5-
15ad146c258b
442 swap /dev/sda7 /dev/urandom swap
443 truecrypt /dev/sda2 /etc/container_password tcrypt
444 hidden /mnt/tc_hidden /dev/null tcrypt-hidden,tcrypt-keyfile=/etc/keyfile
</programlisting>
449 <title>See Also
</title>
451 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
452 <citerefentry><refentrytitle>systemd-cryptsetup@.service
</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
453 <citerefentry><refentrytitle>systemd-cryptsetup-generator
</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
454 <citerefentry project='man-pages'
><refentrytitle>fstab
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
455 <citerefentry project='die-net'
><refentrytitle>cryptsetup
</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
456 <citerefentry project='man-pages'
><refentrytitle>mkswap
</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
457 <citerefentry project='man-pages'
><refentrytitle>mke2fs
</refentrytitle><manvolnum>8</manvolnum></citerefentry>