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