1CRYPTSETUP(8) Maintenance Commands CRYPTSETUP(8)
2
3
4
6 cryptsetup - manage plain dm-crypt and LUKS encrypted volumes
7
9 cryptsetup <options> <action> <action args>
10
12 cryptsetup is used to conveniently setup dm-crypt managed device-mapper
13 mappings. These include plain dm-crypt volumes and LUKS volumes. The
14 difference is that LUKS uses a metadata header and can hence offer more
15 features than plain dm-crypt. On the other hand, the header is visible
16 and vulnerable to damage.
17
18 In addition, cryptsetup provides limited support for the use of loop-
19 AES volumes, TrueCrypt, VeraCrypt and BitLocker compatible volumes.
20
21
23 Unless you understand the cryptographic background well, use LUKS.
24 With plain dm-crypt there are a number of possible user errors that
25 massively decrease security. While LUKS cannot fix them all, it can
26 lessen the impact for many of them.
27
29 A lot of good information on the risks of using encrypted storage, on
30 handling problems and on security aspects can be found in the Crypt‐
31 setup FAQ. Read it. Nonetheless, some risks deserve to be mentioned
32 here.
33
34 Backup: Storage media die. Encryption has no influence on that. Backup
35 is mandatory for encrypted data as well, if the data has any worth. See
36 the Cryptsetup FAQ for advice on how to do a backup of an encrypted
37 volume.
38
39 Character encoding: If you enter a passphrase with special symbols, the
40 passphrase can change depending on character encoding. Keyboard set‐
41 tings can also change, which can make blind input hard or impossible.
42 For example, switching from some ASCII 8-bit variant to UTF-8 can lead
43 to a different binary encoding and hence different passphrase seen by
44 cryptsetup, even if what you see on the terminal is exactly the same.
45 It is therefore highly recommended to select passphrase characters only
46 from 7-bit ASCII, as the encoding for 7-bit ASCII stays the same for
47 all ASCII variants and UTF-8.
48
49 LUKS header: If the header of a LUKS volume gets damaged, all data is
50 permanently lost unless you have a header-backup. If a key-slot is
51 damaged, it can only be restored from a header-backup or if another ac‐
52 tive key-slot with known passphrase is undamaged. Damaging the LUKS
53 header is something people manage to do with surprising frequency. This
54 risk is the result of a trade-off between security and safety, as LUKS
55 is designed for fast and secure wiping by just overwriting header and
56 key-slot area.
57
58 Previously used partitions: If a partition was previously used, it is a
59 very good idea to wipe filesystem signatures, data, etc. before creat‐
60 ing a LUKS or plain dm-crypt container on it. For a quick removal of
61 filesystem signatures, use "wipefs". Take care though that this may not
62 remove everything. In particular, MD RAID signatures at the end of a
63 device may survive. It also does not remove data. For a full wipe,
64 overwrite the whole partition before container creation. If you do not
65 know how to do that, the cryptsetup FAQ describes several options.
66
67
69 The following are valid actions for all supported device types.
70
71 open <device> <name> --type <device_type>
72
73 Opens (creates a mapping with) <name> backed by device <device>.
74
75 Device type can be plain, luks (default), luks1, luks2, loopaes
76 or tcrypt.
77
78 For backward compatibility there are open command aliases:
79
80 create (argument-order <name> <device>): open --type plain
81 plainOpen: open --type plain
82 luksOpen: open --type luks
83 loopaesOpen: open --type loopaes
84 tcryptOpen: open --type tcrypt
85 bitlkOpen: open --type bitlk
86
87 <options> are type specific and are described below for individ‐
88 ual device types. For create, the order of the <name> and <de‐
89 vice> options is inverted for historical reasons, all other
90 aliases use the standard <device> <name> order.
91
92 close <name>
93
94 Removes the existing mapping <name> and wipes the key from ker‐
95 nel memory.
96
97 For backward compatibility there are close command aliases: re‐
98 move, plainClose, luksClose, loopaesClose, tcryptClose (all be‐
99 haves exactly the same, device type is determined automatically
100 from active device).
101
102 <options> can be [--deferred]
103
104
105 status <name>
106
107 Reports the status for the mapping <name>.
108
109 resize <name>
110
111 Resizes an active mapping <name>.
112
113 If --size (in 512-bytes sectors) or --device-size are not speci‐
114 fied, the size is computed from the underlying device. For LUKS
115 it is the size of the underlying device without the area re‐
116 served for LUKS header (see data payload offset in luksDump com‐
117 mand). For plain crypt device, the whole device size is used.
118
119 Note that this does not change the raw device geometry, it just
120 changes how many sectors of the raw device are represented in
121 the mapped device.
122
123 If cryptsetup detected volume key for active device loaded in
124 kernel keyring service, resize action would first try to re‐
125 trieve the key using a token and only if it failed it'd ask for
126 a passphrase to unlock a keyslot (LUKS) or to derive a volume
127 key again (plain mode). The kernel keyring is used by default
128 for LUKS2 devices.
129
130 With LUKS2 device additional <options> can be [--token-id, --to‐
131 ken-only, --key-slot, --key-file, --keyfile-size, --keyfile-off‐
132 set, --timeout, --disable-locks, --disable-keyring].
133
134
135 refresh <name>
136
137 Refreshes parameters of active mapping <name>.
138
139 Updates parameters of active device <name> without need to deac‐
140 tivate the device (and umount filesystem). Currently it supports
141 parameters refresh on following devices: LUKS1, LUKS2 (including
142 authenticated encryption), plain crypt and loopaes.
143
144 Mandatory parameters are identical to those of an open action
145 for respective device type.
146
147 You may change following parameters on all devices
148 --perf-same_cpu_crypt, --perf-submit_from_crypt_cpus, --perf-
149 no_read_workqueue, --perf-no_write_workqueue and --allow-dis‐
150 cards.
151
152 Refreshing device without any optional parameter will refresh
153 the device with default setting (respective to device type).
154
155 LUKS2 only:
156
157 --integrity-no-journal parameter affects only LUKS2 devices with
158 underlying dm-integrity device.
159
160 Adding option --persistent stores any combination of device pa‐
161 rameters above in LUKS2 metadata (only after successful refresh
162 operation).
163
164 --disable-keyring parameter refreshes a device with volume key
165 passed in dm-crypt driver.
166
167
168 reencrypt <device> or --active-name <name> [<new_name>]
169
170 Run resilient reencryption (LUKS2 device only).
171
172 There are 3 basic modes of operation:
173
174 • device reencryption (reencrypt)
175
176 • device encryption (reencrypt --encrypt)
177
178 • device decryption (reencrypt --decrypt)
179
180 <device> or --active-name <name> is mandatory parameter.
181
182 With <device> parameter cryptsetup looks up active <device> dm
183 mapping. If no active mapping is detected, it starts offline
184 reencryption otherwise online reencryption takes place.
185
186 Reencryption process may be safely interrupted by a user via
187 SIGTERM signal (ctrl+c).
188
189 To resume already initialized or interrupted reencryption, just
190 run the cryptsetup reencrypt command again to continue the reen‐
191 cryption operation. Reencryption may be resumed with different
192 --resilience or --hotzone-size unless implicit datashift re‐
193 silience mode is used (reencrypt --encrypt with --reduce-device-
194 size option).
195
196 If the reencryption process was interrupted abruptly (reencryp‐
197 tion process crash, system crash, poweroff) it may require re‐
198 covery. The recovery is currently run automatically on next ac‐
199 tivation (action open) when needed.
200
201 Optional parameter <new_name> takes effect only with --encrypt
202 option and it activates device <new_name> immediately after en‐
203 cryption initialization gets finished. That's useful when device
204 needs to be ready as soon as possible and mounted (used) before
205 full data area encryption is completed.
206
207 Action supports following additional <options> [--encrypt, --de‐
208 crypt, --device-size, --resilience, --resilience-hash, --hot‐
209 zone-size, --init-only, --resume-only, --reduce-device-size,
210 --master-key-file, --key-size].
211
212
214 Plain dm-crypt encrypts the device sector-by-sector with a single, non-
215 salted hash of the passphrase. No checks are performed, no metadata is
216 used. There is no formatting operation. When the raw device is mapped
217 (opened), the usual device operations can be used on the mapped device,
218 including filesystem creation. Mapped devices usually reside in
219 /dev/mapper/<name>.
220
221 The following are valid plain device type actions:
222
223 open --type plain <device> <name>
224 create <name> <device> (OBSOLETE syntax)
225
226 Opens (creates a mapping with) <name> backed by device <device>.
227
228 <options> can be [--hash, --cipher, --verify-passphrase, --sec‐
229 tor-size, --key-file, --keyfile-offset, --key-size, --offset,
230 --skip, --size, --readonly, --shared, --allow-discards, --re‐
231 fresh]
232
233 Example: 'cryptsetup open --type plain /dev/sda10 e1' maps the
234 raw encrypted device /dev/sda10 to the mapped (decrypted) device
235 /dev/mapper/e1, which can then be mounted, fsck-ed or have a
236 filesystem created on it.
237
239 LUKS, the Linux Unified Key Setup, is a standard for disk encryption.
240 It adds a standardized header at the start of the device, a key-slot
241 area directly behind the header and the bulk data area behind that. The
242 whole set is called a 'LUKS container'. The device that a LUKS con‐
243 tainer resides on is called a 'LUKS device'. For most purposes, both
244 terms can be used interchangeably. But note that when the LUKS header
245 is at a nonzero offset in a device, then the device is not a LUKS de‐
246 vice anymore, but has a LUKS container stored in it at an offset.
247
248 LUKS can manage multiple passphrases that can be individually revoked
249 or changed and that can be securely scrubbed from persistent media due
250 to the use of anti-forensic stripes. Passphrases are protected against
251 brute-force and dictionary attacks by PBKDF2, which implements hash it‐
252 eration and salting in one function.
253
254 LUKS2 is a new version of header format that allows additional exten‐
255 sions like different PBKDF algorithm or authenticated encryption. You
256 can format device with LUKS2 header if you specify --type luks2 in
257 luksFormat command. For activation, the format is already recognized
258 automatically.
259
260 Each passphrase, also called a key in this document, is associated with
261 one of 8 key-slots. Key operations that do not specify a slot affect
262 the first slot that matches the supplied passphrase or the first empty
263 slot if a new passphrase is added.
264
265 The <device> parameter can also be specified by a LUKS UUID in the for‐
266 mat UUID=<uuid>. Translation to real device name uses symlinks in
267 /dev/disk/by-uuid directory.
268
269 To specify a detached header, the --header parameter can be used in all
270 LUKS commands and always takes precedence over the positional <device>
271 parameter.
272
273 The following are valid LUKS actions:
274
275 luksFormat <device> [<key file>]
276
277 Initializes a LUKS partition and sets the initial passphrase
278 (for key-slot 0), either via prompting or via <key file>. Note
279 that if the second argument is present, then the passphrase is
280 taken from the file given there, without the need to use the
281 --key-file option. Also note that for both forms of reading the
282 passphrase from a file you can give '-' as file name, which re‐
283 sults in the passphrase being read from stdin and the safety-
284 question being skipped.
285
286 You cannot call luksFormat on a device or filesystem that is
287 mapped or in use, e.g. mounted filesysem, used in LVM, active
288 RAID member etc. The device or filesystem has to be un-mounted
289 in order to call luksFormat.
290
291 To use LUKS2, specify --type luks2.
292
293 <options> can be [--hash, --cipher, --verify-passphrase,
294 --key-size, --key-slot, --key-file (takes precedence over op‐
295 tional second argument), --keyfile-offset, --keyfile-size,
296 --use-random | --use-urandom, --uuid, --master-key-file,
297 --iter-time, --header, --pbkdf-force-iterations, --force-pass‐
298 word, --disable-locks].
299
300 For LUKS2, additional <options> can be [--integrity, --integ‐
301 rity-no-wipe, --sector-size, --label, --subsystem, --pbkdf,
302 --pbkdf-memory, --pbkdf-parallel, --disable-locks, --dis‐
303 able-keyring, --luks2-metadata-size, --luks2-keyslots-size,
304 --keyslot-cipher, --keyslot-key-size].
305
306 WARNING: Doing a luksFormat on an existing LUKS container will
307 make all data the old container permanently irretrievable unless
308 you have a header backup.
309
310 open --type luks <device> <name>
311 luksOpen <device> <name> (old syntax)
312
313 Opens the LUKS device <device> and sets up a mapping <name> af‐
314 ter successful verification of the supplied passphrase.
315
316 First, the passphrase is searched in LUKS tokens. If it's not
317 found in any token and also the passphrase is not supplied via
318 --key-file, the command prompts for it interactively.
319
320 <options> can be [--key-file, --keyfile-offset, --keyfile-size,
321 --readonly, --test-passphrase, --allow-discards, --header,
322 --key-slot, --master-key-file, --token-id, --token-only, --dis‐
323 able-keyring, --disable-locks, --type, --refresh, --serial‐
324 ize-memory-hard-pbkdf].
325
326 luksSuspend <name>
327
328 Suspends an active device (all IO operations will block and ac‐
329 cesses to the device will wait indefinitely) and wipes the en‐
330 cryption key from kernel memory. Needs kernel 2.6.19 or later.
331
332 After this operation you have to use luksResume to reinstate the
333 encryption key and unblock the device or close to remove the
334 mapped device.
335
336 WARNING: never suspend the device on which the cryptsetup binary
337 resides.
338
339 <options> can be [--header, --disable-locks].
340
341 luksResume <name>
342
343 Resumes a suspended device and reinstates the encryption key.
344 Prompts interactively for a passphrase if --key-file is not
345 given.
346
347 <options> can be [--key-file, --keyfile-size, --header, --dis‐
348 able-keyring, --disable-locks, --type]
349
350 luksAddKey <device> [<key file with new key>]
351
352 Adds a new passphrase. An existing passphrase must be supplied
353 interactively or via --key-file. The new passphrase to be added
354 can be specified interactively or read from the file given as
355 positional argument.
356
357 NOTE: with --unbound option the action creates new unbound LUKS2
358 keyslot. The keyslot cannot be used for device activation. If
359 you don't pass new key via --master-key-file option, new random
360 key is generated. Existing passphrase for any active keyslot is
361 not required.
362
363 <options> can be [--key-file, --keyfile-offset, --keyfile-size,
364 --new-keyfile-offset, --new-keyfile-size, --key-slot, --mas‐
365 ter-key-file, --force-password, --header, --disable-locks,
366 --iter-time, --pbkdf, --pbkdf-force-iterations, --unbound,
367 --type, --keyslot-cipher, --keyslot-key-size].
368
369 luksRemoveKey <device> [<key file with passphrase to be removed>]
370
371 Removes the supplied passphrase from the LUKS device. The
372 passphrase to be removed can be specified interactively, as the
373 positional argument or via --key-file.
374
375 <options> can be [--key-file, --keyfile-offset, --keyfile-size,
376 --header, --disable-locks, --type]
377
378 WARNING: If you read the passphrase from stdin (without further
379 argument or with '-' as an argument to --key-file), batch-mode
380 (-q) will be implicitly switched on and no warning will be given
381 when you remove the last remaining passphrase from a LUKS con‐
382 tainer. Removing the last passphrase makes the LUKS container
383 permanently inaccessible.
384
385 luksChangeKey <device> [<new key file>]
386
387 Changes an existing passphrase. The passphrase to be changed
388 must be supplied interactively or via --key-file. The new
389 passphrase can be supplied interactively or in a file given as
390 positional argument.
391
392 If a key-slot is specified (via --key-slot), the passphrase for
393 that key-slot must be given and the new passphrase will over‐
394 write the specified key-slot. If no key-slot is specified and
395 there is still a free key-slot, then the new passphrase will be
396 put into a free key-slot before the key-slot containing the old
397 passphrase is purged. If there is no free key-slot, then the
398 key-slot with the old passphrase is overwritten directly.
399
400 WARNING: If a key-slot is overwritten, a media failure during
401 this operation can cause the overwrite to fail after the old
402 passphrase has been wiped and make the LUKS container inaccessi‐
403 ble.
404
405 <options> can be [--key-file, --keyfile-offset, --keyfile-size,
406 --new-keyfile-offset, --iter-time, --pbkdf, --pbkdf-force-itera‐
407 tions, --new-keyfile-size, --key-slot, --force-password,
408 --header, --disable-locks, --type, --keyslot-cipher,
409 --keyslot-key-size].
410
411 luksConvertKey <device>
412
413 Converts an existing LUKS2 keyslot to new pbkdf parameters. The
414 passphrase for keyslot to be converted must be supplied interac‐
415 tively or via --key-file. If no --pbkdf parameters are specified
416 LUKS2 default pbkdf values will apply.
417
418 If a keyslot is specified (via --key-slot), the passphrase for
419 that keyslot must be given. If no keyslot is specified and there
420 is still a free keyslot, then the new parameters will be put
421 into a free keyslot before the keyslot containing the old param‐
422 eters is purged. If there is no free keyslot, then the keyslot
423 with the old parameters is overwritten directly.
424
425 WARNING: If a keyslot is overwritten, a media failure during
426 this operation can cause the overwrite to fail after the old pa‐
427 rameters have been wiped and make the LUKS container inaccessi‐
428 ble.
429
430 <options> can be [--key-file, --keyfile-offset, --keyfile-size,
431 --key-slot, --header, --disable-locks, --iter-time, --pbkdf,
432 --pbkdf-force-iterations, --pbkdf-memory, --pbkdf-parallel,
433 --keyslot-cipher, --keyslot-key-size].
434
435 luksKillSlot <device> <key slot number>
436
437 Wipe the key-slot number <key slot> from the LUKS device. Except
438 running in batch-mode (-q) a remaining passphrase must be sup‐
439 plied, either interactively or via --key-file. This command can
440 remove the last remaining key-slot, but requires an interactive
441 confirmation when doing so. Removing the last passphrase makes a
442 LUKS container permanently inaccessible.
443
444 <options> can be [--key-file, --keyfile-offset, --keyfile-size,
445 --header, --disable-locks, --type].
446
447 WARNING: If you read the passphrase from stdin (without further
448 argument or with '-' as an argument to --key-file), batch-mode
449 (-q) will be implicitly switched on and no warning will be given
450 when you remove the last remaining passphrase from a LUKS con‐
451 tainer. Removing the last passphrase makes the LUKS container
452 permanently inaccessible.
453
454 NOTE: If there is no passphrase provided (on stdin or through
455 --key-file argument) and batch-mode (-q) is active, the key-slot
456 is removed without any other warning.
457
458
459 erase <device>
460 luksErase <device>
461
462 Erase all keyslots and make the LUKS container permanently inac‐
463 cessible. You do not need to provide any password for this op‐
464 eration.
465
466 WARNING: This operation is irreversible.
467
468 luksUUID <device>
469
470 Print the UUID of a LUKS device.
471 Set new UUID if --uuid option is specified.
472
473 isLuks <device>
474
475 Returns true, if <device> is a LUKS device, false otherwise.
476 Use option -v to get human-readable feedback. 'Command success‐
477 ful.' means the device is a LUKS device.
478
479 By specifying --type you may query for specific LUKS version.
480
481 luksDump <device>
482
483 Dump the header information of a LUKS device.
484
485 If the --dump-master-key option is used, the LUKS device master
486 key is dumped instead of the keyslot info. Together with --mas‐
487 ter-key-file option, master key is dumped to a file instead of
488 standard output. Beware that the master key cannot be changed
489 without reencryption and can be used to decrypt the data stored
490 in the LUKS container without a passphrase and even without the
491 LUKS header. This means that if the master key is compromised,
492 the whole device has to be erased or reencrypted to prevent fur‐
493 ther access. Use this option carefully.
494
495 To dump the master key, a passphrase has to be supplied, either
496 interactively or via --key-file.
497
498 To dump unbound key (LUKS2 format only), --unbound parameter,
499 specific --key-slot id and proper passphrase has to be supplied,
500 either interactively or via --key-file. Optional --mas‐
501 ter-key-file parameter enables unbound keyslot dump to a file.
502
503 <options> can be [--dump-master-key, --key-file, --keyfile-off‐
504 set, --keyfile-size, --header, --disable-locks, --mas‐
505 ter-key-file, --type, --unbound, --key-slot].
506
507 WARNING: If --dump-master-key is used with --key-file and the
508 argument to --key-file is '-', no validation question will be
509 asked and no warning given.
510
511 luksHeaderBackup <device> --header-backup-file <file>
512
513 Stores a binary backup of the LUKS header and keyslot area.
514 Note: Using '-' as filename writes the header backup to a file
515 named '-'.
516
517 WARNING: This backup file and a passphrase valid at the time of
518 backup allows decryption of the LUKS data area, even if the
519 passphrase was later changed or removed from the LUKS device.
520 Also note that with a header backup you lose the ability to se‐
521 curely wipe the LUKS device by just overwriting the header and
522 key-slots. You either need to securely erase all header backups
523 in addition or overwrite the encrypted data area as well. The
524 second option is less secure, as some sectors can survive, e.g.
525 due to defect management.
526
527 luksHeaderRestore <device> --header-backup-file <file>
528
529 Restores a binary backup of the LUKS header and keyslot area
530 from the specified file.
531 Note: Using '-' as filename reads the header backup from a file
532 named '-'.
533
534 WARNING: Header and keyslots will be replaced, only the
535 passphrases from the backup will work afterward.
536
537 This command requires that the master key size and data offset
538 of the LUKS header already on the device and of the header
539 backup match. Alternatively, if there is no LUKS header on the
540 device, the backup will also be written to it.
541
542 token <add|remove|import|export> <device>
543
544 Action add creates new keyring token to enable auto-activation
545 of the device. For the auto-activation, the passphrase must be
546 stored in keyring with the specified description. Usually, the
547 passphrase should be stored in user or user-session keyring.
548 The token command is supported only for LUKS2.
549
550 For adding new keyring token, option --key-description is manda‐
551 tory. Also, new token is assigned to key slot specified with
552 --key-slot option or to all active key slots in the case
553 --key-slot option is omitted.
554
555 To remove existing token, specify the token ID which should be
556 removed with --token-id option.
557
558 WARNING: The action token remove removes any token type, not
559 just keyring type from token slot specified by --token-id op‐
560 tion.
561
562 Action import can store arbitrary valid token json in LUKS2
563 header. It may be passed via standard input or via file passed
564 in --json-file option. If you specify --key-slot then success‐
565 fully imported token is also assigned to the key slot.
566
567 Action export writes requested token json to a file passed with
568 --json-file or to standard output.
569
570 <options> can be [--header, --token-id, --key-slot, --key-de‐
571 scription, --disable-locks, --disable-keyring, --json-file].
572
573 convert <device> --type <format>
574
575 Converts the device between LUKS1 and LUKS2 format (if possi‐
576 ble). The conversion will not be performed if there is an addi‐
577 tional LUKS2 feature or LUKS1 has unsupported header size.
578
579 Conversion (both directions) must be performed on inactive de‐
580 vice. There must not be active dm-crypt mapping established for
581 LUKS header requested for conversion.
582
583 --type option is mandatory with following accepted values: luks1
584 or luks2.
585
586 WARNING: The convert action can destroy the LUKS header in the
587 case of a crash during conversion or if a media error occurs.
588 Always create a header backup before performing this operation!
589
590 <options> can be [--header, --type].
591
592 config <device>
593
594 Set permanent configuration options (store to LUKS header). The
595 config command is supported only for LUKS2.
596
597 The permanent options can be --priority to set priority (normal,
598 prefer, ignore) for keyslot (specified by --key-slot) or --label
599 and --subsystem.
600
601 <options> can be [--priority, --label, --subsystem, --key-slot,
602 --header].
603
604
606 cryptsetup supports mapping loop-AES encrypted partition using a com‐
607 patibility mode.
608
609 open --type loopaes <device> <name> --key-file <keyfile>
610 loopaesOpen <device> <name> --key-file <keyfile> (old syntax)
611
612 Opens the loop-AES <device> and sets up a mapping <name>.
613
614 If the key file is encrypted with GnuPG, then you have to use
615 --key-file=- and decrypt it before use, e.g. like this:
616 gpg --decrypt <keyfile> | cryptsetup loopaesOpen --key-file=-
617 <device> <name>
618
619 WARNING: The loop-AES extension cannot use the direct input of
620 key file on real terminal because the keys are separated by end-
621 of-line and only part of the multi-key file would be read.
622 If you need it in script, just use the pipe redirection:
623 echo $keyfile | cryptsetup loopaesOpen --key-file=- <device>
624 <name>
625
626 Use --keyfile-size to specify the proper key length if needed.
627
628 Use --offset to specify device offset. Note that the units need
629 to be specified in number of 512 byte sectors.
630
631 Use --skip to specify the IV offset. If the original device used
632 an offset and but did not use it in IV sector calculations, you
633 have to explicitly use --skip 0 in addition to the offset param‐
634 eter.
635
636 Use --hash to override the default hash function for passphrase
637 hashing (otherwise it is detected according to key size).
638
639 <options> can be [--key-file, --key-size, --offset, --skip,
640 --hash, --readonly, --allow-discards, --refresh].
641
642 See also section 7 of the FAQ and http://loop-aes.sourceforge.net for
643 more information regarding loop-AES.
644
646 cryptsetup supports mapping of TrueCrypt, tcplay or VeraCrypt (with
647 --veracrypt option) encrypted partition using a native Linux kernel
648 API. Header formatting and TCRYPT header change is not supported,
649 cryptsetup never changes TCRYPT header on-device.
650
651 TCRYPT extension requires kernel userspace crypto API to be available
652 (introduced in Linux kernel 2.6.38). If you are configuring kernel
653 yourself, enable "User-space interface for symmetric key cipher algo‐
654 rithms" in "Cryptographic API" section (CRYPTO_USER_API_SKCIPHER .con‐
655 fig option).
656
657 Because TCRYPT header is encrypted, you have to always provide valid
658 passphrase and keyfiles.
659
660 Cryptsetup should recognize all header variants, except legacy cipher
661 chains using LRW encryption mode with 64 bits encryption block (namely
662 Blowfish in LRW mode is not recognized, this is limitation of kernel
663 crypto API).
664
665 To recognize a VeraCrypt device use the --veracrypt option. VeraCrypt
666 is just extension of TrueCrypt header with increased iteration count so
667 unlocking can take quite a lot of time (in comparison with TCRYPT de‐
668 vice).
669
670 To open a VeraCrypt device with a custom Personal Iteration Multiplier
671 (PIM) value, additionally to --veracrypt use either the --ver‐
672 acrypt-pim=<PIM> option to directly specify the PIM on the command-
673 line or use --veracrypt-query-pim to be prompted for the PIM.
674
675 The PIM value affects the number of iterations applied during key deri‐
676 vation. Please refer to https://www.veracrypt.fr/en/Personal%20Itera‐
677 tions%20Multiplier%20%28PIM%29.html for more detailed information.
678
679 NOTE: Activation with tcryptOpen is supported only for cipher chains
680 using LRW or XTS encryption modes.
681
682 The tcryptDump command should work for all recognized TCRYPT devices
683 and doesn't require superuser privilege.
684
685 To map system device (device with boot loader where the whole encrypted
686 system resides) use --tcrypt-system option. You can use partition de‐
687 vice as the parameter (parameter must be real partition device, not an
688 image in a file), then only this partition is mapped.
689
690 If you have the whole TCRYPT device as a file image and you want to map
691 multiple partition encrypted with system encryption, please create
692 loopback mapping with partitions first (losetup -P, see losetup(8) man
693 page for more info), and use loop partition as the device parameter.
694
695 If you use the whole base device as a parameter, one device for the
696 whole system encryption is mapped. This mode is available only for
697 backward compatibility with older cryptsetup versions which mapped
698 TCRYPT system encryption using the whole device.
699
700 To use hidden header (and map hidden device, if available), use
701 --tcrypt-hidden option.
702
703 To explicitly use backup (secondary) header, use --tcrypt-backup op‐
704 tion.
705
706 NOTE: There is no protection for a hidden volume if the outer volume is
707 mounted. The reason is that if there were any protection, it would re‐
708 quire some metadata describing what to protect in the outer volume and
709 the hidden volume would become detectable.
710
711
712 open --type tcrypt <device> <name>
713 tcryptOpen <device> <name> (old syntax)
714
715 Opens the TCRYPT (a TrueCrypt-compatible) <device> and sets up a
716 mapping <name>.
717
718 <options> can be [--key-file, --tcrypt-hidden, --tcrypt-system,
719 --tcrypt-backup, --readonly, --test-passphrase, --allow-dis‐
720 cards, --veracrypt, --veracrypt-pim, --veracrypt-query-pim,
721 --header].
722
723 The keyfile parameter allows a combination of file content with
724 the passphrase and can be repeated. Note that using keyfiles is
725 compatible with TCRYPT and is different from LUKS keyfile logic.
726
727 If you use --header in combination with hidden or system op‐
728 tions, the header file must contain specific headers on the same
729 positions as the original encrypted container.
730
731 WARNING: Option --allow-discards cannot be combined with option
732 --tcrypt-hidden. For normal mapping, it can cause the destruc‐
733 tion of hidden volume (hidden volume appears as unused space for
734 outer volume so this space can be discarded).
735
736
737 tcryptDump <device>
738
739 Dump the header information of a TCRYPT device.
740
741 If the --dump-master-key option is used, the TCRYPT device mas‐
742 ter key is dumped instead of TCRYPT header info. Beware that the
743 master key (or concatenated master keys if cipher chain is used)
744 can be used to decrypt the data stored in the TCRYPT container
745 without a passphrase. This means that if the master key is com‐
746 promised, the whole device has to be erased to prevent further
747 access. Use this option carefully.
748
749 <options> can be [--dump-master-key, --key-file, --tcrypt-hid‐
750 den, --tcrypt-system, --tcrypt-backup].
751
752 The keyfile parameter allows a combination of file content with
753 the passphrase and can be repeated.
754
755 See also https://en.wikipedia.org/wiki/TrueCrypt for more information
756 regarding TrueCrypt.
757
758 Please note that cryptsetup does not use TrueCrypt code, please report
759 all problems related to this compatibility extension to the cryptsetup
760 project.
761
762
764 cryptsetup supports mapping of BitLocker and BitLocker to Go encrypted
765 partition using a native Linux kernel API. Header formatting and BITLK
766 header changes are not supported, cryptsetup never changes BITLK header
767 on-device.
768
769 WARNING: This extension is EXPERIMENTAL.
770
771 BITLK extension requires kernel userspace crypto API to be available
772 (for details see TCRYPT section).
773
774 Cryptsetup should recognize all BITLK header variants, except legacy
775 header used in Windows Vista systems and partially decrypted BitLocker
776 devices. Activation of legacy devices encrypted in CBC mode requires
777 at least Linux kernel version 5.3 and for devices using Elephant dif‐
778 fuser kernel 5.6.
779
780 The bitlkDump command should work for all recognized BITLK devices and
781 doesn't require superuser privilege.
782
783 For unlocking with the open a password or a recovery passphrase must be
784 provided. Other unlocking methods (TPM, SmartCard) are not supported.
785
786
787 open --type bitlk <device> <name>
788 bitlkOpen <device> <name> (old syntax)
789
790 Opens the BITLK (a BitLocker-compatible) <device> and sets up a
791 mapping <name>.
792
793 <options> can be [--key-file, --readonly, --test-passphrase,
794 --allow-discards].
795
796
797 bitlkDump <device>
798
799 Dump the header information of a BITLK device.
800
801 Please note that cryptsetup does not use any Windows BitLocker
802 code, please report all problems related to this compatibility
803 extension to the cryptsetup project.
804
806 repair <device>
807
808 Tries to repair the device metadata if possible. Currently sup‐
809 ported only for LUKS device type.
810
811 This command is useful to fix some known benign LUKS metadata
812 header corruptions. Only basic corruptions of unused keyslot are
813 fixable. This command will only change the LUKS header, not any
814 key-slot data. You may enforce LUKS version by adding --type op‐
815 tion.
816
817 WARNING: Always create a binary backup of the original header
818 before calling this command.
819
820 benchmark <options>
821
822 Benchmarks ciphers and KDF (key derivation function). Without
823 parameters, it tries to measure few common configurations.
824
825 To benchmark other ciphers or modes, you need to specify --ci‐
826 pher and --key-size options or --hash for KDF test.
827
828 NOTE: This benchmark is using memory only and is only informa‐
829 tive. You cannot directly predict real storage encryption speed
830 from it.
831
832 For testing block ciphers, this benchmark requires kernel
833 userspace crypto API to be available (introduced in Linux kernel
834 2.6.38). If you are configuring kernel yourself, enable "User-
835 space interface for symmetric key cipher algorithms" in "Crypto‐
836 graphic API" section (CRYPTO_USER_API_SKCIPHER .config option).
837
838 <options> can be [--cipher, --key-size, --hash].
839
841 --verbose, -v
842 Print more information on command execution.
843
844 --debug or --debug-json
845 Run in debug mode with full diagnostic logs. Debug output lines
846 are always prefixed by '#'. If --debug-json is used, additional
847 LUKS2 JSON data structures are printed.
848
849 --type <device-type>
850 Specifies required device type, for more info read BASIC ACTIONS
851 section.
852
853 --hash, -h <hash-spec>
854 Specifies the passphrase hash for open (for plain and loopaes
855 device types).
856
857 Specifies the hash used in the LUKS key setup scheme and volume
858 key digest for luksFormat. The specified hash is used as hash-
859 parameter for PBKDF2 and for the AF splitter.
860
861 The specified hash name is passed to the compiled-in crypto
862 backend. Different backends may support different hashes. For
863 luksFormat, the hash algorithm must provide at least 160 bits of
864 output, which excludes, e.g., MD5. Do not use a non-crypto hash
865 like "crc32" as this breaks security.
866
867 Values compatible with old version of cryptsetup are "ripemd160"
868 for open --type plain and "sha1" for luksFormat.
869
870 Use cryptsetup --help to show the defaults.
871
872 --cipher, -c <cipher-spec>
873 Set the cipher specification string.
874
875 cryptsetup --help shows the compiled-in defaults. The current
876 default in the distributed sources is "aes-cbc-essiv:sha256" for
877 plain dm-crypt and "aes-xts-plain64" for LUKS.
878
879 If a hash is part of the cipher specification, then it is used
880 as part of the IV generation. For example, ESSIV needs a hash
881 function, while "plain64" does not and hence none is specified.
882
883 For XTS mode you can optionally set a key size of 512 bits with
884 the -s option. Key size for XTS mode is twice that for other
885 modes for the same security level.
886
887 XTS mode requires kernel 2.6.24 or later and plain64 requires
888 kernel 2.6.33 or later. More information can be found in the
889 FAQ.
890
891 --verify-passphrase, -y
892 When interactively asking for a passphrase, ask for it twice and
893 complain if both inputs do not match. Advised when creating a
894 regular mapping for the first time, or when running luksFormat.
895 Ignored on input from file or stdin.
896
897 --key-file, -d name
898 Read the passphrase from file.
899
900 If the name given is "-", then the passphrase will be read from
901 stdin. In this case, reading will not stop at newline charac‐
902 ters.
903
904 With LUKS, passphrases supplied via --key-file are always the
905 existing passphrases requested by a command, except in the case
906 of luksFormat where --key-file is equivalent to the positional
907 key file argument.
908
909 If you want to set a new passphrase via key file, you have to
910 use a positional argument to luksAddKey.
911
912 See section NOTES ON PASSPHRASE PROCESSING for more information.
913
914 --keyfile-offset value
915 Skip value bytes at the beginning of the key file. Works with
916 all commands that accept key files.
917
918 --keyfile-size, -l value
919 Read a maximum of value bytes from the key file. The default is
920 to read the whole file up to the compiled-in maximum that can be
921 queried with --help. Supplying more data than the compiled-in
922 maximum aborts the operation.
923
924 This option is useful to cut trailing newlines, for example. If
925 --keyfile-offset is also given, the size count starts after the
926 offset. Works with all commands that accept key files.
927
928 --new-keyfile-offset value
929 Skip value bytes at the start when adding a new passphrase from
930 key file with luksAddKey.
931
932 --new-keyfile-size value
933 Read a maximum of value bytes when adding a new passphrase from
934 key file with luksAddKey. The default is to read the whole file
935 up to the compiled-in maximum length that can be queried with
936 --help. Supplying more than the compiled in maximum aborts the
937 operation. When --new-keyfile-offset is also given, reading
938 starts after the offset.
939
940 --master-key-file
941 Use a master key stored in a file.
942
943 For luksFormat this allows creating a LUKS header with this spe‐
944 cific master key. If the master key was taken from an existing
945 LUKS header and all other parameters are the same, then the new
946 header decrypts the data encrypted with the header the master
947 key was taken from.
948
949 Action luksDump together with --dump-master-key option: The vol‐
950 ume (master) key is stored in a file instead of being printed
951 out to standard output.
952
953 WARNING: If you create your own master key, you need to make
954 sure to do it right. Otherwise, you can end up with a low-en‐
955 tropy or otherwise partially predictable master key which will
956 compromise security.
957
958 For luksAddKey this allows adding a new passphrase without hav‐
959 ing to know an existing one.
960
961 For open this allows one to open the LUKS device without giving
962 a passphrase.
963
964 --dump-master-key
965 For luksDump this option includes the master key in the dis‐
966 played information. Use with care, as the master key can be used
967 to bypass the passphrases, see also option --master-key-file.
968
969 --json-file
970 Read token json from a file or write token to it. See token ac‐
971 tion for more information. --json-file=- reads json from stan‐
972 dard input or writes it to standard output respectively.
973
974 --use-random
975
976 --use-urandom
977 For luksFormat these options define which kernel random number
978 generator will be used to create the master key (which is a
979 long-term key).
980
981 See NOTES ON RANDOM NUMBER GENERATORS for more information. Use
982 cryptsetup --help to show the compiled-in default random number
983 generator.
984
985 WARNING: In a low-entropy situation (e.g. in an embedded sys‐
986 tem), both selections are problematic. Using /dev/urandom can
987 lead to weak keys. Using /dev/random can block a long time, po‐
988 tentially forever, if not enough entropy can be harvested by the
989 kernel.
990
991 --key-slot, -S <0-7>
992 For LUKS operations that add key material, this options allows
993 you to specify which key slot is selected for the new key. This
994 option can be used for luksFormat, and luksAddKey.
995 In addition, for open, this option selects a specific key-slot
996 to compare the passphrase against. If the given passphrase
997 would only match a different key-slot, the operation fails.
998
999 --key-size, -s <bits>
1000 Sets key size in bits. The argument has to be a multiple of 8.
1001 The possible key-sizes are limited by the cipher and mode used.
1002
1003 See /proc/crypto for more information. Note that key-size in
1004 /proc/crypto is stated in bytes.
1005
1006 This option can be used for open --type plain or luksFormat.
1007 All other LUKS actions will use the key-size specified in the
1008 LUKS header. Use cryptsetup --help to show the compiled-in de‐
1009 faults.
1010
1011 --size, -b <number of 512 byte sectors>
1012 Set the size of the device in sectors of 512 bytes. This option
1013 is only relevant for the open and resize actions.
1014
1015 --offset, -o <number of 512 byte sectors>
1016 Start offset in the backend device in 512-byte sectors. This
1017 option is only relevant for the open action with plain or
1018 loopaes device types or for LUKS devices in luksFormat.
1019
1020 For LUKS, the --offset option sets the data offset (payload) of
1021 data device and must be be aligned to 4096-byte sectors (must be
1022 multiple of 8). This option cannot be combined with
1023 --align-payload option.
1024
1025 --skip, -p <number of 512 byte sectors>
1026 Start offset used in IV calculation in 512-byte sectors (how
1027 many sectors of the encrypted data to skip at the beginning).
1028 This option is only relevant for the open action with plain or
1029 loopaes device types.
1030
1031 Hence, if --offset n, and --skip s, sector n (the first sector
1032 of the encrypted device) will get a sector number of s for the
1033 IV calculation.
1034
1035 --device-size size[units]
1036 Instead of real device size, use specified value.
1037
1038 With reencrypt action it means that only specified area (from
1039 the start of the device to the specified size) will be reen‐
1040 crypted.
1041
1042 With resize action it sets new size of the device.
1043
1044 If no unit suffix is specified, the size is in bytes.
1045
1046 Unit suffix can be S for 512 byte sectors, K/M/G/T (or
1047 KiB,MiB,GiB,TiB) for units with 1024 base or KB/MB/GB/TB for
1048 1000 base (SI scale).
1049
1050 WARNING: This is destructive operation when used with reencrypt
1051 command.
1052
1053 --readonly, -r
1054 set up a read-only mapping.
1055
1056 --shared
1057 Creates an additional mapping for one common ciphertext device.
1058 Arbitrary mappings are supported. This option is only relevant
1059 for the open --type plain action. Use --offset, --size and
1060 --skip to specify the mapped area.
1061
1062 --pbkdf <PBKDF spec>
1063 Set Password-Based Key Derivation Function (PBKDF) algorithm for
1064 LUKS keyslot. The PBKDF can be: pbkdf2 (for PBKDF2 according to
1065 RFC2898), argon2i for Argon2i or argon2id for Argon2id (see
1066 https://www.cryptolux.org/index.php/Argon2 for more info).
1067
1068 For LUKS1, only PBKDF2 is accepted (no need to use this option).
1069 The default PBKDF2 for LUKS2 is set during compilation time and
1070 is available in cryptsetup --help output.
1071
1072 A PBKDF is used for increasing dictionary and brute-force attack
1073 cost for keyslot passwords. The parameters can be time, memory
1074 and parallel cost.
1075
1076 For PBKDF2, only time cost (number of iterations) applies. For
1077 Argon2i/id, there is also memory cost (memory required during
1078 the process of key derivation) and parallel cost (number of
1079 threads that run in parallel during the key derivation.
1080
1081 Note that increasing memory cost also increases time, so the fi‐
1082 nal parameter values are measured by a benchmark. The benchmark
1083 tries to find iteration time (--iter-time) with required memory
1084 cost --pbkdf-memory. If it is not possible, the memory cost is
1085 decreased as well. The parallel cost --pbkdf-parallel is con‐
1086 stant, is is checked against available CPU cores (if not avail‐
1087 able, it is decreased) and the maximum parallel cost is 4.
1088
1089 You can see all PBKDF parameters for particular LUKS2 keyslot
1090 with luksDump command.
1091
1092 NOTE: If you do not want to use benchmark and want to specify
1093 all parameters directly, use --pbkdf-force-iterations with
1094 --pbkdf-memory and --pbkdf-parallel. This will override the
1095 values without benchmarking. Note it can cause extremely long
1096 unlocking time. Use only in specific cases, for example, if you
1097 know that the formatted device will be used on some small embed‐
1098 ded system. In this case, the LUKS PBKDF2 digest will be set to
1099 the minimum iteration count.
1100
1101 --iter-time, -i <number of milliseconds>
1102 The number of milliseconds to spend with PBKDF passphrase pro‐
1103 cessing. This option is only relevant for LUKS operations that
1104 set or change passphrases, such as luksFormat or luksAddKey.
1105 Specifying 0 as parameter selects the compiled-in default.
1106
1107 --pbkdf-memory <number>
1108 Set the memory cost for PBKDF (for Argon2i/id the number repre‐
1109 sents kilobytes). Note that it is maximal value, PBKDF bench‐
1110 mark or available physical memory can decrease it. This option
1111 is not available for PBKDF2.
1112
1113 --pbkdf-parallel <number>
1114 Set the parallel cost for PBKDF (number of threads, up to 4).
1115 Note that it is maximal value, it is decreased automatically if
1116 CPU online count is lower. This option is not available for
1117 PBKDF2.
1118
1119 --pbkdf-force-iterations <num>
1120 Avoid PBKDF benchmark and set time cost (iterations) directly.
1121 It can be used for LUKS/LUKS2 device only. See --pbkdf option
1122 for more info.
1123
1124 --batch-mode, -q
1125 Suppresses all confirmation questions. Use with care!
1126
1127 If the -y option is not specified, this option also switches off
1128 the passphrase verification for luksFormat.
1129
1130 --progress-frequency <seconds>
1131 Print separate line every <seconds> with wipe progress.
1132
1133 --timeout, -t <number of seconds>
1134 The number of seconds to wait before timeout on passphrase input
1135 via terminal. It is relevant every time a passphrase is asked,
1136 for example for open, luksFormat or luksAddKey. It has no ef‐
1137 fect if used in conjunction with --key-file.
1138 This option is useful when the system should not stall if the
1139 user does not input a passphrase, e.g. during boot. The default
1140 is a value of 0 seconds, which means to wait forever.
1141
1142 --tries, -T
1143 How often the input of the passphrase shall be retried. This
1144 option is relevant every time a passphrase is asked, for example
1145 for open, luksFormat or luksAddKey. The default is 3 tries.
1146
1147 --align-payload <number of 512 byte sectors>
1148 Align payload at a boundary of value 512-byte sectors. This op‐
1149 tion is relevant for luksFormat.
1150
1151 If not specified, cryptsetup tries to use the topology info pro‐
1152 vided by the kernel for the underlying device to get the optimal
1153 alignment. If not available (or the calculated value is a mul‐
1154 tiple of the default) data is by default aligned to a 1MiB
1155 boundary (i.e. 2048 512-byte sectors).
1156
1157 For a detached LUKS header, this option specifies the offset on
1158 the data device. See also the --header option.
1159
1160 WARNING: This option is DEPRECATED and has often unexpected im‐
1161 pact to the data offset and keyslot area size (for LUKS2) due to
1162 the complex rounding. For fixed data device offset use --offset
1163 option instead.
1164
1165
1166 --uuid=UUID
1167 Use the provided UUID for the luksFormat command instead of gen‐
1168 erating a new one. Changes the existing UUID when used with the
1169 luksUUID command.
1170
1171 The UUID must be provided in the standard UUID format, e.g.
1172 12345678-1234-1234-1234-123456789abc.
1173
1174 --allow-discards
1175 Allow the use of discard (TRIM) requests for the device. This
1176 option is only relevant for open action. This is also not sup‐
1177 ported for LUKS2 devices with data integrity protection.
1178
1179 WARNING: This command can have a negative security impact be‐
1180 cause it can make filesystem-level operations visible on the
1181 physical device. For example, information leaking filesystem
1182 type, used space, etc. may be extractable from the physical de‐
1183 vice if the discarded blocks can be located later. If in doubt,
1184 do not use it.
1185
1186 A kernel version of 3.1 or later is needed. For earlier kernels,
1187 this option is ignored.
1188
1189 --perf-same_cpu_crypt
1190 Perform encryption using the same cpu that IO was submitted on.
1191 The default is to use an unbound workqueue so that encryption
1192 work is automatically balanced between available CPUs. This op‐
1193 tion is only relevant for open action.
1194
1195 NOTE: This option is available only for low-level dm-crypt per‐
1196 formance tuning, use only if you need a change to default dm-
1197 crypt behaviour. Needs kernel 4.0 or later.
1198
1199 --perf-submit_from_crypt_cpus
1200 Disable offloading writes to a separate thread after encryption.
1201 There are some situations where offloading write bios from the
1202 encryption threads to a single thread degrades performance sig‐
1203 nificantly. The default is to offload write bios to the same
1204 thread. This option is only relevant for open action.
1205
1206 NOTE: This option is available only for low-level dm-crypt per‐
1207 formance tuning, use only if you need a change to default dm-
1208 crypt behaviour. Needs kernel 4.0 or later.
1209
1210 --perf-no_read_workqueue, --perf-no_write_workqueue
1211 Bypass dm-crypt internal workqueue and process read or write re‐
1212 quests synchronously. This option is only relevant for open ac‐
1213 tion.
1214
1215 NOTE: These options are available only for low-level dm-crypt
1216 performance tuning, use only if you need a change to default dm-
1217 crypt behaviour. Needs kernel 5.9 or later.
1218
1219 --test-passphrase
1220 Do not activate the device, just verify passphrase. This option
1221 is only relevant for open action (the device mapping name is not
1222 mandatory if this option is used).
1223
1224 --header <device or file storing the LUKS header>
1225 Use a detached (separated) metadata device or file where the
1226 LUKS header is stored. This option allows one to store cipher‐
1227 text and LUKS header on different devices.
1228
1229 This option is only relevant for LUKS devices and can be used
1230 with the luksFormat, open, luksSuspend, luksResume, status and
1231 resize commands.
1232
1233 For luksFormat with a file name as the argument to --header, the
1234 file will be automatically created if it does not exist. See
1235 the cryptsetup FAQ for header size calculation.
1236
1237 For other commands that change the LUKS header (e.g. luksAdd‐
1238 Key), specify the device or file with the LUKS header directly
1239 as the LUKS device.
1240
1241 If used with luksFormat, the --align-payload option is taken as
1242 absolute sector alignment on ciphertext device and can be zero.
1243
1244 WARNING: There is no check whether the ciphertext device speci‐
1245 fied actually belongs to the header given. In fact, you can
1246 specify an arbitrary device as the ciphertext device for open
1247 with the --header option. Use with care.
1248
1249 --header-backup-file <file>
1250 Specify file with header backup for luksHeaderBackup or luk‐
1251 sHeaderRestore actions.
1252
1253 --force-password
1254 Do not use password quality checking for new LUKS passwords.
1255
1256 This option applies only to luksFormat, luksAddKey and
1257 luksChangeKey and is ignored if cryptsetup is built without
1258 password quality checking support.
1259
1260 For more info about password quality check, see the manual page
1261 for pwquality.conf(5) and passwdqc.conf(5).
1262
1263 --deferred
1264 Defers device removal in close command until the last user
1265 closes it.
1266
1267 --disable-locks
1268 Disable lock protection for metadata on disk. This option is
1269 valid only for LUKS2 and ignored for other formats.
1270
1271 WARNING: Do not use this option unless you run cryptsetup in a
1272 restricted environment where locking is impossible to perform
1273 (where /run directory cannot be used).
1274
1275 --disable-keyring
1276 Do not load volume key in kernel keyring and store it directly
1277 in the dm-crypt target instead. This option is supported only
1278 for the LUKS2 format.
1279
1280 --key-description <text>
1281 Set key description in keyring for use with token command.
1282
1283 --priority <normal|prefer|ignore>
1284 Set a priority for LUKS2 keyslot. The prefer priority marked
1285 slots are tried before normal priority. The ignored priority
1286 means, that slot is never used, if not explicitly requested by
1287 --key-slot option.
1288
1289 --token-id
1290 Specify what token to use in actions token, open or resize. If
1291 omitted, all available tokens will be checked before proceeding
1292 further with passphrase prompt.
1293
1294 --token-only
1295 Do not proceed further with action (any of token, open or re‐
1296 size) if token activation failed. Without the option, action
1297 asks for passphrase to proceed further.
1298
1299 --sector-size <bytes>
1300 Set sector size for use with disk encryption. It must be power
1301 of two and in range 512 - 4096 bytes. The default is 512 bytes
1302 sectors. This option is available only in the LUKS2 mode.
1303
1304 Note that if sector size is higher than underlying device hard‐
1305 ware sector and there is not integrity protection that uses data
1306 journal, using this option can increase risk on incomplete sec‐
1307 tor writes during a power fail.
1308
1309 If used together with --integrity option and dm-integrity jour‐
1310 nal, the atomicity of writes is guaranteed in all cases (but it
1311 cost write performance - data has to be written twice).
1312
1313 Increasing sector size from 512 bytes to 4096 bytes can provide
1314 better performance on most of the modern storage devices and
1315 also with some hw encryption accelerators.
1316
1317 --iv-large-sectors
1318 Count Initialization Vector (IV) in larger sector size (if set)
1319 instead of 512 bytes sectors. This option can be used only for
1320 open command and plain encryption type.
1321
1322 NOTE: This option does not have any performance or security im‐
1323 pact, use it only for accessing incompatible existing disk im‐
1324 ages from other systems that require this option.
1325
1326 --persistent
1327 If used with LUKS2 devices and activation commands like open or
1328 refresh, the specified activation flags are persistently written
1329 into metadata and used next time automatically even for normal
1330 activation. (No need to use cryptab or other system configura‐
1331 tion files.)
1332
1333 If you need to remove a persistent flag, use --persistent with‐
1334 out the flag you want to remove (e.g. to disable persistently
1335 stored discard flag, use --persistent without --allow-discards).
1336
1337 Only --allow-discards, --perf-same_cpu_crypt, --perf-sub‐
1338 mit_from_crypt_cpus, --perf-no_read_workqueue,
1339 --perf-no_write_workqueue and --integrity-no-journal can be
1340 stored persistently.
1341
1342 --refresh
1343 Refreshes an active device with new set of parameters. See ac‐
1344 tion refresh description for more details.
1345
1346 --label <LABEL>
1347 --subsystem <SUBSYSTEM> Set label and subsystem description for
1348 LUKS2 device, can be used in config and format actions. The la‐
1349 bel and subsystem are optional fields and can be later used in
1350 udev scripts for triggering user actions once device marked by
1351 these labels is detected.
1352
1353 --integrity <integrity algorithm>
1354 Specify integrity algorithm to be used for authenticated disk
1355 encryption in LUKS2.
1356
1357 WARNING: This extension is EXPERIMENTAL and requires dm-integ‐
1358 rity kernel target (available since kernel version 4.12). For
1359 native AEAD modes, also enable "User-space interface for AEAD
1360 cipher algorithms" in "Cryptographic API" section (CON‐
1361 FIG_CRYPTO_USER_API_AEAD .config option).
1362
1363 For more info, see AUTHENTICATED DISK ENCRYPTION section.
1364
1365 --luks2-metadata-size <size>
1366 This option can be used to enlarge the LUKS2 metadata (JSON)
1367 area. The size includes 4096 bytes for binary metadata (usable
1368 JSON area is smaller of the binary area). According to LUKS2
1369 specification, only these values are valid: 16, 32, 64, 128,
1370 256, 512, 1024, 2048 and 4096 kB The <size> can be specified
1371 with unit suffix (for example 128k).
1372
1373 --luks2-keyslots-size <size>
1374 This option can be used to set specific size of the LUKS2 binary
1375 keyslot area (key material is encrypted there). The value must
1376 be aligned to multiple of 4096 bytes with maximum size 128MB.
1377 The <size> can be specified with unit suffix (for example 128k).
1378
1379 --keyslot-cipher <cipher-spec>
1380 This option can be used to set specific cipher encryption for
1381 the LUKS2 keyslot area.
1382
1383 --keyslot-key-size <bits>
1384 This option can be used to set specific key size for the LUKS2
1385 keyslot area.
1386
1387 --integrity-no-journal
1388 Activate device with integrity protection without using data
1389 journal (direct write of data and integrity tags). Note that
1390 without journal power fail can cause non-atomic write and data
1391 corruption. Use only if journalling is performed on a different
1392 storage layer.
1393
1394 --integrity-no-wipe
1395 Skip wiping of device authentication (integrity) tags. If you
1396 skip this step, sectors will report invalid integrity tag until
1397 an application write to the sector.
1398
1399 NOTE: Even some writes to the device can fail if the write is
1400 not aligned to page size and page-cache initiates read of a sec‐
1401 tor with invalid integrity tag.
1402
1403 --unbound
1404
1405 Creates new or dumps existing LUKS2 unbound keyslot. See luksAd‐
1406 dKey or luksDump actions for more details.
1407
1408
1409 --tcrypt-hidden
1410 --tcrypt-system --tcrypt-backup Specify which TrueCrypt on-disk
1411 header will be used to open the device. See TCRYPT section for
1412 more info.
1413
1414 --veracrypt
1415 Allow VeraCrypt compatible mode. Only for TCRYPT extension. See
1416 TCRYPT section for more info.
1417
1418 --veracrypt-pim
1419 --veracrypt-query-pim Use a custom Personal Iteration Multiplier
1420 (PIM) for VeraCrypt device. See TCRYPT section for more info.
1421
1422 --serialize-memory-hard-pbkdf
1423 Use a global lock to serialize unlocking of keyslots using mem‐
1424 ory-hard PBKDF.
1425
1426 NOTE: This is (ugly) workaround for a specific situation when
1427 multiple devices are activated in parallel and system instead of
1428 reporting out of memory starts unconditionally stop processes
1429 using out-of-memory killer.
1430
1431 DO NOT USE this switch until you are implementing boot environ‐
1432 ment with parallel devices activation!
1433
1434 --encrypt
1435 Initialize (and run) device encryption (reencrypt action parame‐
1436 ter)
1437
1438 --decrypt
1439 Initialize (and run) device decryption (reencrypt action parame‐
1440 ter)
1441
1442 --init-only
1443 Initialize reencryption (any variant) operation in LUKS2 meta‐
1444 data only and exit. If any reencrypt operation is already ini‐
1445 tialized in metadata, the command with --init-only parameter
1446 fails.
1447
1448 --resume-only
1449 Resume reencryption (any variant) operation already described in
1450 LUKS2 metadata. If no reencrypt operation is initialized, the
1451 command with --resume-only parameter fails. Useful for resuming
1452 reencrypt operation without accidentally triggering new reen‐
1453 cryption operation.
1454
1455 --resilience <mode>
1456 Reencryption resilience mode can be one of checksum, journal or
1457 none.
1458
1459 checksum: default mode, where individual checksums of ciphertext
1460 hotzone sectors are stored, so the recovery process can detect
1461 which sectors where already reencrypted. It requires that the
1462 device sector write is atomic.
1463
1464 journal: the hotzone is journaled in the binary area (so the
1465 data are written twice).
1466
1467 none: performance mode. There is no protection and the only way
1468 it's safe to interrupt the reencryption is similar to old off‐
1469 line reencryption utility. (ctrl+c).
1470
1471 The option is ignored if reencryption with datashift mode is in
1472 progress.
1473
1474 --resilience-hash <hash>
1475 The hash algorithm used with "--resilience checksum" only. The
1476 default hash is sha256. With other resilience modes, the hash
1477 parameter is ignored.
1478
1479 --hotzone-size <size>
1480 This option can be used to set an upper limit on the size of
1481 reencryption area (hotzone). The <size> can be specified with
1482 unit suffix (for example 50M). Note that actual hotzone size may
1483 be less than specified <size> due to other limitations (free
1484 space in keyslots area or available memory).
1485
1486 --reduce-device-size <size>
1487 Initialize LUKS2 reencryption with data device size reduction
1488 (currently only --encrypt variant is supported).
1489
1490 Last <size> sectors of <device> will be used to properly ini‐
1491 tialize device reencryption. That means any data at last <size>
1492 sectors will be lost.
1493
1494 It could be useful if you added some space to underlying parti‐
1495 tion or logical volume (so last <size> sectors contains no
1496 data).
1497
1498 Recommended minimal size is twice the default LUKS2 header size
1499 (--reduce-device-size 32M) for --encrypt use case. Be sure to
1500 have enough (at least --reduce-device-size value of free
1501 space at the end of <device>).
1502
1503 WARNING: This is a destructive operation and cannot be reverted.
1504 Use with extreme care - accidentally overwritten filesystems are
1505 usually unrecoverable.
1506
1507 --version
1508 Show the program version.
1509
1510 --usage
1511 Show short option help.
1512
1513 --help, -?
1514 Show help text and default parameters.
1515
1517 Example 1: Create LUKS 2 container on block device /dev/sdX.
1518 sudo cryptsetup --type luks2 luksFormat /dev/sdX
1519
1520 Example 2: Add an additional passphrase to key slot 5.
1521 sudo cryptsetup luksAddKey --key-slot 5 /dev/sdX
1522
1523 Example 3: Create LUKS header backup and save it to file.
1524 sudo cryptsetup luksHeaderBackup /dev/sdX --header-backup-file
1525 /var/tmp/NameOfBackupFile
1526
1527 Example 4: Open LUKS contaner on /dev/sdX and map it to sdX_crypt.
1528 sudo cryptsetup open /dev/sdX sdX_crypt
1529
1530 WARNING: The command in example 5 will erase all key slots.
1531 Your cannot use your luks container afterwards anymore unless
1532 you have a backup to restore.
1533
1534 Example 5: Erase all key slots on /dev/sdX.
1535 sudo cryptsetup erase /dev/sdX
1536
1537 Example 6: Restore LUKS header from backup file.
1538 sudo cryptsetup luksHeaderRestore /dev/sdX --header-backup-file
1539 /var/tmp/NameOfBackupFile
1540
1542 Cryptsetup returns 0 on success and a non-zero value on error.
1543
1544 Error codes are: 1 wrong parameters, 2 no permission (bad passphrase),
1545 3 out of memory, 4 wrong device specified, 5 device already exists or
1546 device is busy.
1547
1549 Note that no iterated hashing or salting is done in plain mode. If
1550 hashing is done, it is a single direct hash. This means that low-en‐
1551 tropy passphrases are easy to attack in plain mode.
1552
1553 From a terminal: The passphrase is read until the first newline, i.e.
1554 '\n'. The input without the newline character is processed with the
1555 default hash or the hash specified with --hash. The hash result will
1556 be truncated to the key size of the used cipher, or the size specified
1557 with -s.
1558
1559 From stdin: Reading will continue until a newline (or until the maximum
1560 input size is reached), with the trailing newline stripped. The maximum
1561 input size is defined by the same compiled-in default as for the maxi‐
1562 mum key file size and can be overwritten using --keyfile-size option.
1563
1564 The data read will be hashed with the default hash or the hash speci‐
1565 fied with --hash. The hash result will be truncated to the key size of
1566 the used cipher, or the size specified with -s.
1567
1568 Note that if --key-file=- is used for reading the key from stdin,
1569 trailing newlines are not stripped from the input.
1570
1571 If "plain" is used as argument to --hash, the input data will not be
1572 hashed. Instead, it will be zero padded (if shorter than the key size)
1573 or truncated (if longer than the key size) and used directly as the bi‐
1574 nary key. This is useful for directly specifying a binary key. No
1575 warning will be given if the amount of data read from stdin is less
1576 than the key size.
1577
1578 From a key file: It will be truncated to the key size of the used ci‐
1579 pher or the size given by -s and directly used as a binary key.
1580
1581 WARNING: The --hash argument is being ignored. The --hash option is
1582 usable only for stdin input in plain mode.
1583
1584 If the key file is shorter than the key, cryptsetup will quit with an
1585 error. The maximum input size is defined by the same compiled-in de‐
1586 fault as for the maximum key file size and can be overwritten using
1587 --keyfile-size option.
1588
1589
1590
1592 LUKS uses PBKDF2 to protect against dictionary attacks and to give some
1593 protection to low-entropy passphrases (see RFC 2898 and the cryptsetup
1594 FAQ).
1595
1596 From a terminal: The passphrase is read until the first newline and
1597 then processed by PBKDF2 without the newline character.
1598
1599 From stdin: LUKS will read passphrases from stdin up to the first new‐
1600 line character or the compiled-in maximum key file length. If --key‐
1601 file-size is given, it is ignored.
1602
1603 From key file: The complete keyfile is read up to the compiled-in maxi‐
1604 mum size. Newline characters do not terminate the input. The --key‐
1605 file-size option can be used to limit what is read.
1606
1607 Passphrase processing: Whenever a passphrase is added to a LUKS header
1608 (luksAddKey, luksFormat), the user may specify how much the time the
1609 passphrase processing should consume. The time is used to determine the
1610 iteration count for PBKDF2 and higher times will offer better protec‐
1611 tion for low-entropy passphrases, but open will take longer to com‐
1612 plete. For passphrases that have entropy higher than the used key
1613 length, higher iteration times will not increase security.
1614
1615 The default setting of one or two seconds is sufficient for most prac‐
1616 tical cases. The only exception is a low-entropy passphrase used on a
1617 device with a slow CPU, as this will result in a low iteration count.
1618 On a slow device, it may be advisable to increase the iteration time
1619 using the --iter-time option in order to obtain a higher iteration
1620 count. This does slow down all later luksOpen operations accordingly.
1621
1623 LUKS checks for a valid passphrase when an encrypted partition is un‐
1624 locked. The behavior of plain dm-crypt is different. It will always
1625 decrypt with the passphrase given. If the given passphrase is wrong,
1626 the device mapped by plain dm-crypt will essentially still contain en‐
1627 crypted data and will be unreadable.
1628
1630 The available combinations of ciphers, modes, hashes and key sizes de‐
1631 pend on kernel support. See /proc/crypto for a list of available op‐
1632 tions. You might need to load additional kernel crypto modules in order
1633 to get more options.
1634
1635 For the --hash option, if the crypto backend is libgcrypt, then all al‐
1636 gorithms supported by the gcrypt library are available. For other
1637 crypto backends, some algorithms may be missing.
1638
1640 Mathematics can't be bribed. Make sure you keep your passphrases safe.
1641 There are a few nice tricks for constructing a fallback, when suddenly
1642 out of the blue, your brain refuses to cooperate. These fallbacks need
1643 LUKS, as it's only possible with LUKS to have multiple passphrases.
1644 Still, if your attacker model does not prevent it, storing your
1645 passphrase in a sealed envelope somewhere may be a good idea as well.
1646
1648 Random Number Generators (RNG) used in cryptsetup are always the kernel
1649 RNGs without any modifications or additions to data stream produced.
1650
1651 There are two types of randomness cryptsetup/LUKS needs. One type
1652 (which always uses /dev/urandom) is used for salts, the AF splitter and
1653 for wiping deleted keyslots.
1654
1655 The second type is used for the volume (master) key. You can switch be‐
1656 tween using /dev/random and /dev/urandom here, see --use-random and
1657 --use-urandom options. Using /dev/random on a system without enough en‐
1658 tropy sources can cause luksFormat to block until the requested amount
1659 of random data is gathered. In a low-entropy situation (embedded sys‐
1660 tem), this can take a very long time and potentially forever. At the
1661 same time, using /dev/urandom in a low-entropy situation will produce
1662 low-quality keys. This is a serious problem, but solving it is out of
1663 scope for a mere man-page. See urandom(4) for more information.
1664
1666 Since Linux kernel version 4.12 dm-crypt supports authenticated disk
1667 encryption.
1668
1669 Normal disk encryption modes are length-preserving (plaintext sector is
1670 of the same size as a ciphertext sector) and can provide only confiden‐
1671 tiality protection, but not cryptographically sound data integrity pro‐
1672 tection.
1673
1674 Authenticated modes require additional space per-sector for authentica‐
1675 tion tag and use Authenticated Encryption with Additional Data (AEAD)
1676 algorithms.
1677
1678 If you configure LUKS2 device with data integrity protection, there
1679 will be an underlying dm-integrity device, which provides additional
1680 per-sector metadata space and also provide data journal protection to
1681 ensure atomicity of data and metadata update. Because there must be
1682 additional space for metadata and journal, the available space for the
1683 device will be smaller than for length-preserving modes.
1684
1685 The dm-crypt device then resides on top of such a dm-integrity device.
1686 All activation and deactivation of this device stack is performed by
1687 cryptsetup, there is no difference in using luksOpen for integrity pro‐
1688 tected devices. If you want to format LUKS2 device with data integrity
1689 protection, use --integrity option.
1690
1691 Since dm-integrity doesn't support discards (TRIM), dm-crypt device on
1692 top of it inherits this, so integrity protection mode doesn't support
1693 discards either.
1694
1695 Some integrity modes requires two independent keys (key for encryption
1696 and for authentication). Both these keys are stored in one LUKS
1697 keyslot.
1698
1699 WARNING: All support for authenticated modes is experimental and there
1700 are only some modes available for now. Note that there are a very few
1701 authenticated encryption algorithms that are suitable for disk encryp‐
1702 tion. You also cannot use CRC32 or any other non-cryptographic check‐
1703 sums (other than the special integrity mode "none"). If for some reason
1704 you want to have integrity control without using authentication mode,
1705 then you should separately configure dm-integrity independently of
1706 LUKS2.
1707
1708
1710 Cryptsetup is usually used directly on a block device (disk partition
1711 or LVM volume). However, if the device argument is a file, cryptsetup
1712 tries to allocate a loopback device and map it into this file. This
1713 mode requires Linux kernel 2.6.25 or more recent which supports the
1714 loop autoclear flag (loop device is cleared on the last close automati‐
1715 cally). Of course, you can always map a file to a loop-device manually.
1716 See the cryptsetup FAQ for an example.
1717
1718 When device mapping is active, you can see the loop backing file in the
1719 status command output. Also see losetup(8).
1720
1722 The LUKS2 on-disk metadata is updated in several steps and to achieve
1723 proper atomic update, there is a locking mechanism. For an image in
1724 file, code uses flock(2) system call. For a block device, lock is per‐
1725 formed over a special file stored in a locking directory (by default
1726 /run/lock/cryptsetup). The locking directory should be created with
1727 the proper security context by the distribution during the boot-up
1728 phase. Only LUKS2 uses locks, other formats do not use this mechanism.
1729
1731 The reload action is no longer supported. Please use dmsetup(8) if you
1732 need to directly manipulate with the device mapping table.
1733
1734 The luksDelKey was replaced with luksKillSlot.
1735
1737 Report bugs, including ones in the documentation, on the cryptsetup
1738 mailing list at <dm-crypt@saout.de> or in the 'Issues' section on LUKS
1739 website. Please attach the output of the failed command with the --de‐
1740 bug option added.
1741
1743 cryptsetup originally written by Jana Saout <jana@saout.de>
1744 The LUKS extensions and original man page were written by Clemens Fruh‐
1745 wirth <clemens@endorphin.org>.
1746 Man page extensions by Milan Broz <gmazyland@gmail.com>.
1747 Man page rewrite and extension by Arno Wagner <arno@wagner.name>.
1748
1750 Copyright © 2004 Jana Saout
1751 Copyright © 2004-2006 Clemens Fruhwirth
1752 Copyright © 2012-2014 Arno Wagner
1753 Copyright © 2009-2021 Red Hat, Inc.
1754 Copyright © 2009-2021 Milan Broz
1755
1756 This is free software; see the source for copying conditions. There is
1757 NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
1758 PURPOSE.
1759
1761 The LUKS website at https://gitlab.com/cryptsetup/cryptsetup/
1762
1763 The cryptsetup FAQ, contained in the distribution package and online at
1764 https://gitlab.com/cryptsetup/cryptsetup/wikis/FrequentlyAskedQuestions
1765
1766 The cryptsetup mailing list and list archive, see FAQ entry 1.6.
1767
1768 The LUKS version 1 on-disk format specification available at
1769 https://gitlab.com/cryptsetup/cryptsetup/wikis/Specification and LUKS
1770 version 2 at https://gitlab.com/cryptsetup/LUKS2-docs.
1771
1772
1773
1774cryptsetup January 2021 CRYPTSETUP(8)