3 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
4 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
5 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
6 <refentry id="systemd-cryptsetup" conditional='HAVE_LIBCRYPTSETUP'>
9 <title>systemd-cryptsetup</title>
10 <productname>systemd</productname>
14 <refentrytitle>systemd-cryptsetup</refentrytitle>
15 <manvolnum>8</manvolnum>
19 <refname>systemd-cryptsetup</refname>
20 <refname>systemd-cryptsetup@.service</refname>
21 <!-- <refname>system-systemd\x2dcryptsetup.slice</refname> — this causes meson to go haywire because it
22 thinks this is a (windows) path. Let's just not create the alias for this name, and only include it
24 <refpurpose>Full disk decryption logic</refpurpose>
29 <command>systemd-cryptsetup</command>
30 <arg choice="opt" rep="repeat">OPTIONS</arg>
31 <arg choice="plain">attach</arg>
32 <arg choice="plain">VOLUME</arg>
33 <arg choice="plain">SOURCE-DEVICE</arg>
34 <arg choice="opt">KEY-FILE</arg>
35 <arg choice="opt">CONFIG</arg>
39 <command>systemd-cryptsetup</command>
40 <arg choice="opt" rep="repeat">OPTIONS</arg>
41 <arg choice="plain">detach</arg>
42 <arg choice="plain">VOLUME</arg>
45 <para><filename>systemd-cryptsetup@.service</filename></para>
46 <para><filename>system-systemd\x2dcryptsetup.slice</filename></para>
50 <title>Description</title>
52 <para><filename>systemd-cryptsetup</filename> is used to set up (with <command>attach</command>) and tear
53 down (with <command>detach</command>) access to an encrypted block device. It is primarily used via
54 <filename>systemd-cryptsetup@.service</filename> during early boot, but may also be be called manually.
55 The positional arguments <parameter>VOLUME</parameter>, <parameter>SOURCE-DEVICE</parameter>,
56 <parameter>KEY-FILE</parameter>, and <parameter>CRYPTTAB-OPTIONS</parameter> have the same meaning as the
57 fields in <citerefentry><refentrytitle>crypttab</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
60 <para><filename>systemd-cryptsetup@.service</filename> is a service responsible for providing access to
61 encrypted block devices. It is instantiated for each device that requires decryption.</para>
63 <para><filename>systemd-cryptsetup@.service</filename> instances are part of the
64 <filename>system-systemd\x2dcryptsetup.slice</filename> slice, which is destroyed only very late in the
65 shutdown procedure. This allows the encrypted devices to remain up until filesystems have been unmounted.
68 <para><filename>systemd-cryptsetup@.service</filename> will ask
69 for hard disk passwords via the <ulink
70 url="https://systemd.io/PASSWORD_AGENTS/">password agent logic</ulink>, in
71 order to query the user for the password using the right mechanism at boot
72 and during runtime.</para>
74 <para>At early boot and when the system manager configuration is reloaded, <filename>/etc/crypttab</filename> is
75 translated into <filename>systemd-cryptsetup@.service</filename> units by
76 <citerefentry><refentrytitle>systemd-cryptsetup-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
78 <para>In order to unlock a volume a password or binary key is required.
79 <filename>systemd-cryptsetup@.service</filename> tries to acquire a suitable password or binary key via
80 the following mechanisms, tried in order:</para>
83 <listitem><para>If a key file is explicitly configured (via the third column in
84 <filename>/etc/crypttab</filename>), a key read from it is used. If a PKCS#11 token, FIDO2 token or
85 TPM2 device is configured (using the <varname>pkcs11-uri=</varname>, <varname>fido2-device=</varname>,
86 <varname>tpm2-device=</varname> options) the key is decrypted before use.</para></listitem>
88 <listitem><para>If no key file is configured explicitly this way, a key file is automatically loaded
89 from <filename>/etc/cryptsetup-keys.d/<replaceable>volume</replaceable>.key</filename> and
90 <filename>/run/cryptsetup-keys.d/<replaceable>volume</replaceable>.key</filename>, if present. Here
91 too, if a PKCS#11/FIDO2/TPM2 token/device is configured, any key found this way is decrypted before
92 use.</para></listitem>
94 <listitem><para>If the <varname>try-empty-password</varname> option is specified then unlocking the
95 volume with an empty password is attempted.</para></listitem>
97 <listitem><para>The kernel keyring is then checked for a suitable cached password from previous
98 attempts.</para></listitem>
100 <listitem><para>Finally, the user is queried for a password, possibly multiple times, unless
101 the <varname>headless</varname> option is set.</para></listitem>
104 <para>If no suitable key may be acquired via any of the mechanisms describes above, volume activation fails.</para>
108 <title>See Also</title>
110 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
111 <citerefentry><refentrytitle>systemd-cryptsetup-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
112 <citerefentry><refentrytitle>crypttab</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
113 <citerefentry><refentrytitle>systemd-cryptenroll</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
114 <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
115 <ulink url="https://systemd.io/TPM2_PCR_MEASUREMENTS">TPM2 PCR Measurements Made by systemd</ulink>