1CRYPTSETUP(8)                Maintenance Commands                CRYPTSETUP(8)
2
3
4

NAME

6       cryptsetup - manage plain dm-crypt and LUKS encrypted volumes
7

SYNOPSIS

9       cryptsetup <options> <action> <action args>
10

DESCRIPTION

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

PLAIN DM-CRYPT OR LUKS?

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

WARNINGS

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

BASIC COMMANDS

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 parametrs are identical to those of an open action for
146              respective device type.
147
148              You   may   change   following   parameters   on   all   devices
149              --perf-same_cpu_crypt,     --perf-submit_from_crypt_cpus     and
150              --allow-discards.
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
161              parameters  above  in  LUKS2  metadata  (only  after  successful
162              refresh 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
193              resilience  mode  is  used  (reencrypt  --encrypt with --reduce-
194              device-size option).
195
196              If the reencryption process was interrupted abruptly  (reencryp‐
197              tion  process  crash,  system  crash,  poweroff)  it may require
198              recovery. The recovery is currently run  automatically  on  next
199              activation (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
203              encryption  initialization  gets  finished.  That's  useful when
204              device needs to be ready as soon as possible and mounted  (used)
205              before full data area encryption is completed.
206
207              Action   supports  following  additional  <options>  [--encrypt,
208              --decrypt,   --device-size,   --resilience,   --resilience-hash,
209              --hotzone-size,            --init-only,           --resume-only,
210              --reduce-device-size].
211
212

PLAIN MODE

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,
231              --refresh]
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

LUKS EXTENSION

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
246       device 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
252       iteration 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
283              results  in the passphrase being read from stdin and the safety-
284              question being skipped.
285
286              You can only call luksFormat  on  a  LUKS  device  that  is  not
287              mapped.
288
289              To use LUKS2, specify --type luks2.
290
291              <options>   can   be   [--hash,  --cipher,  --verify-passphrase,
292              --key-size,  --key-slot,  --key-file  (takes   precedence   over
293              optional  second  argument),  --keyfile-offset,  --keyfile-size,
294              --use-random   |   --use-urandom,   --uuid,   --master-key-file,
295              --iter-time,  --header,  --pbkdf-force-iterations, --force-pass‐
296              word, --disable-locks].
297
298              For   LUKS2,   additional   <options>   can   be   [--integrity,
299              --integrity-no-wipe,    --sector-size,   --label,   --subsystem,
300              --pbkdf,  --pbkdf-memory,   --pbkdf-parallel,   --disable-locks,
301              --disable-keyring, --luks2-metadata-size, --luks2-keyslots-size,
302              --keyslot-cipher, --keyslot-key-size].
303
304              WARNING: Doing a luksFormat on an existing LUKS  container  will
305              make all data the old container permanently irretrievable unless
306              you have a header backup.
307
308       open --type luks <device> <name>
309       luksOpen <device> <name> (old syntax)
310
311              Opens the LUKS device <device> and  sets  up  a  mapping  <name>
312              after successful verification of the supplied passphrase.
313
314              First,  the  passphrase  is searched in LUKS tokens. If it's not
315              found in any token and also the passphrase is not  supplied  via
316              --key-file, the command prompts for it interactively.
317
318              <options>  can be [--key-file, --keyfile-offset, --keyfile-size,
319              --readonly,   --test-passphrase,   --allow-discards,   --header,
320              --key-slot,  --master-key-file, --token-id, --token-only, --dis‐
321              able-keyring,  --disable-locks,  --type,  --refresh,   --serial‐
322              ize-memory-hard-pbkdf].
323
324       luksSuspend <name>
325
326              Suspends  an  active  device  (all  IO operations will block and
327              accesses to the device will wait  indefinitely)  and  wipes  the
328              encryption key from kernel memory. Needs kernel 2.6.19 or later.
329
330              After this operation you have to use luksResume to reinstate the
331              encryption key and unblock the device or  close  to  remove  the
332              mapped device.
333
334              WARNING: never suspend the device on which the cryptsetup binary
335              resides.
336
337              <options> can be [--header, --disable-locks].
338
339       luksResume <name>
340
341              Resumes a suspended device and reinstates  the  encryption  key.
342              Prompts  interactively  for  a  passphrase  if --key-file is not
343              given.
344
345              <options> can be [--key-file, --keyfile-size,  --header,  --dis‐
346              able-keyring, --disable-locks, --type]
347
348       luksAddKey <device> [<key file with new key>]
349
350              Adds  a  new passphrase. An existing passphrase must be supplied
351              interactively or via --key-file.  The new passphrase to be added
352              can  be  specified  interactively or read from the file given as
353              positional argument.
354
355              NOTE: with --unbound option the action creates new unbound LUKS2
356              keyslot.  The  keyslot cannot be used for device activation.  If
357              you don't pass new key via --master-key-file option, new  random
358              key  is generated. Existing passphrase for any active keyslot is
359              not required.
360
361              <options> can be [--key-file, --keyfile-offset,  --keyfile-size,
362              --new-keyfile-offset,   --new-keyfile-size,  --key-slot,  --mas‐
363              ter-key-file,   --force-password,   --header,   --disable-locks,
364              --iter-time,   --pbkdf,   --pbkdf-force-iterations,   --unbound,
365              --type, --keyslot-cipher, --keyslot-key-size].
366
367       luksRemoveKey <device> [<key file with passphrase to be removed>]
368
369              Removes the  supplied  passphrase  from  the  LUKS  device.  The
370              passphrase  to be removed can be specified interactively, as the
371              positional argument or via --key-file.
372
373              <options> can be [--key-file, --keyfile-offset,  --keyfile-size,
374              --header, --disable-locks, --type]
375
376              WARNING:  If you read the passphrase from stdin (without further
377              argument or with '-' as an argument to  --key-file),  batch-mode
378              (-q) will be implicitly switched on and no warning will be given
379              when you remove the last remaining passphrase from a  LUKS  con‐
380              tainer.  Removing  the  last passphrase makes the LUKS container
381              permanently inaccessible.
382
383       luksChangeKey <device> [<new key file>]
384
385              Changes an existing passphrase. The  passphrase  to  be  changed
386              must  be  supplied  interactively  or  via  --key-file.  The new
387              passphrase can be supplied interactively or in a file  given  as
388              positional argument.
389
390              If  a key-slot is specified (via --key-slot), the passphrase for
391              that key-slot must be given and the new  passphrase  will  over‐
392              write  the  specified  key-slot. If no key-slot is specified and
393              there is still a free key-slot, then the new passphrase will  be
394              put  into a free key-slot before the key-slot containing the old
395              passphrase is purged. If there is no  free  key-slot,  then  the
396              key-slot with the old passphrase is overwritten directly.
397
398              WARNING:  If  a  key-slot is overwritten, a media failure during
399              this operation can cause the overwrite to  fail  after  the  old
400              passphrase has been wiped and make the LUKS container inaccessi‐
401              ble.
402
403              <options> can be [--key-file, --keyfile-offset,  --keyfile-size,
404              --new-keyfile-offset, --iter-time, --pbkdf, --pbkdf-force-itera‐
405              tions,   --new-keyfile-size,    --key-slot,    --force-password,
406              --header,     --disable-locks,     --type,     --keyslot-cipher,
407              --keyslot-key-size].
408
409       luksConvertKey <device>
410
411              Converts an existing LUKS2 keyslot to new pbkdf parameters.  The
412              passphrase for keyslot to be converted must be supplied interac‐
413              tively or via --key-file. If no --pbkdf parameters are specified
414              LUKS2 default pbkdf values will apply.
415
416              If  a  keyslot is specified (via --key-slot), the passphrase for
417              that keyslot must be given. If no keyslot is specified and there
418              is  still  a  free  keyslot, then the new parameters will be put
419              into a free keyslot before the keyslot containing the old param‐
420              eters  is  purged. If there is no free keyslot, then the keyslot
421              with the old parameters is overwritten directly.
422
423              WARNING: If a keyslot is overwritten,  a  media  failure  during
424              this  operation  can  cause  the overwrite to fail after the old
425              parameters have been wiped and make the LUKS container  inacces‐
426              sible.
427
428              <options>  can be [--key-file, --keyfile-offset, --keyfile-size,
429              --key-slot,  --header,  --disable-locks,  --iter-time,  --pbkdf,
430              --pbkdf-force-iterations,    --pbkdf-memory,   --pbkdf-parallel,
431              --keyslot-cipher, --keyslot-key-size].
432
433       luksKillSlot <device> <key slot number>
434
435              Wipe the key-slot number <key slot> from the LUKS device. Except
436              running  in  batch-mode (-q) a remaining passphrase must be sup‐
437              plied, either interactively or via --key-file.  This command can
438              remove  the last remaining key-slot, but requires an interactive
439              confirmation when doing so. Removing the last passphrase makes a
440              LUKS container permanently inaccessible.
441
442              <options>  can be [--key-file, --keyfile-offset, --keyfile-size,
443              --header, --disable-locks, --type].
444
445              WARNING: If you read the passphrase from stdin (without  further
446              argument  or  with '-' as an argument to --key-file), batch-mode
447              (-q) will be implicitly switched on and no warning will be given
448              when  you  remove the last remaining passphrase from a LUKS con‐
449              tainer. Removing the last passphrase makes  the  LUKS  container
450              permanently inaccessible.
451
452              NOTE:  If  there  is no passphrase provided (on stdin or through
453              --key-file argument) and batch-mode (-q) is active, the key-slot
454              is removed without any other warning.
455
456
457       erase <device>
458       luksErase <device>
459
460              Erase all keyslots and make the LUKS container permanently inac‐
461              cessible.  You do not need to  provide  any  password  for  this
462              operation.
463
464              WARNING: This operation is irreversible.
465
466       luksUUID <device>
467
468              Print the UUID of a LUKS device.
469              Set new UUID if --uuid option is specified.
470
471       isLuks <device>
472
473              Returns  true,  if  <device>  is a LUKS device, false otherwise.
474              Use option -v to get human-readable feedback. 'Command  success‐
475              ful.'  means the device is a LUKS device.
476
477              By specifying --type you may query for specific LUKS version.
478
479       luksDump <device>
480
481              Dump the header information of a LUKS device.
482
483              If  the --dump-master-key option is used, the LUKS device master
484              key is dumped instead of the keyslot info. Together with  --mas‐
485              ter-key-file  option,  master key is dumped to a file instead of
486              standard output. Beware that the master key  cannot  be  changed
487              without  reencryption and can be used to decrypt the data stored
488              in the LUKS container without a passphrase and even without  the
489              LUKS  header.  This means that if the master key is compromised,
490              the whole device has to be erased to prevent further access. Use
491              this option carefully.
492
493              To  dump the master key, a passphrase has to be supplied, either
494              interactively or via --key-file.
495
496              <options> can be [--dump-master-key, --key-file,  --keyfile-off‐
497              set,    --keyfile-size,    --header,   --disable-locks,   --mas‐
498              ter-key-file, --type].
499
500              WARNING: If --dump-master-key is used with  --key-file  and  the
501              argument  to  --key-file  is '-', no validation question will be
502              asked and no warning given.
503
504       luksHeaderBackup <device> --header-backup-file <file>
505
506              Stores a binary backup of the LUKS header and keyslot area.
507              Note: Using '-' as filename writes the header backup to  a  file
508              named '-'.
509
510              WARNING:  This backup file and a passphrase valid at the time of
511              backup allows decryption of the LUKS  data  area,  even  if  the
512              passphrase  was  later  changed or removed from the LUKS device.
513              Also note that with a header backup  you  lose  the  ability  to
514              securely wipe the LUKS device by just overwriting the header and
515              key-slots. You either need to securely erase all header  backups
516              in  addition  or overwrite the encrypted data area as well.  The
517              second option is less secure, as some sectors can survive,  e.g.
518              due to defect management.
519
520       luksHeaderRestore <device> --header-backup-file <file>
521
522              Restores  a  binary  backup  of the LUKS header and keyslot area
523              from the specified file.
524              Note: Using '-' as filename reads the header backup from a  file
525              named '-'.
526
527              WARNING:   Header  and  keyslots  will  be  replaced,  only  the
528              passphrases from the backup will work afterward.
529
530              This command requires that the master key size and  data  offset
531              of  the  LUKS  header  already  on  the device and of the header
532              backup match. Alternatively, if there is no LUKS header  on  the
533              device, the backup will also be written to it.
534
535       token <add|remove|import|export> <device>
536
537              Action  add  creates new keyring token to enable auto-activation
538              of the device.  For the auto-activation, the passphrase must  be
539              stored  in  keyring with the specified description. Usually, the
540              passphrase should be stored in  user  or  user-session  keyring.
541              The token command is supported only for LUKS2.
542
543              For adding new keyring token, option --key-description is manda‐
544              tory.  Also, new token is assigned to key  slot  specified  with
545              --key-slot  option  or  to  all  active  key  slots  in the case
546              --key-slot option is omitted.
547
548              To remove existing token, specify the token ID which  should  be
549              removed with --token-id option.
550
551              WARNING:  The  action  token  remove removes any token type, not
552              just keyring  type  from  token  slot  specified  by  --token-id
553              option.
554
555              Action  import  can  store  arbitrary  valid token json in LUKS2
556              header. It may be passed via standard input or via  file  passed
557              in  --json-file  option. If you specify --key-slot then success‐
558              fully imported token is also assigned to the key slot.
559
560              Action export writes requested token json to a file passed  with
561              --json-file or to standard output.
562
563              <options>    can    be    [--header,   --token-id,   --key-slot,
564              --key-description,      --disable-locks,      --disable-keyring,
565              --json-file].
566
567       convert <device> --type <format>
568
569              Converts  the  device  between LUKS1 and LUKS2 format (if possi‐
570              ble).  The conversion will not be performed if there is an addi‐
571              tional LUKS2 feature or LUKS1 has unsupported header size.
572
573              Conversion  (both  directions)  must  be  performed  on inactive
574              device. There must not be active  dm-crypt  mapping  established
575              for LUKS header requested for conversion.
576
577              --type option is mandatory with following accepted values: luks1
578              or luks2.
579
580              WARNING: The convert action can destroy the LUKS header  in  the
581              case  of  a  crash during conversion or if a media error occurs.
582              Always create a header backup before performing this operation!
583
584              <options> can be [--header, --type].
585
586       config <device>
587
588              Set permanent configuration options (store to LUKS header).  The
589              config command is supported only for LUKS2.
590
591              The permanent options can be --priority to set priority (normal,
592              prefer, ignore) for keyslot (specified by --key-slot) or --label
593              and --subsystem.
594
595              <options>  can be [--priority, --label, --subsystem, --key-slot,
596              --header].
597
598

loop-AES EXTENSION

600       cryptsetup supports mapping loop-AES encrypted partition using  a  com‐
601       patibility mode.
602
603       open --type loopaes <device> <name> --key-file <keyfile>
604       loopaesOpen <device> <name> --key-file <keyfile>  (old syntax)
605
606              Opens the loop-AES <device> and sets up a mapping <name>.
607
608              If  the  key  file is encrypted with GnuPG, then you have to use
609              --key-file=- and decrypt it before use, e.g. like this:
610              gpg --decrypt <keyfile> |  cryptsetup  loopaesOpen  --key-file=-
611              <device> <name>
612
613              WARNING:  The  loop-AES extension cannot use the direct input of
614              key file on real terminal because the keys are separated by end-
615              of-line and only part of the multi-key file would be read.
616              If you need it in script, just use the pipe redirection:
617              echo  $keyfile  |  cryptsetup  loopaesOpen --key-file=- <device>
618              <name>
619
620              Use --keyfile-size to specify the proper key length if needed.
621
622              Use --offset to specify device offset. Note that the units  need
623              to be specified in number of 512 byte sectors.
624
625              Use --skip to specify the IV offset. If the original device used
626              an offset and but did not use it in IV sector calculations,  you
627              have to explicitly use --skip 0 in addition to the offset param‐
628              eter.
629
630              Use --hash to override the default hash function for  passphrase
631              hashing (otherwise it is detected according to key size).
632
633              <options>  can  be  [--key-file,  --key-size,  --offset, --skip,
634              --hash, --readonly, --allow-discards, --refresh].
635
636       See also section 7 of the FAQ and  http://loop-aes.sourceforge.net  for
637       more information regarding loop-AES.
638

TCRYPT (TrueCrypt-compatible and VeraCrypt) EXTENSION

640       cryptsetup  supports  mapping  of  TrueCrypt, tcplay or VeraCrypt (with
641       --veracrypt option) encrypted partition using  a  native  Linux  kernel
642       API.   Header  formatting  and  TCRYPT  header change is not supported,
643       cryptsetup never changes TCRYPT header on-device.
644
645       TCRYPT extension requires kernel userspace crypto API to  be  available
646       (introduced  in  Linux  kernel  2.6.38).  If you are configuring kernel
647       yourself, enable "User-space interface for symmetric key  cipher  algo‐
648       rithms"  in "Cryptographic API" section (CRYPTO_USER_API_SKCIPHER .con‐
649       fig option).
650
651       Because TCRYPT header is encrypted, you have to  always  provide  valid
652       passphrase and keyfiles.
653
654       Cryptsetup  should  recognize all header variants, except legacy cipher
655       chains using LRW encryption mode with 64 bits encryption block  (namely
656       Blowfish  in  LRW  mode is not recognized, this is limitation of kernel
657       crypto API).
658
659       To recognize a VeraCrypt device use the --veracrypt option.   VeraCrypt
660       is just extension of TrueCrypt header with increased iteration count so
661       unlocking can take quite a lot  of  time  (in  comparison  with  TCRYPT
662       device).
663
664       To  open a VeraCrypt device with a custom Personal Iteration Multiplier
665       (PIM)  value,  additionally  to  --veracrypt   use  either  the  --ver‐
666       acrypt-pim=<PIM>  option  to  directly  specify the PIM on the command-
667       line or use --veracrypt-query-pim to be prompted for the PIM.
668
669       The PIM value affects the  number  of  iterations  applied  during  key
670       derivation.    Please    refer    to   https://www.veracrypt.fr/en/Per
671       sonal%20Iterations%20Multiplier%20%28PIM%29.html  for   more   detailed
672       information.
673
674       NOTE:  Activation  with  tcryptOpen is supported only for cipher chains
675       using LRW or XTS encryption modes.
676
677       The tcryptDump command should work for all  recognized  TCRYPT  devices
678       and doesn't require superuser privilege.
679
680       To map system device (device with boot loader where the whole encrypted
681       system resides) use --tcrypt-system  option.   You  can  use  partition
682       device  as  the parameter (parameter must be real partition device, not
683       an image in a file), then only this partition is mapped.
684
685       If you have the whole TCRYPT device as a file image and you want to map
686       multiple  partition  encrypted  with  system  encryption, please create
687       loopback mapping with partitions first (losetup -P, see losetup(8)  man
688       page for more info), and use loop partition as the device parameter.
689
690       If  you  use  the  whole base device as a parameter, one device for the
691       whole system encryption is mapped. This  mode  is  available  only  for
692       backward  compatibility  with  older  cryptsetup  versions which mapped
693       TCRYPT system encryption using the whole device.
694
695       To use hidden  header  (and  map  hidden  device,  if  available),  use
696       --tcrypt-hidden option.
697
698       To  explicitly  use  backup  (secondary)  header,  use  --tcrypt-backup
699       option.
700
701       NOTE: There is no protection for a hidden volume if the outer volume is
702       mounted.  The  reason  is  that  if there were any protection, it would
703       require some metadata describing what to protect in  the  outer  volume
704       and the hidden volume would become detectable.
705
706
707       open --type tcrypt <device> <name>
708       tcryptOpen <device> <name>  (old syntax)
709
710              Opens the TCRYPT (a TrueCrypt-compatible) <device> and sets up a
711              mapping <name>.
712
713              <options> can be [--key-file, --tcrypt-hidden,  --tcrypt-system,
714              --tcrypt-backup,   --readonly,  --test-passphrase,  --allow-dis‐
715              cards, --veracrypt, --veracrypt-pim, --veracrypt-query-pim].
716
717              The keyfile parameter allows a combination of file content  with
718              the  passphrase and can be repeated. Note that using keyfiles is
719              compatible with TCRYPT and is different from LUKS keyfile logic.
720
721              WARNING: Option --allow-discards cannot be combined with  option
722              --tcrypt-hidden.  For  normal mapping, it can cause the destruc‐
723              tion of hidden volume (hidden volume appears as unused space for
724              outer volume so this space can be discarded).
725
726
727       tcryptDump <device>
728
729              Dump the header information of a TCRYPT device.
730
731              If  the --dump-master-key option is used, the TCRYPT device mas‐
732              ter key is dumped instead of TCRYPT header info. Beware that the
733              master key (or concatenated master keys if cipher chain is used)
734              can be used to decrypt the data stored in the  TCRYPT  container
735              without a passphrase.  This means that if the master key is com‐
736              promised, the whole device has to be erased to  prevent  further
737              access. Use this option carefully.
738
739              <options>  can  be [--dump-master-key, --key-file, --tcrypt-hid‐
740              den, --tcrypt-system, --tcrypt-backup].
741
742              The keyfile parameter allows a combination of file content  with
743              the passphrase and can be repeated.
744
745       See  also  https://en.wikipedia.org/wiki/TrueCrypt for more information
746       regarding TrueCrypt.
747
748       Please note that cryptsetup does not use TrueCrypt code, please  report
749       all  problems related to this compatibility extension to the cryptsetup
750       project.
751
752

BITLK (Windows BitLocker-compatible) EXTENSION

754       cryptsetup supports mapping of BitLocker and BitLocker to Go  encrypted
755       partition using a native Linux kernel API.  Header formatting and BITLK
756       header changes are not supported, cryptsetup never changes BITLK header
757       on-device.
758
759       BITLK  extension  requires  kernel userspace crypto API to be available
760       (for details see TCRYPT section).
761
762       Cryptsetup should recognize all BITLK header  variants,  except  legacy
763       header  used in Windows Vista systems and partially decrypted BitLocker
764       devices.  Activation of legacy devices encrypted in CBC  mode  requires
765       at  least  Linux kernel version 5.3 and for devices using Elephant dif‐
766       fuser kernel 5.6.
767
768       The bitlkDump command should work for all recognized BITLK devices  and
769       doesn't require superuser privilege.
770
771       For unlocking with the open a password or a recovery passphrase must be
772       provided. Other unlocking methods (TPM, SmartCard) are not supported.
773
774
775       open --type bitlk <device> <name>
776       bitlkOpen <device> <name>  (old syntax)
777
778              Opens the BITLK (a BitLocker-compatible) <device> and sets up  a
779              mapping <name>.
780
781              <options>  can  be  [--key-file,  --readonly, --test-passphrase,
782              --allow-discards].
783
784
785       bitlkDump <device>
786
787              Dump the header information of a BITLK device.
788
789              Please note that cryptsetup does not use any  Windows  BitLocker
790              code,  please  report all problems related to this compatibility
791              extension to the cryptsetup project.
792

MISCELLANEOUS

794       repair <device>
795
796              Tries to repair the device metadata if possible. Currently  sup‐
797              ported only for LUKS device type.
798
799              This  command  is  useful to fix some known benign LUKS metadata
800              header corruptions. Only basic corruptions of unused keyslot are
801              fixable.  This command will only change the LUKS header, not any
802              key-slot data. You may enforce LUKS  version  by  adding  --type
803              option.
804
805              WARNING:  Always  create  a binary backup of the original header
806              before calling this command.
807
808       benchmark <options>
809
810              Benchmarks ciphers and KDF (key derivation  function).   Without
811              parameters, it tries to measure few common configurations.
812
813              To  benchmark  other  ciphers  or  modes,  you  need  to specify
814              --cipher and --key-size options or --hash for KDF test.
815
816              NOTE: This benchmark is using memory only and is  only  informa‐
817              tive.  You cannot directly predict real storage encryption speed
818              from it.
819
820              For  testing  block  ciphers,  this  benchmark  requires  kernel
821              userspace crypto API to be available (introduced in Linux kernel
822              2.6.38).  If you are configuring kernel yourself, enable  "User-
823              space interface for symmetric key cipher algorithms" in "Crypto‐
824              graphic API" section (CRYPTO_USER_API_SKCIPHER .config option).
825
826              <options> can be [--cipher, --key-size, --hash].
827

OPTIONS

829       --verbose, -v
830              Print more information on command execution.
831
832       --debug or --debug-json
833              Run in debug mode with full diagnostic logs. Debug output  lines
834              are always prefixed by '#'.  If --debug-json is used, additional
835              LUKS2 JSON data structures are printed.
836
837       --type <device-type>
838              Specifies required device type, for more info  read  BASIC  COM‐
839              MANDS section.
840
841       --hash, -h <hash-spec>
842              Specifies  the  passphrase  hash for open (for plain and loopaes
843              device types).
844
845              Specifies the hash used in the LUKS key setup scheme and  volume
846              key  digest  for luksFormat. The specified hash is used as hash-
847              parameter for PBKDF2 and for the AF splitter.
848
849              The specified hash name is  passed  to  the  compiled-in  crypto
850              backend.   Different backends may support different hashes.  For
851              luksFormat, the hash algorithm must provide at least 160 bits of
852              output,  which excludes, e.g., MD5. Do not use a non-crypto hash
853              like "crc32" as this breaks security.
854
855              Values compatible with old version of cryptsetup are "ripemd160"
856              for open --type plain and "sha1" for luksFormat.
857
858              Use cryptsetup --help to show the defaults.
859
860       --cipher, -c <cipher-spec>
861              Set the cipher specification string.
862
863              cryptsetup  --help  shows the compiled-in defaults.  The current
864              default in the distributed sources is "aes-cbc-essiv:sha256" for
865              plain dm-crypt and "aes-xts-plain64" for LUKS.
866
867              If  a  hash is part of the cipher specification, then it is used
868              as part of the IV generation. For example, ESSIV  needs  a  hash
869              function, while "plain64" does not and hence none is specified.
870
871              For  XTS mode you can optionally set a key size of 512 bits with
872              the -s option. Key size for XTS mode is  twice  that  for  other
873              modes for the same security level.
874
875              XTS  mode  requires  kernel 2.6.24 or later and plain64 requires
876              kernel 2.6.33 or later. More information can  be  found  in  the
877              FAQ.
878
879       --verify-passphrase, -y
880              When interactively asking for a passphrase, ask for it twice and
881              complain if both inputs do not match. Advised  when  creating  a
882              regular  mapping for the first time, or when running luksFormat.
883              Ignored on input from file or stdin.
884
885       --key-file, -d name
886              Read the passphrase from file.
887
888              If the name given is "-", then the passphrase will be read  from
889              stdin.   In  this case, reading will not stop at newline charac‐
890              ters.
891
892              With LUKS, passphrases supplied via --key-file  are  always  the
893              existing  passphrases requested by a command, except in the case
894              of luksFormat where --key-file is equivalent to  the  positional
895              key file argument.
896
897              If  you  want  to set a new passphrase via key file, you have to
898              use a positional argument to luksAddKey.
899
900              See section NOTES ON PASSPHRASE PROCESSING for more information.
901
902       --keyfile-offset value
903              Skip value bytes at the beginning of the key file.   Works  with
904              all commands that accept key files.
905
906       --keyfile-size, -l value
907              Read a maximum of value bytes from the key file.  The default is
908              to read the whole file up to the compiled-in maximum that can be
909              queried  with  --help.  Supplying more data than the compiled-in
910              maximum aborts the operation.
911
912              This option is useful to cut trailing newlines, for example.  If
913              --keyfile-offset  is also given, the size count starts after the
914              offset.  Works with all commands that accept key files.
915
916       --new-keyfile-offset value
917              Skip value bytes at the start when adding a new passphrase  from
918              key file with luksAddKey.
919
920       --new-keyfile-size  value
921              Read  a maximum of value bytes when adding a new passphrase from
922              key file with luksAddKey.  The default is to read the whole file
923              up  to  the  compiled-in maximum length that can be queried with
924              --help.  Supplying more than the compiled in maximum aborts  the
925              operation.   When  --new-keyfile-offset  is  also given, reading
926              starts after the offset.
927
928       --master-key-file
929              Use a master key stored in a file.
930
931              For luksFormat this allows creating a LUKS header with this spe‐
932              cific  master  key. If the master key was taken from an existing
933              LUKS header and all other parameters are the same, then the  new
934              header  decrypts  the  data encrypted with the header the master
935              key was taken from.
936
937              Action luksDump together with --dump-master-key option: The vol‐
938              ume  (master)  key  is stored in a file instead of being printed
939              out to standard output.
940
941              WARNING: If you create your own master key,  you  need  to  make
942              sure  to  do  it  right.  Otherwise,  you can end up with a low-
943              entropy or otherwise partially predictable master key which will
944              compromise security.
945
946              For  luksAddKey this allows adding a new passphrase without hav‐
947              ing to know an existing one.
948
949              For open this allows one to open the LUKS device without  giving
950              a passphrase.
951
952       --dump-master-key
953              For  luksDump  this  option  includes the master key in the dis‐
954              played information. Use with care, as the master key can be used
955              to bypass the passphrases, see also option --master-key-file.
956
957       --json-file
958              Read  token  json  from  a  file or write token to it. See token
959              action for more information. --json-file=- reads json from stan‐
960              dard input or writes it to standard output respectively.
961
962       --use-random
963
964       --use-urandom
965              For  luksFormat  these options define which kernel random number
966              generator will be used to create the  master  key  (which  is  a
967              long-term key).
968
969              See  NOTES ON RANDOM NUMBER GENERATORS for more information. Use
970              cryptsetup --help to show the compiled-in default random  number
971              generator.
972
973              WARNING:  In  a  low-entropy situation (e.g. in an embedded sys‐
974              tem), both selections are problematic.  Using  /dev/urandom  can
975              lead  to  weak  keys.   Using /dev/random can block a long time,
976              potentially forever, if not enough entropy can be  harvested  by
977              the kernel.
978
979       --key-slot, -S <0-7>
980              For  LUKS  operations that add key material, this options allows
981              you to specify which key slot is selected for the new key.  This
982              option can be used for luksFormat, and luksAddKey.
983              In  addition,  for open, this option selects a specific key-slot
984              to compare the passphrase  against.   If  the  given  passphrase
985              would only match a different key-slot, the operation fails.
986
987       --key-size, -s <bits>
988              Sets  key  size in bits. The argument has to be a multiple of 8.
989              The possible key-sizes are limited by the cipher and mode used.
990
991              See /proc/crypto for more information.  Note  that  key-size  in
992              /proc/crypto is stated in bytes.
993
994              This  option  can  be  used for open --type plain or luksFormat.
995              All other LUKS actions will use the key-size  specified  in  the
996              LUKS  header.   Use  cryptsetup  --help  to show the compiled-in
997              defaults.
998
999       --size, -b <number of 512 byte sectors>
1000              Set the size of the device in sectors of 512 bytes.  This option
1001              is only relevant for the open and resize actions.
1002
1003       --offset, -o <number of 512 byte sectors>
1004              Start  offset  in  the backend device in 512-byte sectors.  This
1005              option is only relevant  for  the  open  action  with  plain  or
1006              loopaes device types or for LUKS devices in luksFormat.
1007
1008              For  LUKS, the --offset option sets the data offset (payload) of
1009              data device and must be be aligned to 4096-byte sectors (must be
1010              multiple   of   8).    This   option  cannot  be  combined  with
1011              --align-payload option.
1012
1013       --skip, -p <number of 512 byte sectors>
1014              Start offset used in IV calculation  in  512-byte  sectors  (how
1015              many  sectors  of  the encrypted data to skip at the beginning).
1016              This option is only relevant for the open action with  plain  or
1017              loopaes device types.
1018
1019              Hence,  if  --offset n, and --skip s, sector n (the first sector
1020              of the encrypted device) will get a sector number of s  for  the
1021              IV calculation.
1022
1023       --device-size size[units]
1024              Instead of real device size, use specified value.
1025
1026              With  reencrypt  action  it means that only specified area (from
1027              the start of the device to the specified  size)  will  be  reen‐
1028              crypted.
1029
1030              With resize action it sets new size of the device.
1031
1032              If no unit suffix is specified, the size is in bytes.
1033
1034              Unit  suffix  can  be  S  for  512  byte  sectors,  K/M/G/T  (or
1035              KiB,MiB,GiB,TiB) for units with 1024  base  or  KB/MB/GB/TB  for
1036              1000 base (SI scale).
1037
1038              WARNING:  This is destructive operation when used with reencrypt
1039              command.
1040
1041       --readonly, -r
1042              set up a read-only mapping.
1043
1044       --shared
1045              Creates an additional mapping for one common ciphertext  device.
1046              Arbitrary  mappings are supported.  This option is only relevant
1047              for the open --type  plain  action.  Use  --offset,  --size  and
1048              --skip to specify the mapped area.
1049
1050       --pbkdf <PBKDF spec>
1051              Set Password-Based Key Derivation Function (PBKDF) algorithm for
1052              LUKS keyslot.  The PBKDF can be: pbkdf2 (for PBKDF2 according to
1053              RFC2898),  argon2i  for  Argon2i  or  argon2id for Argon2id (see
1054              https://www.cryptolux.org/index.php/Argon2 for more info).
1055
1056              For LUKS1, only PBKDF2 is accepted (no need to use this option).
1057              The  default PBKDF2 for LUKS2 is set during compilation time and
1058              is available in cryptsetup --help output.
1059
1060              A PBKDF is used for increasing dictionary and brute-force attack
1061              cost  for  keyslot passwords. The parameters can be time, memory
1062              and parallel cost.
1063
1064              For PBKDF2, only time cost (number of iterations) applies.   For
1065              Argon2i/id,  there  is  also memory cost (memory required during
1066              the process of key derivation)  and  parallel  cost  (number  of
1067              threads that run in parallel during the key derivation.
1068
1069              Note  that  increasing  memory  cost also increases time, so the
1070              final parameter values are measured by a benchmark.  The  bench‐
1071              mark  tries  to  find iteration time (--iter-time) with required
1072              memory cost --pbkdf-memory. If it is not  possible,  the  memory
1073              cost  is  decreased as well.  The parallel cost --pbkdf-parallel
1074              is constant, is is checked against available CPU cores  (if  not
1075              available, it is decreased) and the maximum parallel cost is 4.
1076
1077              You  can  see  all PBKDF parameters for particular LUKS2 keyslot
1078              with luksDump command.
1079
1080              NOTE: If you do not want to use benchmark and  want  to  specify
1081              all   parameters  directly,  use  --pbkdf-force-iterations  with
1082              --pbkdf-memory and --pbkdf-parallel.   This  will  override  the
1083              values  without  benchmarking.  Note it can cause extremely long
1084              unlocking time. Use only is specified cases, for example, if you
1085              know that the formatted device will be used on some small embed‐
1086              ded system.  In this case, the LUKS PBKDF2 digest will be set to
1087              the minimum iteration count.
1088
1089       --iter-time, -i <number of milliseconds>
1090              The  number  of milliseconds to spend with PBKDF passphrase pro‐
1091              cessing.  This option is only relevant for LUKS operations  that
1092              set  or  change  passphrases,  such as luksFormat or luksAddKey.
1093              Specifying 0 as parameter selects the compiled-in default.
1094
1095       --pbkdf-memory <number>
1096              Set the memory cost for PBKDF (for Argon2i/id the number  repre‐
1097              sents  kilobytes).   Note that it is maximal value, PBKDF bench‐
1098              mark or available physical memory can decrease it.  This  option
1099              is not available for PBKDF2.
1100
1101       --pbkdf-parallel <number>
1102              Set  the  parallel  cost for PBKDF (number of threads, up to 4).
1103              Note that it is maximal value, it is decreased automatically  if
1104              CPU  online  count  is  lower.  This option is not available for
1105              PBKDF2.
1106
1107       --pbkdf-force-iterations <num>
1108              Avoid PBKDF benchmark and set time cost  (iterations)  directly.
1109              It  can  be used for LUKS/LUKS2 device only.  See --pbkdf option
1110              for more info.
1111
1112       --batch-mode, -q
1113              Suppresses all confirmation questions. Use with care!
1114
1115              If the -y option is not specified, this option also switches off
1116              the passphrase verification for luksFormat.
1117
1118       --progress-frequency <seconds>
1119              Print separate line every <seconds> with wipe progress.
1120
1121       --timeout, -t <number of seconds>
1122              The number of seconds to wait before timeout on passphrase input
1123              via terminal. It is relevant every time a passphrase  is  asked,
1124              for  example  for  open,  luksFormat  or  luksAddKey.  It has no
1125              effect if used in conjunction with --key-file.
1126              This option is useful when the system should not  stall  if  the
1127              user  does not input a passphrase, e.g. during boot. The default
1128              is a value of 0 seconds, which means to wait forever.
1129
1130       --tries, -T
1131              How often the input of the passphrase shall  be  retried.   This
1132              option is relevant every time a passphrase is asked, for example
1133              for open, luksFormat or luksAddKey.  The default is 3 tries.
1134
1135       --align-payload <number of 512 byte sectors>
1136              Align payload at a boundary of  value  512-byte  sectors.   This
1137              option is relevant for luksFormat.
1138
1139              If not specified, cryptsetup tries to use the topology info pro‐
1140              vided by the kernel for the underlying device to get the optimal
1141              alignment.   If not available (or the calculated value is a mul‐
1142              tiple of the default) data is  by  default  aligned  to  a  1MiB
1143              boundary (i.e. 2048 512-byte sectors).
1144
1145              For  a detached LUKS header, this option specifies the offset on
1146              the data device. See also the --header option.
1147
1148              WARNING: This option is  DEPRECATED  and  has  often  unexpected
1149              impact  to the data offset and keyslot area size (for LUKS2) due
1150              to the complex rounding.   For  fixed  data  device  offset  use
1151              --offset option instead.
1152
1153
1154       --uuid=UUID
1155              Use the provided UUID for the luksFormat command instead of gen‐
1156              erating a new one. Changes the existing UUID when used with  the
1157              luksUUID command.
1158
1159              The  UUID  must  be  provided  in the standard UUID format, e.g.
1160              12345678-1234-1234-1234-123456789abc.
1161
1162       --allow-discards
1163              Allow the use of discard (TRIM) requests for the  device.   This
1164              option  is only relevant for open action.  This is also not sup‐
1165              ported for LUKS2 devices with data integrity protection.
1166
1167              WARNING: This  command  can  have  a  negative  security  impact
1168              because  it  can make filesystem-level operations visible on the
1169              physical device. For  example,  information  leaking  filesystem
1170              type,  used  space,  etc.  may  be extractable from the physical
1171              device if the discarded blocks  can  be  located  later.  If  in
1172              doubt, do not use it.
1173
1174              A kernel version of 3.1 or later is needed. For earlier kernels,
1175              this option is ignored.
1176
1177       --perf-same_cpu_crypt
1178              Perform encryption using the same cpu that IO was submitted  on.
1179              The  default  is  to use an unbound workqueue so that encryption
1180              work is automatically balanced  between  available  CPUs.   This
1181              option is only relevant for open action.
1182
1183              NOTE:  This option is available only for low-level dm-crypt per‐
1184              formance tuning, use only if you need a change  to  default  dm-
1185              crypt behaviour. Needs kernel 4.0 or later.
1186
1187       --perf-submit_from_crypt_cpus
1188              Disable offloading writes to a separate thread after encryption.
1189              There are some situations where offloading write bios  from  the
1190              encryption  threads to a single thread degrades performance sig‐
1191              nificantly.  The default is to offload write bios  to  the  same
1192              thread.  This option is only relevant for open action.
1193
1194              NOTE:  This option is available only for low-level dm-crypt per‐
1195              formance tuning, use only if you need a change  to  default  dm-
1196              crypt behaviour. Needs kernel 4.0 or later.
1197
1198       --test-passphrase
1199              Do not activate the device, just verify passphrase.  This option
1200              is only relevant for open action (the device mapping name is not
1201              mandatory if this option is used).
1202
1203       --header <device or file storing the LUKS header>
1204              Use  a  detached  (separated)  metadata device or file where the
1205              LUKS header is stored. This option allows one to  store  cipher‐
1206              text and LUKS header on different devices.
1207
1208              This  option  is  only relevant for LUKS devices and can be used
1209              with the luksFormat, open, luksSuspend, luksResume,  status  and
1210              resize commands.
1211
1212              For luksFormat with a file name as the argument to --header, the
1213              file will be automatically created if it does  not  exist.   See
1214              the cryptsetup FAQ for header size calculation.
1215
1216              For  other  commands  that change the LUKS header (e.g. luksAdd‐
1217              Key), specify the device or file with the LUKS  header  directly
1218              as the LUKS device.
1219
1220              If  used with luksFormat, the --align-payload option is taken as
1221              absolute sector alignment on ciphertext device and can be zero.
1222
1223              WARNING: There is no check whether the ciphertext device  speci‐
1224              fied  actually  belongs  to  the  header given. In fact, you can
1225              specify an arbitrary device as the ciphertext  device  for  open
1226              with the --header option. Use with care.
1227
1228       --header-backup-file <file>
1229              Specify  file  with  header  backup for luksHeaderBackup or luk‐
1230              sHeaderRestore actions.
1231
1232       --force-password
1233              Do not use password quality checking for new LUKS passwords.
1234
1235              This  option  applies  only  to   luksFormat,   luksAddKey   and
1236              luksChangeKey  and  is  ignored  if  cryptsetup is built without
1237              password quality checking support.
1238
1239              For more info about password quality check, see the manual  page
1240              for pwquality.conf(5) and passwdqc.conf(5).
1241
1242       --deferred
1243              Defers  device  removal  in  close  command  until the last user
1244              closes it.
1245
1246       --disable-locks
1247              Disable lock protection for metadata on disk.   This  option  is
1248              valid only for LUKS2 and ignored for other formats.
1249
1250              WARNING:  Do  not use this option unless you run cryptsetup in a
1251              restricted environment where locking is  impossible  to  perform
1252              (where /run directory cannot be used).
1253
1254       --disable-keyring
1255              Do  not  load volume key in kernel keyring and store it directly
1256              in the dm-crypt target instead.  This option is  supported  only
1257              for the LUKS2 format.
1258
1259       --key-description <text>
1260              Set key description in keyring for use with token command.
1261
1262       --priority <normal|prefer|ignore>
1263              Set  a  priority  for LUKS2 keyslot.  The prefer priority marked
1264              slots are tried before normal priority.   The  ignored  priority
1265              means,  that  slot is never used, if not explicitly requested by
1266              --key-slot option.
1267
1268       --token-id
1269              Specify what token to use in actions token, open or resize.   If
1270              omitted,  all available tokens will be checked before proceeding
1271              further with passphrase prompt.
1272
1273       --token-only
1274              Do not proceed further  with  action  (any  of  token,  open  or
1275              resize)  if  token activation failed. Without the option, action
1276              asks for passphrase to proceed further.
1277
1278       --sector-size <bytes>
1279              Set sector size for use with disk encryption. It must  be  power
1280              of  two  and in range 512 - 4096 bytes. The default is 512 bytes
1281              sectors.  This option is available only in the LUKS2 mode.
1282
1283              Note that if sector size is higher than underlying device  hard‐
1284              ware sector and there is not integrity protection that uses data
1285              journal, using this option can increase risk on incomplete  sec‐
1286              tor writes during a power fail.
1287
1288              If  used together with --integrity option and dm-integrity jour‐
1289              nal, the atomicity of writes is guaranteed in all cases (but  it
1290              cost write performance - data has to be written twice).
1291
1292              Increasing  sector size from 512 bytes to 4096 bytes can provide
1293              better performance on most of the  modern  storage  devices  and
1294              also with some hw encryption accelerators.
1295
1296       --persistent
1297              If  used  with  LUKS2 devices and activation commands like open,
1298              the specified activation flags  are  persistently  written  into
1299              metadata  and used next time automatically even for normal acti‐
1300              vation.  (No need to use cryptab or other  system  configuration
1301              files.)      Only    --allow-discards,    --perf-same_cpu_crypt,
1302              --perf-submit_from_crypt_cpus and --integrity-no-journal can  be
1303              stored persistently.
1304
1305       --refresh
1306              Refreshes  an  active  device  with  new  set of parameters. See
1307              action refresh description for more details.
1308
1309       --label <LABEL>
1310              --subsystem <SUBSYSTEM> Set label and subsystem description  for
1311              LUKS2  device,  can  be  used in config and format actions.  The
1312              label and subsystem are optional fields and can be later used in
1313              udev  scripts  for triggering user actions once device marked by
1314              these labels is detected.
1315
1316       --integrity <integrity algorithm>
1317              Specify integrity algorithm to be used  for  authenticated  disk
1318              encryption in LUKS2.
1319
1320              WARNING:   This  extension  is  EXPERIMENTAL  and  requires  dm-
1321              integrity kernel target (available since kernel  version  4.12).
1322              For  native  AEAD  modes,  also enable "User-space interface for
1323              AEAD cipher algorithms" in  "Cryptographic  API"  section  (CON‐
1324              FIG_CRYPTO_USER_API_AEAD .config option).
1325
1326              For more info, see AUTHENTICATED DISK ENCRYPTION section.
1327
1328       --luks2-metadata-size <size>
1329              This  option  can  be  used to enlarge the LUKS2 metadata (JSON)
1330              area.  The size includes 4096 bytes for binary metadata  (usable
1331              JSON  area  is  smaller of the binary area).  According to LUKS2
1332              specification, only these values are valid:  16,  32,  64,  128,
1333              256,  512,  1024,  2048  and 4096 kB The <size> can be specified
1334              with unit suffix (for example 128k).
1335
1336       --luks2-keyslots-size <size>
1337              This option can be used to set specific size of the LUKS2 binary
1338              keyslot  area  (key material is encrypted there). The value must
1339              be aligned to multiple of 4096 bytes with  maximum  size  128MB.
1340              The <size> can be specified with unit suffix (for example 128k).
1341
1342       --keyslot-cipher <cipher-spec>
1343              This  option  can  be used to set specific cipher encryption for
1344              the LUKS2 keyslot area.
1345
1346       --keyslot-key-size <bits>
1347              This option can be used to set specific key size for  the  LUKS2
1348              keyslot area.
1349
1350       --integrity-no-journal
1351              Activate  device  with  integrity  protection without using data
1352              journal (direct write of data and integrity  tags).   Note  that
1353              without  journal  power fail can cause non-atomic write and data
1354              corruption.  Use only if journalling is performed on a different
1355              storage layer.
1356
1357       --integrity-no-wipe
1358              Skip  wiping  of  device authentication (integrity) tags. If you
1359              skip this step, sectors will report invalid integrity tag  until
1360              an application write to the sector.
1361
1362              NOTE:  Even  some  writes to the device can fail if the write is
1363              not aligned to page size and page-cache initiates read of a sec‐
1364              tor with invalid integrity tag.
1365
1366       --unbound
1367
1368              Creates  new  LUKS2  unbound  keyslot. See luksAddKey action for
1369              more details.
1370
1371       --tcrypt-hidden
1372              --tcrypt-system --tcrypt-backup Specify which TrueCrypt  on-disk
1373              header  will be used to open the device.  See TCRYPT section for
1374              more info.
1375
1376       --veracrypt
1377              Allow VeraCrypt compatible mode. Only for TCRYPT extension.  See
1378              TCRYPT section for more info.
1379
1380       --veracrypt-pim
1381              --veracrypt-query-pim Use a custom Personal Iteration Multiplier
1382              (PIM) for VeraCrypt device.  See TCRYPT section for more info.
1383
1384       --serialize-memory-hard-pbkdf
1385              Use a global lock to serialize unlocking of keyslots using  mem‐
1386              ory-hard PBKDF.
1387
1388              NOTE:  This  is  (ugly) workaround for a specific situation when
1389              multiple devices are activated in parallel and system instead of
1390              reporting  out  of  memory starts unconditionally stop processes
1391              using out-of-memory killer.
1392
1393              DO NOT USE this switch until you are implementing boot  environ‐
1394              ment with parallel devices activation!
1395
1396       --encrypt
1397              Initialize (and run) device encryption (reencrypt action parame‐
1398              ter)
1399
1400       --decrypt
1401              Initialize (and run) device decryption (reencrypt action parame‐
1402              ter)
1403
1404       --init-only
1405              Initialize  reencryption  (any variant) operation in LUKS2 meta‐
1406              data only and exit. If any reencrypt operation is  already  ini‐
1407              tialized  in  metadata,  the  command with --init-only parameter
1408              fails.
1409
1410       --resume-only
1411              Resume reencryption (any variant) operation already described in
1412              LUKS2  metadata.  If  no reencrypt operation is initialized, the
1413              command with --resume-only parameter fails. Useful for  resuming
1414              reencrypt  operation  without  accidentally triggering new reen‐
1415              cryption operation.
1416
1417       --resilience <mode>
1418              Reencryption resilience mode can be one of checksum, journal  or
1419              none.
1420
1421              checksum: default mode, where individual checksums of ciphertext
1422              hotzone sectors are stored, so the recovery process  can  detect
1423              which  sectors  where  already reencrypted. It requires that the
1424              device sector write is atomic.
1425
1426              journal: the hotzone is journaled in the  binary  area  (so  the
1427              data are written twice).
1428
1429              none:  performance mode. There is no protection and the only way
1430              it's safe to interrupt the reencryption is similar to  old  off‐
1431              line reencryption utility. (ctrl+c).
1432
1433              The  option is ignored if reencryption with datashift mode is in
1434              progress.
1435
1436       --resilience-hash <hash>
1437              The hash algorithm used with "--resilience checksum"  only.  The
1438              default  hash  is  sha256. With other resilience modes, the hash
1439              parameter is ignored.
1440
1441       --hotzone-size <size>
1442              This option can be used to set an upper limit  on  the  size  of
1443              reencryption  area  (hotzone).  The <size> can be specified with
1444              unit suffix (for example 50M). Note that actual hotzone size may
1445              be  less  than  specified  <size> due to other limitations (free
1446              space in keyslots area or available memory).
1447
1448       --reduce-device-size <size>
1449              Initialize LUKS2 reencryption with data  device  size  reduction
1450              (currently only --encrypt variant is supported).
1451
1452              Last  <size>  sectors  of <device> will be used to properly ini‐
1453              tialize device reencryption. That means any data at last  <size>
1454              sectors will be lost.
1455
1456              It  could be useful if you added some space to underlying parti‐
1457              tion or logical volume  (so  last  <size>  sectors  contains  no
1458              data).
1459
1460              Recommended  minimal size is twice the default LUKS2 header size
1461              (--reduce-device-size 32M) for --encrypt use case.  Be  sure  to
1462              have  enough  (at least --reduce-device-size value of free space
1463              at the end of <device>).
1464
1465              WARNING: This is a destructive operation and cannot be reverted.
1466              Use with extreme care - accidentally overwritten filesystems are
1467              usually unrecoverable.
1468
1469       --version
1470              Show the program version.
1471
1472       --usage
1473              Show short option help.
1474
1475       --help, -?
1476              Show help text and default parameters.
1477

RETURN CODES

1479       Cryptsetup returns 0 on success and a non-zero value on error.
1480
1481       Error codes are: 1 wrong parameters, 2 no permission (bad  passphrase),
1482       3  out  of memory, 4 wrong device specified, 5 device already exists or
1483       device is busy.
1484

NOTES ON PASSPHRASE PROCESSING FOR PLAIN MODE

1486       Note that no iterated hashing or salting is done  in  plain  mode.   If
1487       hashing  is  done,  it  is  a  single direct hash. This means that low-
1488       entropy passphrases are easy to attack in plain mode.
1489
1490       From a terminal: The passphrase is read until the first  newline,  i.e.
1491       '\n'.   The  input  without the newline character is processed with the
1492       default hash or the hash specified with --hash.  The hash  result  will
1493       be  truncated to the key size of the used cipher, or the size specified
1494       with -s.
1495
1496       From stdin: Reading will continue until a newline (or until the maximum
1497       input size is reached), with the trailing newline stripped. The maximum
1498       input size is defined by the same compiled-in default as for the  maxi‐
1499       mum key file size and can be overwritten using --keyfile-size option.
1500
1501       The  data  read will be hashed with the default hash or the hash speci‐
1502       fied with --hash.  The hash result will be truncated to the key size of
1503       the used cipher, or the size specified with -s.
1504
1505       Note  that  if  --key-file=-  is  used  for reading the key from stdin,
1506       trailing newlines are not stripped from the input.
1507
1508       If "plain" is used as argument to --hash, the input data  will  not  be
1509       hashed.  Instead, it will be zero padded (if shorter than the key size)
1510       or truncated (if longer than the key size) and  used  directly  as  the
1511       binary  key.  This  is useful for directly specifying a binary key.  No
1512       warning will be given if the amount of data read  from  stdin  is  less
1513       than the key size.
1514
1515       From  a  key  file:  It  will  be truncated to the key size of the used
1516       cipher or the size given by -s and directly used as a binary key.
1517
1518       WARNING: The --hash argument is being ignored.  The  --hash  option  is
1519       usable only for stdin input in plain mode.
1520
1521       If  the  key file is shorter than the key, cryptsetup will quit with an
1522       error.  The maximum input size  is  defined  by  the  same  compiled-in
1523       default  as  for the maximum key file size and can be overwritten using
1524       --keyfile-size option.
1525
1526
1527

NOTES ON PASSPHRASE PROCESSING FOR LUKS

1529       LUKS uses PBKDF2 to protect against dictionary attacks and to give some
1530       protection  to low-entropy passphrases (see RFC 2898 and the cryptsetup
1531       FAQ).
1532
1533       From a terminal: The passphrase is read until  the  first  newline  and
1534       then processed by PBKDF2 without the newline character.
1535
1536       From  stdin: LUKS will read passphrases from stdin up to the first new‐
1537       line character or the compiled-in maximum key file  length.  If  --key‐
1538       file-size is given, it is ignored.
1539
1540       From key file: The complete keyfile is read up to the compiled-in maxi‐
1541       mum size. Newline characters do not terminate  the  input.  The  --key‐
1542       file-size option can be used to limit what is read.
1543
1544       Passphrase  processing: Whenever a passphrase is added to a LUKS header
1545       (luksAddKey, luksFormat), the user may specify how much  the  time  the
1546       passphrase processing should consume. The time is used to determine the
1547       iteration count for PBKDF2 and higher times will offer  better  protec‐
1548       tion  for  low-entropy  passphrases,  but open will take longer to com‐
1549       plete. For passphrases that have  entropy  higher  than  the  used  key
1550       length, higher iteration times will not increase security.
1551
1552       The  default setting of one or two seconds is sufficient for most prac‐
1553       tical cases. The only exception is a low-entropy passphrase used  on  a
1554       device  with  a slow CPU, as this will result in a low iteration count.
1555       On a slow device, it may be advisable to increase  the  iteration  time
1556       using  the  --iter-time  option  in  order to obtain a higher iteration
1557       count. This does slow down all later luksOpen operations accordingly.
1558

INCOHERENT BEHAVIOR FOR INVALID PASSPHRASES/KEYS

1560       LUKS checks for a valid  passphrase  when  an  encrypted  partition  is
1561       unlocked.  The behavior of plain dm-crypt is different.  It will always
1562       decrypt with the passphrase given. If the given  passphrase  is  wrong,
1563       the  device  mapped  by  plain  dm-crypt will essentially still contain
1564       encrypted data and will be unreadable.
1565

NOTES ON SUPPORTED CIPHERS, MODES, HASHES AND KEY SIZES

1567       The available combinations of ciphers,  modes,  hashes  and  key  sizes
1568       depend  on  kernel  support.  See  /proc/crypto for a list of available
1569       options. You might need to load additional  kernel  crypto  modules  in
1570       order to get more options.
1571
1572       For  the  --hash  option,  if the crypto backend is libgcrypt, then all
1573       algorithms supported by the gcrypt library are  available.   For  other
1574       crypto backends, some algorithms may be missing.
1575

NOTES ON PASSPHRASES

1577       Mathematics  can't be bribed. Make sure you keep your passphrases safe.
1578       There are a few nice tricks for constructing a fallback, when  suddenly
1579       out of the blue, your brain refuses to cooperate.  These fallbacks need
1580       LUKS, as it's only possible with LUKS  to  have  multiple  passphrases.
1581       Still,  if  your  attacker  model  does  not  prevent  it, storing your
1582       passphrase in a sealed envelope somewhere may be a good idea as well.
1583

NOTES ON RANDOM NUMBER GENERATORS

1585       Random Number Generators (RNG) used in cryptsetup are always the kernel
1586       RNGs without any modifications or additions to data stream produced.
1587
1588       There  are  two  types  of  randomness  cryptsetup/LUKS needs. One type
1589       (which always uses /dev/urandom) is used for salts, the AF splitter and
1590       for wiping deleted keyslots.
1591
1592       The  second  type  is  used for the volume (master) key. You can switch
1593       between using /dev/random and /dev/urandom  here, see --use-random  and
1594       --use-urandom  options.  Using  /dev/random  on a system without enough
1595       entropy sources can cause  luksFormat  to  block  until  the  requested
1596       amount of random data is gathered. In a low-entropy situation (embedded
1597       system), this can take a very long time and potentially forever. At the
1598       same  time,  using /dev/urandom in a low-entropy situation will produce
1599       low-quality keys. This is a serious problem, but solving it is  out  of
1600       scope for a mere man-page.  See urandom(4) for more information.
1601

AUTHENTICATED DISK ENCRYPTION (EXPERIMENTAL)

1603       Since  Linux  kernel  version 4.12 dm-crypt supports authenticated disk
1604       encryption.
1605
1606       Normal disk encryption modes are length-preserving (plaintext sector is
1607       of the same size as a ciphertext sector) and can provide only confiden‐
1608       tiality protection, but not cryptographically sound data integrity pro‐
1609       tection.
1610
1611       Authenticated modes require additional space per-sector for authentica‐
1612       tion tag and use Authenticated Encryption with Additional  Data  (AEAD)
1613       algorithms.
1614
1615       If  you  configure  LUKS2  device with data integrity protection, there
1616       will be an underlying dm-integrity device,  which  provides  additional
1617       per-sector  metadata  space and also provide data journal protection to
1618       ensure atomicity of data and metadata update.  Because  there  must  be
1619       additional  space for metadata and journal, the available space for the
1620       device will be smaller than for length-preserving modes.
1621
1622       The dm-crypt device then resides on top of such a dm-integrity  device.
1623       All  activation  and  deactivation of this device stack is performed by
1624       cryptsetup, there is no difference in using luksOpen for integrity pro‐
1625       tected devices.  If you want to format LUKS2 device with data integrity
1626       protection, use --integrity option.
1627
1628       Since dm-integrity doesn't support discards (TRIM), dm-crypt device  on
1629       top  of  it inherits this, so integrity protection mode doesn't support
1630       discards either.
1631
1632       Some integrity modes requires two independent keys (key for  encryption
1633       and  for  authentication).  Both  these  keys  are  stored  in one LUKS
1634       keyslot.
1635
1636       WARNING: All support for authenticated modes is experimental and  there
1637       are  only  some modes available for now. Note that there are a very few
1638       authenticated encryption algorithms that are suitable for disk  encryp‐
1639       tion.
1640
1641

NOTES ON LOOPBACK DEVICE USE

1643       Cryptsetup  is  usually used directly on a block device (disk partition
1644       or LVM volume). However, if the device argument is a  file,  cryptsetup
1645       tries  to  allocate  a  loopback device and map it into this file. This
1646       mode requires Linux kernel 2.6.25 or more  recent  which  supports  the
1647       loop autoclear flag (loop device is cleared on the last close automati‐
1648       cally). Of course, you can always map a file to a loop-device manually.
1649       See the cryptsetup FAQ for an example.
1650
1651       When device mapping is active, you can see the loop backing file in the
1652       status command output. Also see losetup(8).
1653

LUKS2 header locking

1655       The LUKS2 on-disk metadata is updated in several steps and  to  achieve
1656       proper  atomic  update,  there is a locking mechanism.  For an image in
1657       file, code uses flock(2) system call.  For a block device, lock is per‐
1658       formed  over  a  special file stored in a locking directory (by default
1659       /run/lock/cryptsetup).  The locking directory should  be  created  with
1660       the  proper  security  context  by  the distribution during the boot-up
1661       phase.  Only LUKS2 uses locks, other formats do not use this mechanism.
1662

DEPRECATED ACTIONS

1664       The reload action is no longer supported.  Please use dmsetup(8) if you
1665       need to directly manipulate with the device mapping table.
1666
1667       The luksDelKey was replaced with luksKillSlot.
1668

REPORTING BUGS

1670       Report  bugs,  including  ones  in the documentation, on the cryptsetup
1671       mailing list at <dm-crypt@saout.de> or in the 'Issues' section on  LUKS
1672       website.   Please  attach  the  output  of  the failed command with the
1673       --debug option added.
1674

AUTHORS

1676       cryptsetup originally written by Jana Saout <jana@saout.de>
1677       The LUKS extensions and original man page were written by Clemens Fruh‐
1678       wirth <clemens@endorphin.org>.
1679       Man page extensions by Milan Broz <gmazyland@gmail.com>.
1680       Man page rewrite and extension by Arno Wagner <arno@wagner.name>.
1681
1683       Copyright © 2004 Jana Saout
1684       Copyright © 2004-2006 Clemens Fruhwirth
1685       Copyright © 2012-2014 Arno Wagner
1686       Copyright © 2009-2020 Red Hat, Inc.
1687       Copyright © 2009-2020 Milan Broz
1688
1689       This is free software; see the source for copying conditions.  There is
1690       NO warranty; not even for MERCHANTABILITY or FITNESS FOR  A  PARTICULAR
1691       PURPOSE.
1692

SEE ALSO

1694       The LUKS website at https://gitlab.com/cryptsetup/cryptsetup/
1695
1696       The cryptsetup FAQ, contained in the distribution package and online at
1697       https://gitlab.com/cryptsetup/cryptsetup/wikis/FrequentlyAskedQuestions
1698
1699       The cryptsetup mailing list and list archive, see FAQ entry 1.6.
1700
1701       The  LUKS  on-disk  format  specification  available  at   https://git
1702       lab.com/cryptsetup/cryptsetup/wikis/Specification
1703
1704
1705
1706cryptsetup                       January 2019                    CRYPTSETUP(8)
Impressum