Debian Codegraph @

upstream/mageia-cauldron/man5/crypttab.5

raw
1 '\" t
2 .TH "CRYPTTAB" "5" "" "systemd 258.7" "crypttab"
3 .\" -----------------------------------------------------------------
4 .\" * Define some portability stuff
5 .\" -----------------------------------------------------------------
6 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 .\" http://bugs.debian.org/507673
8 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
9 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 .ie \n(.g .ds Aq \(aq
11 .el .ds Aq '
12 .\" -----------------------------------------------------------------
13 .\" * set default formatting
14 .\" -----------------------------------------------------------------
15 .\" disable hyphenation
16 .nh
17 .\" disable justification (adjust text to left margin only)
18 .ad l
19 .\" -----------------------------------------------------------------
20 .\" * MAIN CONTENT STARTS HERE *
21 .\" -----------------------------------------------------------------
22 .SH "NAME"
23 crypttab \- Configuration for encrypted block devices
24 .SH "SYNOPSIS"
25 .PP
26 /etc/crypttab
27 .SH "DESCRIPTION"
28 .PP
29 The
30 /etc/crypttab
31 file describes encrypted block devices that are set up during system boot\&.
32 .PP
33 Empty lines and lines starting with the
34 "#"
35 character are ignored\&. Each of the remaining lines describes one encrypted block device\&. Fields are delimited by white space\&.
36 .PP
37 Each line is in the form
38 .sp
39 .if n \{\
40 .RS 4
41 .\}
42 .nf
43 \fIvolume\-name\fR \fIencrypted\-device\fR \fIkey\-file\fR \fIoptions\fR
44 .fi
45 .if n \{\
46 .RE
47 .\}
48 .sp
49 The first two fields are mandatory, the remaining two are optional\&.
50 .PP
51 Setting up encrypted block devices using this file supports four encryption modes: LUKS, TrueCrypt, BitLocker and plain\&. See
52 \fBcryptsetup\fR(8)
53 for more information about each mode\&. When no mode is specified in the options field and the block device contains a LUKS signature, it is opened as a LUKS device; otherwise, it is assumed to be in raw dm\-crypt (plain mode) format\&.
54 .PP
55 The four fields of
56 /etc/crypttab
57 are defined as follows:
58 .sp
59 .RS 4
60 .ie n \{\
61 \h'-04' 1.\h'+01'\c
62 .\}
63 .el \{\
64 .sp -1
65 .IP " 1." 4.2
66 .\}
67 The first field contains the name of the resulting volume with decrypted data; its block device is set up below
68 /dev/mapper/\&.
69 .RE
70 .sp
71 .RS 4
72 .ie n \{\
73 \h'-04' 2.\h'+01'\c
74 .\}
75 .el \{\
76 .sp -1
77 .IP " 2." 4.2
78 .\}
79 The second field contains a path to the underlying block device or file, or a specification of a block device via
80 "UUID="
81 followed by the UUID\&.
82 .RE
83 .sp
84 .RS 4
85 .ie n \{\
86 \h'-04' 3.\h'+01'\c
87 .\}
88 .el \{\
89 .sp -1
90 .IP " 3." 4.2
91 .\}
92 The third field specifies an absolute path to a file with the encryption key\&. Optionally, the path may be followed by
93 ":"
94 and an
95 /etc/fstab
96 style device specification (e\&.g\&. starting with
97 "LABEL="
98 or similar); in which case the path is taken relative to the specified device\*(Aqs file system root\&. If the field is not present or is
99 "none"
100 or
101 "\-", a key file named after the volume to unlock (i\&.e\&. the first column of the line), suffixed with
102 \&.key
103 is automatically loaded from the
104 /etc/cryptsetup\-keys\&.d/
105 and
106 /run/cryptsetup\-keys\&.d/
107 directories, if present\&. Otherwise, the password has to be manually entered during system boot\&. For swap encryption,
108 /dev/urandom
109 may be used as key file, resulting in a randomized key\&.
110 .sp
111 If the specified key file path refers to an
112 \fBAF_UNIX\fR
113 stream socket in the file system, the key is acquired by connecting to the socket and reading it from the connection\&. This allows the implementation of a service to provide key information dynamically, at the moment when it is needed\&. For details see below\&.
114 .RE
115 .sp
116 .RS 4
117 .ie n \{\
118 \h'-04' 4.\h'+01'\c
119 .\}
120 .el \{\
121 .sp -1
122 .IP " 4." 4.2
123 .\}
124 The fourth field, if present, is a comma\-delimited list of options\&. The supported options are listed below\&.
125 .RE
126 .SH "KEY ACQUISITION"
127 .PP
128 Six different mechanisms for acquiring the decryption key or passphrase unlocking the encrypted volume are supported\&. Specifically:
129 .sp
130 .RS 4
131 .ie n \{\
132 \h'-04' 1.\h'+01'\c
133 .\}
134 .el \{\
135 .sp -1
136 .IP " 1." 4.2
137 .\}
138 Most prominently, the user may be queried interactively during volume activation (i\&.e\&. typically at boot), asking them to type in the necessary passphrases\&.
139 .RE
140 .sp
141 .RS 4
142 .ie n \{\
143 \h'-04' 2.\h'+01'\c
144 .\}
145 .el \{\
146 .sp -1
147 .IP " 2." 4.2
148 .\}
149 The (unencrypted) key may be read from a file on disk, possibly on removable media\&. The third field of each line encodes the location, for details see above\&.
150 .RE
151 .sp
152 .RS 4
153 .ie n \{\
154 \h'-04' 3.\h'+01'\c
155 .\}
156 .el \{\
157 .sp -1
158 .IP " 3." 4.2
159 .\}
160 The (unencrypted) key may be requested from another service, by specifying an
161 \fBAF_UNIX\fR
162 file system socket in place of a key file in the third field\&. For details see above and below\&.
163 .RE
164 .sp
165 .RS 4
166 .ie n \{\
167 \h'-04' 4.\h'+01'\c
168 .\}
169 .el \{\
170 .sp -1
171 .IP " 4." 4.2
172 .\}
173 The key may be acquired via a PKCS#11 compatible hardware security token or smartcard\&. In this case, a saved key used in unlock process is stored on disk/removable media, acquired via
174 \fBAF_UNIX\fR, or stored in the LUKS2 JSON token metadata header\&. For RSA, the saved key is an encrypted volume key\&. The encrypted volume key is then decrypted by the PKCS#11 token with an RSA private key stored on it, and used to unlock the encrypted volume\&. For elliptic\-curve (EC) cryptography, the saved key is the public key generated in enrollment process\&. The public key is then used to derive a shared secret with a private key stored in the PKCS#11 token\&. The derived shared secret is then used to unlock the volume\&. Use the
175 \fBpkcs11\-uri=\fR
176 option described below to use this mechanism\&.
177 .RE
178 .sp
179 .RS 4
180 .ie n \{\
181 \h'-04' 5.\h'+01'\c
182 .\}
183 .el \{\
184 .sp -1
185 .IP " 5." 4.2
186 .\}
187 Similarly, the key may be acquired via a FIDO2 compatible hardware security token (which must implement the "hmac\-secret" extension)\&. In this case, a key generated randomly during enrollment is stored on disk/removable media, acquired via
188 \fBAF_UNIX\fR, or stored in the LUKS2 JSON token metadata header\&. The random key is hashed via a keyed hash function (HMAC) on the FIDO2 token, using a secret key stored on the token that never leaves it\&. The resulting hash value is then used as key to unlock the encrypted volume\&. Use the
189 \fBfido2\-device=\fR
190 option described below to use this mechanism\&.
191 .RE
192 .sp
193 .RS 4
194 .ie n \{\
195 \h'-04' 6.\h'+01'\c
196 .\}
197 .el \{\
198 .sp -1
199 .IP " 6." 4.2
200 .\}
201 Similarly, the key may be acquired via a TPM2 security chip\&. In this case, a (during enrollment) randomly generated key \(em encrypted by an asymmetric key derived from the TPM2 chip\*(Aqs seed key \(em is stored on disk/removable media, acquired via
202 \fBAF_UNIX\fR, or stored in the LUKS2 JSON token metadata header\&. Use the
203 \fBtpm2\-device=\fR
204 option described below to use this mechanism\&.
205 .RE
206 .PP
207 For the latter five mechanisms the source for the key material used for unlocking the volume is primarily configured in the third field of each
208 /etc/crypttab
209 line, but may also be configured in
210 /etc/cryptsetup\-keys\&.d/
211 and
212 /run/cryptsetup\-keys\&.d/
213 (see above) or in the LUKS2 JSON token header (in case of the latter three)\&. Use the
214 \fBsystemd-cryptenroll\fR(1)
215 tool to enroll PKCS#11, FIDO2 and TPM2 devices in LUKS2 volumes\&.
216 .SH "SUPPORTED OPTIONS"
217 .PP
218 The following options may be used in the fourth field of each line:
219 .PP
220 \fBcipher=\fR
221 .RS 4
222 Specifies the cipher to use\&. See
223 \fBcryptsetup\fR(8)
224 for possible values and the default value of this option\&. A cipher with unpredictable IV values, such as
225 "aes\-cbc\-essiv:sha256", is recommended\&. Embedded commas in the cipher specification need to be escaped by preceding them with a backslash, see example below\&.
226 .sp
227 Added in version 186\&.
228 .RE
229 .PP
230 \fBdiscard\fR
231 .RS 4
232 Allow discard requests to be passed through the encrypted block device\&. This improves performance on SSD storage but has security implications\&.
233 .sp
234 Added in version 207\&.
235 .RE
236 .PP
237 \fBhash=\fR
238 .RS 4
239 Specifies the hash to use for password hashing\&. See
240 \fBcryptsetup\fR(8)
241 for possible values and the default value of this option\&.
242 .sp
243 Added in version 186\&.
244 .RE
245 .PP
246 \fBheader=\fR
247 .RS 4
248 Use a detached (separated) metadata device or file where the header containing the master key(s) is stored\&. This option is only relevant for LUKS and TrueCrypt/VeraCrypt devices\&. See
249 \fBcryptsetup\fR(8)
250 for possible values and the default value of this option\&.
251 .sp
252 Optionally, the path may be followed by
253 ":"
254 and an
255 /etc/fstab
256 device specification (e\&.g\&. starting with
257 "UUID="
258 or similar); in which case, the path is relative to the device file system root\&. The device gets mounted automatically for LUKS device activation duration only\&.
259 .sp
260 Added in version 219\&.
261 .RE
262 .PP
263 \fBkeyfile\-offset=\fR
264 .RS 4
265 Specifies the number of bytes to skip at the start of the key file\&. See
266 \fBcryptsetup\fR(8)
267 for possible values and the default value of this option\&.
268 .sp
269 Added in version 187\&.
270 .RE
271 .PP
272 \fBkeyfile\-size=\fR
273 .RS 4
274 Specifies the maximum number of bytes to read from the key file\&. See
275 \fBcryptsetup\fR(8)
276 for possible values and the default value of this option\&. This option is ignored in plain encryption mode, where the key file size is determined by the key size\&. It is also ignored when the key file is used as a salt file for a FIDO2 token, as the salt size in that case is defined by the FIDO2 specification to be exactly 32 bytes\&.
277 .sp
278 Added in version 188\&.
279 .RE
280 .PP
281 \fBkeyfile\-erase\fR
282 .RS 4
283 If enabled, the specified key file is erased after the volume is activated or when activation fails\&. This is in particular useful when the key file is only acquired transiently before activation (e\&.g\&. via a file in
284 /run/, generated by a service running before activation), and shall be removed after use\&. Defaults to off\&.
285 .sp
286 Added in version 246\&.
287 .RE
288 .PP
289 \fBkey\-slot=\fR
290 .RS 4
291 Specifies the key slot to compare the passphrase or key against\&. If the key slot does not match the given passphrase or key, but another would, the setup of the device will fail regardless\&. This option implies
292 \fBluks\fR\&. See
293 \fBcryptsetup\fR(8)
294 for possible values\&. The default is to try all key slots in sequential order\&.
295 .sp
296 Added in version 209\&.
297 .RE
298 .PP
299 \fBkeyfile\-timeout=\fR
300 .RS 4
301 Specifies the timeout for the device on which the key file resides or the device used as the key file, and falls back to a password if it could not be accessed\&. See
302 \fBsystemd-cryptsetup-generator\fR(8)
303 for key files on external devices\&.
304 .sp
305 Added in version 243\&.
306 .RE
307 .PP
308 \fBlink\-volume\-key=\fR
309 .RS 4
310 Specifies the kernel keyring and key description (see
311 \fBkeyrings\fR(7)) where LUKS2 volume key gets linked during device activation\&. The kernel keyring description and key description must be separated by
312 "::"\&.
313 .sp
314 The kernel keyring part can be a string description or a predefined kernel keyring prefixed with
315 "@"
316 (e\&.g\&.: to use
317 "@s"
318 session or
319 "@u"
320 user keyring directly)\&. The type prefix text in the kernel keyring description is not required\&. The specified kernel keyring must already exist at the time of device activation\&.
321 .sp
322 The key part is a string description optionally prefixed by a
323 "%key_type:"\&. If no type is specified, the
324 "user"
325 type key is linked by default\&. See
326 \fBkeyctl\fR(1)
327 for more information on key descriptions (KEY IDENTIFIERS section)\&.
328 .sp
329 Note that the linked volume key is not cleaned up automatically when the device is detached\&.
330 .sp
331 Added in version 256\&.
332 .RE
333 .PP
334 \fBluks\fR
335 .RS 4
336 Force LUKS mode\&. When this mode is used, the following options are ignored since they are provided by the LUKS header on the device:
337 \fBcipher=\fR,
338 \fBhash=\fR,
339 \fBsize=\fR\&.
340 .sp
341 Added in version 186\&.
342 .RE
343 .PP
344 \fBbitlk\fR
345 .RS 4
346 Decrypt BitLocker drive\&. Encryption parameters are deduced by cryptsetup from BitLocker header\&.
347 .sp
348 Added in version 246\&.
349 .RE
350 .PP
351 \fB_netdev\fR
352 .RS 4
353 Marks this cryptsetup device as requiring network\&. It will be started after the network is available, similarly to
354 \fBsystemd.mount\fR(5)
355 units marked with
356 \fB_netdev\fR\&. The service unit to set up this device will be ordered between
357 remote\-fs\-pre\&.target
358 and
359 remote\-cryptsetup\&.target, instead of
360 cryptsetup\-pre\&.target
361 and
362 cryptsetup\&.target\&.
363 .sp
364 Hint: if this device is used for a mount point that is specified in
365 \fBfstab\fR(5), the
366 \fB_netdev\fR
367 option should also be used for the mount point\&. Otherwise, a dependency loop might be created where the mount point will be pulled in by
368 local\-fs\&.target, while the service to configure the network is usually only started
369 \fIafter\fR
370 the local file system has been mounted\&.
371 .sp
372 Added in version 235\&.
373 .RE
374 .PP
375 \fBnoauto\fR
376 .RS 4
377 This device will not be added to
378 cryptsetup\&.target\&. This means that it will not be automatically unlocked on boot, unless something else pulls it in\&. In particular, if the device is used for a mount point, it\*(Aqll be unlocked automatically during boot, unless the mount point itself is also disabled with
379 \fBnoauto\fR\&.
380 .sp
381 Added in version 186\&.
382 .RE
383 .PP
384 \fBnofail\fR
385 .RS 4
386 This device will not be a hard dependency of
387 cryptsetup\&.target\&. It\*(Aqll still be pulled in and started, but the system will not wait for the device to show up and be unlocked, and boot will not fail if this is unsuccessful\&. Note that other units that depend on the unlocked device may still fail\&. In particular, if the device is used for a mount point, the mount point itself also needs to have the
388 \fBnofail\fR
389 option, or the boot will fail if the device is not unlocked successfully\&. If a keyfile and/or a
390 \fBheader\fR
391 are specified, the dependencies on their respective directories will also not be fatal, so that unmounting said directories will not cause the generated cryptset unit to be deactivated\&.
392 .sp
393 Added in version 186\&.
394 .RE
395 .PP
396 \fBoffset=\fR
397 .RS 4
398 Start offset in the backend device, in 512\-byte sectors\&. This option is only relevant for plain devices\&.
399 .sp
400 Added in version 220\&.
401 .RE
402 .PP
403 \fBplain\fR
404 .RS 4
405 Force plain encryption mode\&.
406 .sp
407 Added in version 186\&.
408 .RE
409 .PP
410 \fBread\-only\fR, \fBreadonly\fR
411 .RS 4
412 Set up the encrypted block device in read\-only mode\&.
413 .sp
414 Added in version 186\&.
415 .RE
416 .PP
417 \fBsame\-cpu\-crypt\fR
418 .RS 4
419 Perform encryption using the same CPU that IO was submitted on\&. The default is to use an unbound workqueue so that encryption work is automatically balanced between available CPUs\&.
420 .sp
421 This requires kernel 4\&.0 or newer\&.
422 .sp
423 Added in version 242\&.
424 .RE
425 .PP
426 \fBsubmit\-from\-crypt\-cpus\fR
427 .RS 4
428 Disable offloading writes to a separate thread after encryption\&. There are some situations where offloading write requests from the encryption threads to a dedicated thread degrades performance significantly\&. The default is to offload write requests to a dedicated thread because it benefits the CFQ scheduler to have writes submitted using the same context\&.
429 .sp
430 This requires kernel 4\&.0 or newer\&.
431 .sp
432 Added in version 242\&.
433 .RE
434 .PP
435 \fBno\-read\-workqueue\fR
436 .RS 4
437 Bypass dm\-crypt internal workqueue and process read requests synchronously\&. The default is to queue these requests and process them asynchronously\&.
438 .sp
439 This requires kernel 5\&.9 or newer\&.
440 .sp
441 Added in version 248\&.
442 .RE
443 .PP
444 \fBno\-write\-workqueue\fR
445 .RS 4
446 Bypass dm\-crypt internal workqueue and process write requests synchronously\&. The default is to queue these requests and process them asynchronously\&.
447 .sp
448 This requires kernel 5\&.9 or newer\&.
449 .sp
450 Added in version 248\&.
451 .RE
452 .PP
453 \fBskip=\fR
454 .RS 4
455 How many 512\-byte sectors of the encrypted data to skip at the beginning\&. This is different from the
456 \fBoffset=\fR
457 option with respect to the sector numbers used in initialization vector (IV) calculation\&. Using
458 \fBoffset=\fR
459 will shift the IV calculation by the same negative amount\&. Hence, if
460 \fBoffset=\fR\fB\fIn\fR\fR
461 is given, sector
462 \fIn\fR
463 will get a sector number of 0 for the IV calculation\&. Using
464 \fBskip=\fR
465 causes sector
466 \fIn\fR
467 to also be the first sector of the mapped device, but with its number for IV generation being
468 \fIn\fR\&.
469 .sp
470 This option is only relevant for plain devices\&.
471 .sp
472 Added in version 220\&.
473 .RE
474 .PP
475 \fBsize=\fR
476 .RS 4
477 Specifies the key size in bits\&. See
478 \fBcryptsetup\fR(8)
479 for possible values and the default value of this option\&.
480 .sp
481 Added in version 186\&.
482 .RE
483 .PP
484 \fBsector\-size=\fR
485 .RS 4
486 Specifies the sector size in bytes\&. See
487 \fBcryptsetup\fR(8)
488 for possible values and the default value of this option\&.
489 .sp
490 Added in version 240\&.
491 .RE
492 .PP
493 \fBswap\fR
494 .RS 4
495 The encrypted block device will be used as a swap device, and will be formatted accordingly after setting up the encrypted block device, with
496 \fBmkswap\fR(8)\&. This option implies
497 \fBplain\fR\&.
498 .if n \{\
499 .sp
500 .\}
501 .RS 4
502 .it 1 an-trap
503 .nr an-no-space-flag 1
504 .nr an-break-flag 1
505 .br
506 .ps +1
507 \fBWarning\fR
508 .ps -1
509 .br
510 Using the
511 \fBswap\fR
512 option will destroy the contents of the named partition during every boot, so make sure the underlying block device is specified correctly\&.
513 .sp .5v
514 .RE
515 Added in version 186\&.
516 .RE
517 .PP
518 \fBtcrypt\fR
519 .RS 4
520 Use TrueCrypt encryption mode\&. When this mode is used, the following options are ignored since they are provided by the TrueCrypt header on the device or do not apply:
521 \fBcipher=\fR,
522 \fBhash=\fR,
523 \fBkeyfile\-offset=\fR,
524 \fBkeyfile\-size=\fR,
525 \fBsize=\fR\&.
526 .sp
527 When this mode is used, the passphrase is read from the key file given in the third field\&. Only the first line of this file is read, excluding the new line character\&.
528 .sp
529 Note that the TrueCrypt format uses both passphrase and key files to derive a password for the volume\&. Therefore, the passphrase and all key files need to be provided\&. Use
530 \fBtcrypt\-keyfile=\fR
531 to provide the absolute path to all key files\&. When using an empty passphrase in combination with one or more key files, use
532 "/dev/null"
533 as the password file in the third field\&.
534 .sp
535 Added in version 206\&.
536 .RE
537 .PP
538 \fBtcrypt\-hidden\fR
539 .RS 4
540 Use the hidden TrueCrypt volume\&. This option implies
541 \fBtcrypt\fR\&.
542 .sp
543 This will map the hidden volume that is inside of the volume provided in the second field\&. Please note that there is no protection for the hidden volume if the outer volume is mounted instead\&. See
544 \fBcryptsetup\fR(8)
545 for more information on this limitation\&.
546 .sp
547 Added in version 206\&.
548 .RE
549 .PP
550 \fBtcrypt\-keyfile=\fR
551 .RS 4
552 Specifies the absolute path to a key file to use for a TrueCrypt volume\&. This implies
553 \fBtcrypt\fR
554 and can be used more than once to provide several key files\&.
555 .sp
556 See the entry for
557 \fBtcrypt\fR
558 on the behavior of the passphrase and key files when using TrueCrypt encryption mode\&.
559 .sp
560 Added in version 206\&.
561 .RE
562 .PP
563 \fBtcrypt\-system\fR
564 .RS 4
565 Use TrueCrypt in system encryption mode\&. This option implies
566 \fBtcrypt\fR\&.
567 .sp
568 Added in version 206\&.
569 .RE
570 .PP
571 \fBtcrypt\-veracrypt\fR
572 .RS 4
573 Check for a VeraCrypt volume\&. VeraCrypt is a fork of TrueCrypt that is mostly compatible, but uses different, stronger key derivation algorithms that cannot be detected without this flag\&. Enabling this option could substantially slow down unlocking, because VeraCrypt\*(Aqs key derivation takes much longer than TrueCrypt\*(Aqs\&. This option implies
574 \fBtcrypt\fR\&.
575 .sp
576 Added in version 232\&.
577 .RE
578 .PP
579 \fBveracrypt\-pim=\fR
580 .RS 4
581 Specifies a custom Personal Iteration Multiplier (PIM) value, which can range from 0\&.\&.2147468 for standard veracrypt volumes and 0\&.\&.65535 for veracrypt system volumes\&. A value of 0 will imply the VeraCrypt default\&. This option is only effective when
582 \fBtcrypt\-veracrypt\fR
583 is set\&.
584 .sp
585 Note that VeraCrypt enforces a minimal allowed PIM value depending on the password strength and the hash algorithm used for key derivation, however
586 \fBveracrypt\-pim=\fR
587 is not checked against these bounds\&. See
588 \m[blue]\fBVeracrypt Personal Iterations Multiplier\fR\m[]\&\s-2\u[1]\d\s+2
589 documentation for more information\&.
590 .sp
591 Added in version 254\&.
592 .RE
593 .PP
594 \fBtimeout=\fR
595 .RS 4
596 Specifies the timeout for querying for a password\&. If no unit is specified, seconds is used\&. Supported units are s, ms, us, min, h, d\&. A timeout of 0 waits indefinitely (which is the default)\&.
597 .sp
598 Added in version 186\&.
599 .RE
600 .PP
601 \fBtmp=\fR
602 .RS 4
603 The encrypted block device will be prepared for using it as
604 /tmp/; it will be formatted using
605 \fBmkfs\fR(8)\&. Takes a file system type as argument, such as
606 "ext4",
607 "xfs"
608 or
609 "btrfs"\&. If no argument is specified defaults to
610 "ext4"\&. This option implies
611 \fBplain\fR\&.
612 .if n \{\
613 .sp
614 .\}
615 .RS 4
616 .it 1 an-trap
617 .nr an-no-space-flag 1
618 .nr an-break-flag 1
619 .br
620 .ps +1
621 \fBWarning\fR
622 .ps -1
623 .br
624 Using the
625 \fBtmp\fR
626 option will destroy the contents of the named partition during every boot, so make sure the underlying block device is specified correctly\&.
627 .sp .5v
628 .RE
629 Added in version 186\&.
630 .RE
631 .PP
632 \fBtries=\fR
633 .RS 4
634 Specifies the maximum number of times the user is queried for a password\&. The default is 3\&. If set to 0, the user is queried for a password indefinitely\&.
635 .sp
636 Added in version 186\&.
637 .RE
638 .PP
639 \fBheadless=\fR
640 .RS 4
641 Takes a boolean argument, defaults to false\&. If true, never query interactively for the password/PIN\&. Useful for headless systems\&.
642 .sp
643 Added in version 249\&.
644 .RE
645 .PP
646 \fBverify\fR
647 .RS 4
648 If the encryption password is read from console, it has to be entered twice to prevent typos\&.
649 .sp
650 Added in version 186\&.
651 .RE
652 .PP
653 \fBpassword\-echo=yes|no|masked\fR
654 .RS 4
655 Controls whether to echo passwords or security token PINs that are read from console\&. Takes a boolean or the special string
656 "masked"\&. The default is
657 \fBpassword\-echo=masked\fR\&.
658 .sp
659 If enabled, the typed characters are echoed literally\&. If disabled, the typed characters are not echoed in any form, the user will not get feedback on their input\&. If set to
660 "masked", an asterisk ("*") is echoed for each character typed\&. Regardless of which mode is chosen, if the user hits the tabulator key ("↹") at any time, or the backspace key ("⌫") before any other data has been entered, then echo is turned off\&.
661 .sp
662 Added in version 249\&.
663 .RE
664 .PP
665 \fBpassword\-cache=yes|no|read\-only\fR
666 .RS 4
667 Controls whether to use cache for passwords or security token PINs\&. Takes a boolean or the special string
668 "read\-only"\&. Defaults to
669 "yes"\&.
670 .sp
671 If set to
672 "read\-only", the kernel keyring is checked for a password/PIN before requesting one interactively\&. If set to
673 "yes", in addition to checking the keyring, any password/PIN entered interactively is cached in the keyring with a 2\&.5\-minute timeout before being purged\&.
674 .sp
675 Note that this option is not permitted for PKCS#11 security tokens\&. The reasoning behind this is that PKCS#11 security tokens are usually configured to lock after being supplied an invalid PIN multiple times, so using the cache might inadvertently lock the token\&.
676 .sp
677 Added in version 257\&.
678 .RE
679 .PP
680 \fBpkcs11\-uri=\fR
681 .RS 4
682 Takes either the special value
683 "auto"
684 or an
685 \m[blue]\fBRFC7512 PKCS#11 URI\fR\m[]\&\s-2\u[2]\d\s+2
686 pointing to a private key which is used to decrypt the encrypted key specified in the third column of the line\&. This is useful for unlocking encrypted volumes through PKCS#11 compatible security tokens or smartcards\&. See below for an example how to set up this mechanism for unlocking a LUKS2 volume with a YubiKey security token\&.
687 .sp
688 If specified as
689 "auto"
690 the volume must be of type LUKS2 and must carry PKCS#11 security token metadata in its LUKS2 JSON token section\&. In this mode the URI and the encrypted key are automatically read from the LUKS2 JSON token header\&. Use
691 \fBsystemd-cryptenroll\fR(1)
692 as a simple tool for enrolling PKCS#11 security tokens or smartcards in a way compatible with
693 "auto"\&. In this mode the third column of the line should remain empty (that is, specified as
694 "\-")\&.
695 .sp
696 The specified URI can refer directly to a private key stored on a token or alternatively just to a slot or token, in which case a search for a suitable private key will be performed\&. In this case, if multiple suitable objects are found, the token is refused\&. The keyfile configured in the third column of the line is used as is (i\&.e\&. in binary form, unprocessed)\&. The resulting decrypted key (for RSA) or derived shared secret (for ECC) is then Base64 encoded before it is used to unlock the LUKS volume\&.
697 .sp
698 Use
699 \fBsystemd\-cryptenroll \-\-pkcs11\-token\-uri=list\fR
700 to list all suitable PKCS#11 security tokens currently plugged in, along with their URIs\&.
701 .sp
702 Note that many newer security tokens that may be used as PKCS#11 security token typically also implement the newer and simpler FIDO2 standard\&. Consider using
703 \fBfido2\-device=\fR
704 (described below) to enroll it via FIDO2 instead\&. Note that a security token enrolled via PKCS#11 cannot be used to unlock the volume via FIDO2, unless also enrolled via FIDO2, and vice versa\&.
705 .sp
706 Added in version 245\&.
707 .RE
708 .PP
709 \fBfido2\-device=\fR
710 .RS 4
711 Takes either the special value
712 "auto"
713 or the path to a
714 "hidraw"
715 device node (e\&.g\&.
716 /dev/hidraw1) referring to a FIDO2 security token that implements the
717 "hmac\-secret"
718 extension (most current hardware security tokens do)\&. See below for an example how to set up this mechanism for unlocking an encrypted volume with a FIDO2 security token\&.
719 .sp
720 If specified as
721 "auto"
722 the FIDO2 token device is automatically discovered, as it is plugged in\&.
723 .sp
724 FIDO2 volume unlocking requires a client ID hash (CID) to be configured via
725 \fBfido2\-cid=\fR
726 (see below) and a key to pass to the security token\*(Aqs HMAC functionality (configured in the line\*(Aqs third column) to operate\&. If not configured and the volume is of type LUKS2, the CID and the key are read from LUKS2 JSON token metadata instead\&. Use
727 \fBsystemd-cryptenroll\fR(1)
728 as simple tool for enrolling FIDO2 security tokens for LUKS2 volumes\&.
729 .sp
730 Use
731 \fBsystemd\-cryptenroll \-\-fido2\-device=list\fR
732 to list all suitable FIDO2 security tokens currently plugged in, along with their device nodes\&.
733 .sp
734 This option implements the following mechanism: the configured key is hashed via they HMAC keyed hash function the FIDO2 device implements, keyed by a secret key embedded on the device\&. The resulting hash value is Base64 encoded and used to unlock the LUKS2 volume\&. As it should not be possible to extract the secret from the hardware token, it should not be possible to retrieve the hashed key given the configured key \(em without possessing the hardware token\&.
735 .sp
736 Note that many security tokens that implement FIDO2 also implement PKCS#11, suitable for unlocking volumes via the
737 \fBpkcs11\-uri=\fR
738 option described above\&. Typically the newer, simpler FIDO2 standard is preferable\&.
739 .sp
740 Added in version 248\&.
741 .RE
742 .PP
743 \fBfido2\-cid=\fR
744 .RS 4
745 Takes a Base64 encoded FIDO2 client ID to use for the FIDO2 unlock operation\&. If specified, but
746 \fBfido2\-device=\fR
747 is not,
748 \fBfido2\-device=auto\fR
749 is implied\&. If
750 \fBfido2\-device=\fR
751 is used but
752 \fBfido2\-cid=\fR
753 is not, the volume must be of LUKS2 type, and the CID is read from the LUKS2 JSON token header\&. Use
754 \fBsystemd-cryptenroll\fR(1)
755 for enrolling a FIDO2 token in the LUKS2 header compatible with this automatic mode\&.
756 .sp
757 Added in version 248\&.
758 .RE
759 .PP
760 \fBfido2\-rp=\fR
761 .RS 4
762 Takes a string, configuring the FIDO2 Relying Party (rp) for the FIDO2 unlock operation\&. If not specified,
763 "io\&.systemd\&.cryptsetup"
764 is used, except if the LUKS2 JSON token header contains a different value\&. It should normally not be necessary to override this\&.
765 .sp
766 Added in version 248\&.
767 .RE
768 .PP
769 \fBfido2\-pin=\fR
770 .RS 4
771 Controls whether to require the user to enter a PIN when unlocking the volume (the FIDO2
772 "clientPin"
773 feature)\&. This option only applies when in manual mode, i\&.e\&. when
774 \fBfido2\-cid=\fR
775 option is set\&. Defaults to neither true or false, but rather to
776 \fBv248\fR
777 behavior, that is: try with no PIN first, but if token reports that PIN is required, try again asking for PIN\&.
778 .sp
779 Added in version 257\&.
780 .RE
781 .PP
782 \fBfido2\-up=\fR
783 .RS 4
784 Controls whether to require the user to verify presence (tap the token, the FIDO2
785 "up"
786 feature) when unlocking the volume\&. This option only applies when in manual mode, i\&.e\&. when
787 \fBfido2\-cid=\fR
788 option is set\&. Defaults to neither true or false, but rather to
789 \fBv248\fR
790 behavior, that is: try with no UP first, but if token reports that UP is required, try again with UP enabled\&.
791 .sp
792 Added in version 257\&.
793 .RE
794 .PP
795 \fBfido2\-uv=\fR
796 .RS 4
797 Controls whether to require user verification (the FIDO2
798 "uv"
799 feature) when unlocking the volume\&. This option only applies when in manual mode, i\&.e\&. when
800 \fBfido2\-cid=\fR
801 option is set\&. Defaults to neither true or false, but rather to
802 \fBv248\fR
803 behavior, that is: omit configuring UV whatsoever\&.
804 .sp
805 Added in version 257\&.
806 .RE
807 .PP
808 \fBtpm2\-device=\fR
809 .RS 4
810 Takes either the special value
811 "auto"
812 or the path to a device node (e\&.g\&.
813 /dev/tpmrm0) referring to a TPM2 security chip\&. See below for an example how to set up this mechanism for unlocking an encrypted volume with a TPM2 chip\&.
814 .sp
815 Use
816 \fBtpm2\-pcrs=\fR
817 (see below) to configure the set of TPM2 PCRs to bind the volume unlocking to\&. Use
818 \fBsystemd-cryptenroll\fR(1)
819 as simple tool for enrolling TPM2 security chips in LUKS2 volumes\&.
820 .sp
821 If specified as
822 "auto"
823 the TPM2 device is automatically discovered\&. Use
824 \fBsystemd\-cryptenroll \-\-tpm2\-device=list\fR
825 to list all suitable TPM2 devices currently available, along with their device nodes\&.
826 .sp
827 This option implements the following mechanism: when enrolling a TPM2 device via
828 \fBsystemd\-cryptenroll\fR
829 on a LUKS2 volume, a randomized key unlocking the volume is generated on the host and loaded into the TPM2 chip where it is encrypted with an asymmetric "primary" key pair derived from the TPM2\*(Aqs internal "seed" key\&. Neither the seed key nor the primary key are permitted to ever leave the TPM2 chip \(em however, the now encrypted randomized key may\&. It is saved in the LUKS2 volume JSON token header\&. When unlocking the encrypted volume, the primary key pair is generated on the TPM2 chip again (which works as long as the chip\*(Aqs seed key is correctly maintained by the TPM2 chip), which is then used to decrypt (on the TPM2 chip) the encrypted key from the LUKS2 volume JSON token header saved there during enrollment\&. The resulting decrypted key is then used to unlock the volume\&. When the randomized key is encrypted the current values of the selected PCRs (see below) are included in the operation, so that different PCR state results in different encrypted keys and the decrypted key can only be recovered if the same PCR state is reproduced\&.
830 .sp
831 Added in version 248\&.
832 .RE
833 .PP
834 \fBtpm2\-pcrs=\fR
835 .RS 4
836 Takes a
837 "+"
838 separated list of numeric TPM2 PCR (i\&.e\&. "Platform Configuration Register") indexes to bind the TPM2 volume unlocking to\&. This option is only useful when TPM2 enrollment metadata is not available in the LUKS2 JSON token header already, the way
839 \fBsystemd\-cryptenroll\fR
840 writes it there\&. If not used (and no metadata in the LUKS2 JSON token header defines it), defaults to a list of a single entry: PCR 7\&. Assign an empty string to encode a policy that binds the key to no PCRs, making the key accessible to local programs regardless of the current PCR state\&.
841 .sp
842 Added in version 248\&.
843 .RE
844 .PP
845 \fBtpm2\-pin=\fR
846 .RS 4
847 Takes a boolean argument, defaults to
848 "false"\&. Controls whether TPM2 volume unlocking is bound to a PIN in addition to PCRs\&. Similarly, this option is only useful when TPM2 enrollment metadata is not available\&.
849 .sp
850 Added in version 251\&.
851 .RE
852 .PP
853 \fBtpm2\-signature=\fR
854 .RS 4
855 Takes an absolute path to a TPM2 PCR JSON signature file, as produced by the
856 \fBsystemd-measure\fR(1)
857 tool\&. This permits locking LUKS2 volumes to any PCR values for which a valid signature matching a public key specified at key enrollment time can be provided\&. See
858 \fBsystemd-cryptenroll\fR(1)
859 for details on enrolling TPM2 PCR public keys\&. If this option is not specified but it is attempted to unlock a LUKS2 volume with a signed TPM2 PCR enrollment, a suitable signature file
860 tpm2\-pcr\-signature\&.json
861 is searched for in
862 /etc/systemd/,
863 /run/systemd/,
864 /usr/lib/systemd/
865 (in this order)\&.
866 .sp
867 Added in version 252\&.
868 .RE
869 .PP
870 \fBtpm2\-pcrlock=\fR
871 .RS 4
872 Takes an absolute path to a TPM2 pcrlock policy file, as produced by the
873 \fBsystemd-pcrlock\fR(8)
874 tool\&. This permits locking LUKS2 volumes to a local policy of allowed PCR values with variants\&. See
875 \fBsystemd-cryptenroll\fR(1)
876 for details on enrolling TPM2 pcrlock policies\&. If this option is not specified but it is attempted to unlock a LUKS2 volume with a TPM2 pcrlock enrollment, a suitable signature file
877 pcrlock\&.json
878 is searched for in
879 /run/systemd/
880 and
881 /var/lib/systemd/
882 (in this order)\&.
883 .sp
884 Added in version 255\&.
885 .RE
886 .PP
887 \fBtpm2\-measure\-pcr=\fR
888 .RS 4
889 Controls whether to measure the volume key of the encrypted volume to a TPM2 PCR\&. If set to "no" (which is the default) no PCR extension is done\&. If set to "yes" the volume key is measured into PCR 15\&. If set to a decimal integer in the range 0\&...23 the volume key is measured into the specified PCR\&. The volume key is measured along with the activated volume name and its UUID\&. This functionality is particularly useful for the encrypted volume backing the root file system, as it then allows later TPM objects to be securely bound to the root file system and hence the specific installation\&.
890 .sp
891 Added in version 253\&.
892 .RE
893 .PP
894 \fBtpm2\-measure\-bank=\fR
895 .RS 4
896 Selects one or more TPM2 PCR banks to measure the volume key into, as configured with
897 \fBtpm2\-measure\-pcr=\fR
898 above\&. Multiple banks may be specified, separated by a colon character\&. If not specified, automatically determines available and used banks\&. Expects a message digest name (e\&.g\&.
899 "sha1",
900 "sha256", \&...) as argument, to identify the bank\&.
901 .sp
902 Added in version 253\&.
903 .RE
904 .PP
905 \fBtoken\-timeout=\fR
906 .RS 4
907 Specifies how long to wait at most for configured security devices (i\&.e\&. FIDO2, PKCS#11, TPM2) to show up\&. Takes a time value in seconds (but other time units may be specified too, see
908 \fBsystemd.time\fR(7)
909 for supported formats)\&. Defaults to 30s\&. Once the specified timeout elapsed authentication via password is attempted\&. Note that this timeout applies to waiting for the security device to show up \(em it does not apply to the PIN prompt for the device (should one be needed) or similar\&. Pass 0 to turn off the timeout and wait forever\&.
910 .sp
911 Added in version 250\&.
912 .RE
913 .PP
914 \fBtry\-empty\-password=\fR
915 .RS 4
916 Takes a boolean argument\&. If enabled, right before asking the user for a password it is first attempted to unlock the volume with an empty password\&. This is useful for systems that are initialized with an encrypted volume with only an empty password set, which shall be replaced with a suitable password during first boot, but after activation\&.
917 .sp
918 Added in version 246\&.
919 .RE
920 .PP
921 \fBx\-systemd\&.device\-timeout=\fR
922 .RS 4
923 Specifies how long systemd should wait for a block device to show up before giving up on the entry\&. The argument is a time in seconds or explicitly specified units of
924 "s",
925 "min",
926 "h",
927 "ms"\&.
928 .sp
929 Added in version 216\&.
930 .RE
931 .PP
932 \fBx\-initrd\&.attach\fR
933 .RS 4
934 Setup this encrypted block device in the initrd, similarly to
935 \fBsystemd.mount\fR(5)
936 units marked with
937 \fBx\-initrd\&.mount\fR\&.
938 .sp
939 Although it is not necessary to mark the mount entry for the root file system with
940 \fBx\-initrd\&.mount\fR,
941 \fBx\-initrd\&.attach\fR
942 is still recommended with the encrypted block device containing the root file system as otherwise systemd will attempt to detach the device during the regular system shutdown while it is still in use\&. With this option the device will still be detached but later after the root file system is unmounted\&.
943 .sp
944 All other encrypted block devices that contain file systems mounted in the initrd should use this option\&.
945 .sp
946 Added in version 245\&.
947 .RE
948 .PP
949 At early boot and when the system manager configuration is reloaded, this file is translated into native systemd units by
950 \fBsystemd-cryptsetup-generator\fR(8)\&.
951 .SH "AF_UNIX KEY FILES"
952 .PP
953 If the key file path (as specified in the third column of
954 /etc/crypttab
955 entries, see above) refers to an
956 \fBAF_UNIX\fR
957 stream socket in the file system, the key is acquired by connecting to the socket and reading the key from the connection\&. The connection is made from an
958 \fBAF_UNIX\fR
959 socket name in the abstract namespace, see
960 \fBunix\fR(7)
961 for details\&. The source socket name is chosen according to the following format:
962 .sp
963 .if n \{\
964 .RS 4
965 .\}
966 .nf
967 \fBNUL\fR \fIRANDOM\fR /cryptsetup/ \fIVOLUME\fR
968 .fi
969 .if n \{\
970 .RE
971 .\}
972 .PP
973 In other words: a
974 \fBNUL\fR
975 byte (as required for abstract namespace sockets), followed by a random string (consisting of alphanumeric characters only), followed by the literal string
976 "/cryptsetup/", followed by the name of the volume to acquire they key for\&. For example, for the volume
977 "myvol":
978 .sp
979 .if n \{\
980 .RS 4
981 .\}
982 .nf
983 \e0d7067f78d9827418/cryptsetup/myvol
984 .fi
985 .if n \{\
986 .RE
987 .\}
988 .PP
989 Services listening on the
990 \fBAF_UNIX\fR
991 stream socket may query the source socket name with
992 \fBgetpeername\fR(2), and use this to determine which key to send, allowing a single listening socket to serve keys for multiple volumes\&. If the PKCS#11 logic is used (see above), the socket source name is picked in similar fashion, except that the literal string
993 "/cryptsetup\-pkcs11/"
994 is used\&. And similarly for FIDO2 ("/cryptsetup\-fido2\-salt/") and TPM2 ("/cryptsetup\-tpm2/")\&. A different path component is used so that services providing key material know that the secret key was not requested directly, but instead an encrypted key that will be decrypted via the PKCS#11/FIDO2/TPM2 logic to acquire the final secret key\&.
995 .SH "EXAMPLES"
996 .PP
997 \fBExample\ \&1.\ \&/etc/crypttab example\fR
998 .PP
999 Set up four encrypted block devices\&. One using LUKS for normal storage, another one for usage as a swap device and two TrueCrypt volumes\&. For the fourth device, the option string is interpreted as two options
1000 "cipher=xchacha12,aes\-adiantum\-plain64",
1001 "keyfile\-timeout=10s"\&.
1002 .sp
1003 .if n \{\
1004 .RS 4
1005 .\}
1006 .nf
1007 luks UUID=2505567a\-9e27\-4efe\-a4d5\-15ad146c258b
1008 swap /dev/sda7 /dev/urandom swap
1009 truecrypt /dev/sda2 /etc/container_password tcrypt
1010 hidden /mnt/tc_hidden /dev/null tcrypt\-hidden,tcrypt\-keyfile=/etc/keyfile
1011 external /dev/sda3 keyfile:LABEL=keydev keyfile\-timeout=10s,cipher=xchacha12\e,aes\-adiantum\-plain64
1012 .fi
1013 .if n \{\
1014 .RE
1015 .\}
1016 .PP
1017 \fBExample\ \&2.\ \&Yubikey\-based PKCS#11 Volume Unlocking Example\fR
1018 .PP
1019 The PKCS#11 logic allows hooking up any compatible security token that is capable of storing RSA or EC cryptographic keys for unlocking an encrypted volume\&. Here\*(Aqs an example how to set up a Yubikey security token for this purpose on a LUKS2 volume, using
1020 \fBykmap\fR(1)
1021 from the yubikey\-manager project to initialize the token and
1022 \fBsystemd-cryptenroll\fR(1)
1023 to add it in the LUKS2 volume:
1024 .sp
1025 .if n \{\
1026 .RS 4
1027 .\}
1028 .nf
1029 # SPDX\-License\-Identifier: MIT\-0
1030
1031 # Destroy any old key on the Yubikey (careful!)
1032 ykman piv reset
1033
1034 # Generate a new private/public key pair on the device, store the public key in
1035 # \*(Aqpubkey\&.pem\*(Aq\&.
1036 ykman piv generate\-key \-a RSA2048 9d pubkey\&.pem
1037
1038 # Create a self\-signed certificate from this public key, and store it on the
1039 # device\&. The "subject" should be an arbitrary user\-chosen string to identify
1040 # the token with\&.
1041 ykman piv generate\-certificate \-\-subject "Knobelei" 9d pubkey\&.pem
1042
1043 # We do not need the public key anymore, let\*(Aqs remove it\&. Since it is not
1044 # security sensitive we just do a regular "rm" here\&.
1045 rm pubkey\&.pem
1046
1047 # Enroll the freshly initialized security token in the LUKS2 volume\&. Replace
1048 # /dev/sdXn by the partition to use (e\&.g\&. /dev/sda1)\&.
1049 sudo systemd\-cryptenroll \-\-pkcs11\-token\-uri=auto /dev/sdXn
1050
1051 # Test: Let\*(Aqs run systemd\-cryptsetup to test if this all worked\&.
1052 sudo systemd\-cryptsetup attach mytest /dev/sdXn none pkcs11\-uri=auto
1053
1054 # If that worked, let\*(Aqs now add the same line persistently to /etc/crypttab,
1055 # for the future\&. We do not want to use the (unstable) /dev/sdX name, so let\*(Aqs
1056 # figure out a stable link:
1057 udevadm info \-q symlink \-r /dev/sdXn
1058
1059 # Now add the line using the by\-uuid symlink to /etc/crypttab:
1060 sudo bash \-c \*(Aqecho "mytest /dev/disk/by\-uuid/\&.\&.\&. none pkcs11\-uri=auto" >>/etc/crypttab\*(Aq
1061
1062 # Depending on your distribution and encryption setup, you may need to manually
1063 # regenerate your initramfs to be able to use a Yubikey / PKCS#11 token to
1064 # unlock the partition during early boot\&.
1065 # More information at https://unix\&.stackexchange\&.com/a/705809\&.
1066 # On Fedora based systems:
1067 sudo dracut \-\-force
1068 # On Debian based systems:
1069 sudo update\-initramfs \-u
1070 .fi
1071 .if n \{\
1072 .RE
1073 .\}
1074 .PP
1075 A few notes on the above:
1076 .sp
1077 .RS 4
1078 .ie n \{\
1079 \h'-04'\(bu\h'+03'\c
1080 .\}
1081 .el \{\
1082 .sp -1
1083 .IP \(bu 2.3
1084 .\}
1085 We use RSA2048, which is the longest key size current Yubikeys support
1086 .RE
1087 .sp
1088 .RS 4
1089 .ie n \{\
1090 \h'-04'\(bu\h'+03'\c
1091 .\}
1092 .el \{\
1093 .sp -1
1094 .IP \(bu 2.3
1095 .\}
1096 We use Yubikey key slot 9d, since that\*(Aqs apparently the keyslot to use for decryption purposes, see
1097 \m[blue]\fBYubico PIV certificate slots\fR\m[]\&\s-2\u[3]\d\s+2\&.
1098 .RE
1099 .PP
1100 \fBExample\ \&3.\ \&FIDO2 Volume Unlocking Example\fR
1101 .PP
1102 The FIDO2 logic allows using any compatible FIDO2 security token that implements the
1103 "hmac\-secret"
1104 extension for unlocking an encrypted volume\&. Here\*(Aqs an example how to set up a FIDO2 security token for this purpose for a LUKS2 volume, using
1105 \fBsystemd-cryptenroll\fR(1):
1106 .sp
1107 .if n \{\
1108 .RS 4
1109 .\}
1110 .nf
1111 # SPDX\-License\-Identifier: MIT\-0
1112
1113 # Enroll the security token in the LUKS2 volume\&. Replace /dev/sdXn by the
1114 # partition to use (e\&.g\&. /dev/sda1)\&.
1115 sudo systemd\-cryptenroll \-\-fido2\-device=auto /dev/sdXn
1116
1117 # Test: Let\*(Aqs run systemd\-cryptsetup to test if this worked\&.
1118 sudo systemd\-cryptsetup attach mytest /dev/sdXn none fido2\-device=auto
1119
1120 # If that worked, let\*(Aqs now add the same line persistently to /etc/crypttab,
1121 # for the future\&. We do not want to use the (unstable) /dev/sdX name, so let\*(Aqs
1122 # figure out a stable link:
1123 udevadm info \-q symlink \-r /dev/sdXn
1124
1125 # Now add the line using the by\-uuid symlink to /etc/crypttab:
1126 sudo bash \-c \*(Aqecho "mytest /dev/disk/by\-uuid/\&.\&.\&. none fido2\-device=auto" >>/etc/crypttab\*(Aq
1127
1128 # Depending on your distribution and encryption setup, you may need to manually
1129 # regenerate your initramfs to be able to use a FIDO2 device to unlock the
1130 # partition during early boot\&.
1131 # More information at https://unix\&.stackexchange\&.com/a/705809\&.
1132 # On Fedora based systems:
1133 sudo dracut \-\-force
1134 # On Debian based systems:
1135 sudo update\-initramfs \-u
1136 .fi
1137 .if n \{\
1138 .RE
1139 .\}
1140 .PP
1141 \fBExample\ \&4.\ \&TPM2 Volume Unlocking Example\fR
1142 .PP
1143 The TPM2 logic allows using any TPM2 chip supported by the Linux kernel for unlocking an encrypted volume\&. Here\*(Aqs an example how to set up a TPM2 chip for this purpose for a LUKS2 volume, using
1144 \fBsystemd-cryptenroll\fR(1):
1145 .sp
1146 .if n \{\
1147 .RS 4
1148 .\}
1149 .nf
1150 # SPDX\-License\-Identifier: MIT\-0
1151
1152 # Enroll the TPM2 security chip in the LUKS2 volume, and bind it to PCR 7
1153 # only\&. Replace /dev/sdXn by the partition to use (e\&.g\&. /dev/sda1)\&.
1154 sudo systemd\-cryptenroll \-\-tpm2\-device=auto \-\-tpm2\-pcrs=7 /dev/sdXn
1155
1156 # Test: Let\*(Aqs run systemd\-cryptsetup to test if this worked\&.
1157 sudo systemd\-cryptsetup attach mytest /dev/sdXn none tpm2\-device=auto
1158
1159 # If that worked, let\*(Aqs now add the same line persistently to /etc/crypttab,
1160 # for the future\&. We do not want to use the (unstable) /dev/sdX name, so let\*(Aqs
1161 # figure out a stable link:
1162 udevadm info \-q symlink \-r /dev/sdXn
1163
1164 # Now add the line using the by\-uuid symlink to /etc/crypttab:
1165 sudo bash \-c \*(Aqecho "mytest /dev/disk/by\-uuid/\&.\&.\&. none tpm2\-device=auto" >>/etc/crypttab\*(Aq
1166
1167 # And now let\*(Aqs check that automatic unlocking works:
1168 sudo systemd\-cryptsetup detach mytest
1169 sudo systemctl daemon\-reload
1170 sudo systemctl start cryptsetup\&.target
1171 systemctl is\-active systemd\-cryptsetup@mytest\&.service
1172
1173 # Once we have the device which will be unlocked automatically, we can use it\&.
1174 # Usually we would create a file system and add it to /etc/fstab:
1175 sudo mkfs\&.ext4 /dev/mapper/mytest
1176 # This prints a \*(AqFilesystem UUID\*(Aq, which we can use as a stable name:
1177 sudo bash \-c \*(Aqecho "/dev/disk/by\-uuid/\&.\&.\&. /var/mytest ext4 defaults,x\-systemd\&.mkdir 0 2" >>/etc/fstab\*(Aq
1178 # And now let\*(Aqs check that the mounting works:
1179 sudo systemctl daemon\-reload
1180 sudo systemctl start /var/mytest
1181 systemctl status /var/mytest
1182
1183 # Depending on your distribution and encryption setup, you may need to manually
1184 # regenerate your initramfs to be able to use a TPM2 security chip to unlock
1185 # the partition during early boot\&.
1186 # More information at https://unix\&.stackexchange\&.com/a/705809\&.
1187 # On Fedora based systems:
1188 sudo dracut \-\-force
1189 # On Debian based systems:
1190 sudo update\-initramfs \-u
1191 .fi
1192 .if n \{\
1193 .RE
1194 .\}
1195 .SH "SEE ALSO"
1196 .PP
1197 \fBsystemd\fR(1), \[email protected]\fR(8), \fBsystemd-cryptsetup-generator\fR(8), \fBsystemd-cryptenroll\fR(1), \fBfstab\fR(5), \fBcryptsetup\fR(8), \fBmkswap\fR(8), \fBmke2fs\fR(8)
1198 .SH "NOTES"
1199 .IP " 1." 4
1200 Veracrypt Personal Iterations Multiplier
1201 .RS 4
1202 \%https://www.veracrypt.fr/en/Personal%20Iterations%20Multiplier%20%28PIM%29.html
1203 .RE
1204 .IP " 2." 4
1205 RFC7512 PKCS#11 URI
1206 .RS 4
1207 \%https://tools.ietf.org/html/rfc7512
1208 .RE
1209 .IP " 3." 4
1210 Yubico PIV certificate slots
1211 .RS 4
1212 \%https://developers.yubico.com/PIV/Introduction/Certificate_slots.html
1213 .RE