1 .TH CRYPTSETUP "8" "December 2013" "cryptsetup" "Maintenance Commands"
3 cryptsetup - manage plain dm-crypt and LUKS encrypted volumes
5 .B cryptsetup <options> <action> <action args>
8 cryptsetup is used to conveniently setup dm-crypt managed
9 device-mapper mappings. These include plain dm-crypt volumes and
10 LUKS volumes. The difference is that LUKS uses a metadata header
11 and can hence offer more features than plain dm-crypt. On the other
12 hand, the header is visible and vulnerable to damage.
14 In addition, cryptsetup provides limited support for the use of
15 historic loopaes volumes and for TrueCrypt compatible volumes.
17 .SH PLAIN DM-CRYPT OR LUKS?
19 Unless you understand the cryptographic background well, use LUKS.
20 With plain dm-crypt there are a number of possible user errors
21 that massively decrease security. While LUKS cannot fix them
22 all, it can lessen the impact for many of them.
25 A lot of good information on the risks of using encrypted storage,
26 on handling problems and on security aspects can be found in the
27 \fICryptsetup FAQ\fR. Read it. Nonetheless, some risks deserve
30 \fBBackup:\fR Storage media die. Encryption has no influence on that.
31 Backup is mandatory for encrypted data as well, if the data has any
32 worth. See the Cryptsetup FAQ for advice on how to do backup of an
35 \fBCharacter encoding:\fR If you enter a
36 passphrase with special symbols, the passphrase can change
37 depending character encoding. Keyboard settings can also change,
38 which can make blind input hard or impossible. For
39 example, switching from some ASCII 8-bit variant to UTF-8
40 can lead to a different binary encoding and hence different
41 passphrase seen by cryptsetup, even if what you see on
42 the terminal is exactly the same. It is therefore highly
43 recommended to select passphrase characters only from 7-bit
44 ASCII, as the encoding for 7-bit ASCII stays the same for
45 all ASCII variants and UTF-8.
47 \fBLUKS header:\fR If the header of a LUKS volume gets damaged,
48 all data is permanently lost unless you have a header-backup.
49 If a key-slot is damaged, it can only be restored from a header-backup
50 or if another active key-slot with known passphrase is undamaged.
51 Damaging the LUKS header is something people manage to do with
52 surprising frequency. This risk is the result of a trade-off
53 between security and safety, as LUKS is designed for fast and
54 secure wiping by just overwriting header and key-slot area.
56 \fBPreviously used partitions:\fR If a partition was previously used,
57 it is a very good idea to wipe filesystem signatures, data, etc. before
58 creating a LUKS or plain dm-crypt container on it.
59 For a quick removal of filesystem signatures, use "wipefs". Take care
60 though that this may not remove everything. In particular md (RAID)
61 signatures at the end of a device may survive. It also does not
62 remove data. For a full wipe, overwrite the whole partition before
63 container creation. If you do not know how to to that, the
64 cryptsetup FAQ describes several options.
67 The following are valid actions for all supported device types.
69 \fIopen\fR <device> <name> \-\-type <device_type>
71 Opens (creates a mapping with) <name> backed by device <device>.
73 Device type can be \fIplain\fR, \fIluks\fR (default), \fIloopaes\fR
76 For backward compatibility there are \fBopen\fR command aliases:
78 \fBcreate\fR (argument-order <name> <device>): open \-\-type plain
80 \fBplainOpen\fR: open \-\-type plain
82 \fBluksOpen\fR: open \-\-type luks
84 \fBloopaesOpen\fR: open \-\-type loopaes
86 \fBtcryptOpen\fR: open \-\-type tcrypt
88 \fB<options>\fR are type specific and are described below
89 for individual device types. For \fBcreate\fR, the order of the <name>
90 and <device> options is inverted for historical reasons, all other
91 aliases use the standard \fB<device> <name>\fR order.
95 Removes the existing mapping <name> and wipes the key from kernel memory.
97 For backward compatibility there are \fBclose\fR command aliases:
98 \fBremove\fR, \fBplainClose\fR, \fBluksClose\fR, \fBloopaesClose\fR,
99 \fBtcryptClose\fR (all behaves exactly the same, device type is
100 determined automatically from active device).
104 Reports the status for the mapping <name>.
108 Resizes an active mapping <name>.
110 If \-\-size (in sectors) is not specified, the size of the
111 underlying block device is used. Note that this does not
112 change the raw device geometry, it just changes how many
113 sectors of the raw device are represented in the mapped device.
115 Plain dm-crypt encrypts the device sector-by-sector with a
116 single, non-salted hash of the passphrase. No checks
117 are performed, no metadata is used. There is no formatting operation.
118 When the raw device is mapped (opened), the usual device operations
119 can be used on the mapped device, including filesystem creation.
120 Mapped devices usually reside in /dev/mapper/<name>.
122 The following are valid plain device type actions:
124 \fIopen\fR \-\-type plain <device> <name>
126 \fIcreate\fR <name> <device> (\fBOBSOLETE syntax\fR)
128 Opens (creates a mapping with) <name> backed by device <device>.
130 \fB<options>\fR can be [\-\-hash, \-\-cipher, \-\-verify-passphrase,
131 \-\-key-file, \-\-keyfile-offset, \-\-key-size, \-\-offset, \-\-skip, \-\-size,
132 \-\-readonly, \-\-shared, \-\-allow-discards]
134 Example: 'cryptsetup open \-\-type plain /dev/sda10 e1' maps the raw
135 encrypted device /dev/sda10 to the mapped (decrypted) device
136 /dev/mapper/e1, which can then be mounted, fsck-ed or have a
137 filesystem created on it.
139 LUKS, the Linux Unified Key Setup, is a standard for disk encryption.
140 It adds a standardized header at the start of the device,
141 a key-slot area directly behind the header and the bulk
142 data area behind that. The whole set is called a 'LUKS container'.
143 The device that a LUKS container resides on is called a 'LUKS device'.
144 For most purposes both terms can be used interchangeably. But
145 note that when the LUKS header is at a nonzero offset
146 in a device, then the device is not a LUKS device anymore, but
147 has a LUKS container stored in it at an offset.
149 LUKS can manage multiple passphrases that can be individually revoked
150 or changed and that can be securely scrubbed from persistent
151 media due to the use of anti-forensic stripes. Passphrases
152 are protected against brute-force and dictionary
153 attacks by PBKDF2, which implements hash iteration and salting
156 Each passphrase, also called a
158 in this document, is associated with one of 8 key-slots.
159 Key operations that do not specify a slot affect the first slot
160 that matches the supplied passphrase or the first empty slot if
161 a new passphrase is added.
163 The \fB<device>\fR parameter can be also specified by a LUKS UUID in the
164 format UUID=<uuid>. Translation to real device name uses symlinks
165 in /dev/disk/by-uuid directory.
167 To specify a detached header, the \fB\-\-header\fR parameter can be used
168 in all LUKS commands and always takes precedence over positional \fB<device>\fR
171 The following are valid LUKS actions:
173 \fIluksFormat\fR <device> [<key file>]
175 Initializes a LUKS partition and sets the initial passphrase
177 either via prompting or via <key file>. Note that
178 if the second argument is present, then the passphrase
179 is taken from the file given there, without the need
180 to use the \-\-key-file option. Also note that for both forms
181 of reading the passphrase from file you can
182 give '-' as file name, which results in the passphrase being read
183 from stdin and the safety-question being skipped.
185 You can only call luksFormat on a LUKS device that is not mapped.
187 \fB<options>\fR can be [\-\-hash, \-\-cipher, \-\-verify\-passphrase,
188 \-\-key\-size, \-\-key\-slot,
189 \-\-key\-file (takes precedence over optional second argument),
190 \-\-keyfile\-offset, \-\-keyfile\-size, \-\-use\-random | \-\-use\-urandom,
191 \-\-uuid, \-\-master\-key\-file, \-\-iter\-time, \-\-header,
192 \-\-force\-password].
194 \fBWARNING:\fR Doing a luksFormat on an existing LUKS container will
195 make all data the old container permanently irretrievable, unless
196 you have a header backup.
198 \fIopen\fR \-\-type luks <device> <name>
200 \fIluksOpen\fR <device> <name> (\fBold syntax\fR)
202 Opens the LUKS device <device> and sets up a mapping <name> after
203 successful verification of the supplied passphrase.
204 If the passphrase is not supplied via \-\-key-file, the command
205 prompts for it interactively.
207 \fB<options>\fR can be [\-\-key\-file, \-\-keyfile\-offset,
208 \-\-keyfile\-size, \-\-readonly, \-\-test\-passphrase,
209 \-\-allow\-discards, \-\-header, \-\-key-slot, \-\-master\-key\-file].
211 \fIluksSuspend\fR <name>
213 Suspends an active device (all IO operations will blocked
214 and accesses to the device will wait indefinitely)
215 and wipes the encryption
216 key from kernel memory. Needs kernel 2.6.19 or later.
218 After this operation you have to use \fIluksResume\fR to reinstate
219 the encryption key and unblock the device or \fIclose\fR to remove
222 \fBWARNING:\fR never suspend the device on which the cryptsetup binary resides.
224 \fB<options>\fR can be [\-\-header].
226 \fIluksResume\fR <name>
228 Resumes a suspended device and reinstates the encryption key.
229 Prompts interactively for a passphrase if \-\-key-file is not given.
231 \fB<options>\fR can be [\-\-key\-file, \-\-keyfile\-size, \-\-header]
233 \fIluksAddKey\fR <device> [<key file with new key>]
235 adds a new passphrase. An existing passphrase must be supplied
236 interactively or via \-\-key-file.
237 The new passphrase to be added can be specified interactively
238 or read from the file given as positional argument.
240 \fB<options>\fR can be [\-\-key\-file, \-\-keyfile\-offset,
241 \-\-keyfile\-size, \-\-new\-keyfile\-offset,
242 \-\-new\-keyfile\-size, \-\-key\-slot, \-\-master\-key\-file,
243 \-\-iter\-time, \-\-force\-password, \-\-header].
245 \fIluksRemoveKey\fR <device> [<key file with passphrase to be removed>]
247 Removes the supplied passphrase from the LUKS device. The
248 passphrase to be removed can be specified interactively,
249 as positional argument or via \-\-key-file.
251 \fB<options>\fR can be [\-\-key\-file, \-\-keyfile\-offset,
252 \-\-keyfile\-size, \-\-header]
254 \fBWARNING:\fR If you read the passphrase from stdin
255 (without further argument or with '-' as argument
256 to \-\-key\-file), batch-mode (\-q) will be implicitely
257 switched on and no warning will be given when you remove the
258 last remaining passphrase from a LUKS container. Removing
259 the last passphrase makes the LUKS container permanently
262 \fIluksChangeKey\fR <device> [<new key file>]
264 Changes an existing passphrase. The passphrase
265 to be changed must be supplied interactively or via \-\-key\-file.
266 The new passphrase can be supplied interactively or in
267 a file given as positional argument.
269 If a key-slot is specified (via \-\-key-slot), the passphrase
270 for that key-slot must be given and the new passphrase
271 will overwrite the specified key-slot. If no key-slot
272 is specified and there is still a free key-slot, then
273 the new passphrase will be put into a free key-slot before the
274 key-slot containing the old passphrase is purged. If there is
275 no free key-slot, then the key-slot with the old passphrase is
276 overwritten directly.
278 \fBWARNING:\fR If a key-slot is overwritten, a media failure
279 during this operation can cause the overwrite to fail after
280 the old passphrase has been wiped and make the LUKS container
283 \fB<options>\fR can be [\-\-key\-file, \-\-keyfile\-offset,
284 \-\-keyfile\-size, \-\-new\-keyfile\-offset,
285 \-\-new\-keyfile\-size, \-\-key\-slot, \-\-force\-password, \-\-header].
287 \fIluksKillSlot\fR <device> <key slot number>
289 Wipe the key-slot number <key slot> from the LUKS device. A remaining
290 passphrase must be supplied, either interactively or via \-\-key-file.
291 This command can remove the last remaining key-slot, but requires
292 an interactive confirmation when doing so. Removing the last
293 passphrase makes a LUKS container permanently inaccessible.
295 \fB<options>\fR can be [\-\-key\-file, \-\-keyfile\-offset,
296 \-\-keyfile\-size, \-\-header].
298 \fBWARNING:\fR If you read the passphrase from stdin
299 (without further argument or with '-' as argument
300 to \-\-key-file), batch-mode (\-q) will be implicitely
301 switched on and no warning will be given when you remove the
302 last remaining passphrase from a LUKS container. Removing
303 the last passphrase makes the LUKS container permanently
308 \fIluksErase\fR <device>
310 Erase all keyslots and make the LUKS container permanently inaccessible.
311 You do not need to provide any password for this operation.
313 \fBWARNING:\fR This operation is irreversible.
315 \fIluksUUID\fR <device>
317 Print the UUID of a LUKS device.
319 Set new UUID if \fI\-\-uuid\fR option is specified.
321 \fIisLuks\fR <device>
323 Returns true, if <device> is a LUKS device, false otherwise.
324 Use option \-v to get human-readable feedback. 'Command successful.'
325 means the device is a LUKS device.
327 \fIluksDump\fR <device>
329 Dump the header information of a LUKS device.
331 If the \-\-dump\-master\-key option is used, the LUKS device master key is
332 dumped instead of the keyslot info. Beware that the master key cannot be
333 changed and can be used to decrypt the data stored in the LUKS container
334 without a passphrase and even without the LUKS header. This means
335 that if the master key is compromised, the whole device has to be
336 erased to prevent further access. Use this option carefully.
338 In order to dump the master key, a passphrase has to be supplied,
339 either interactively or via \-\-key\-file.
341 \fB<options>\fR can be [\-\-dump\-master\-key, \-\-key\-file,
342 \-\-keyfile\-offset, \-\-keyfile\-size, \-\-header].
344 \fBWARNING:\fR If \-\-dump\-master\-key is used with \-\-key\-file
345 and the argument to \-\-key\-file is '-', no validation question
346 will be asked and no warning given.
348 \fIluksHeaderBackup\fR <device> \-\-header\-backup\-file <file>
350 Stores a binary backup of the LUKS header and keyslot area.
352 Note: Using '-' as filename writes the header backup to a file named '-'.
354 \fBWARNING:\fR This backup file and a passphrase valid
355 at the time of backup allows decryption of the
356 LUKS data area, even if the passphrase was later changed or
357 removed from the LUKS device. Also note that with a header
358 backup you lose the ability to securely wipe the LUKS
359 device by just overwriting the header and key-slots. You
360 either need to securely erase all header backups in
361 addition or overwrite the encrypted data area as well.
362 The second option is less secure, as some sectors
363 can survive, e.g. due to defect management.
365 \fIluksHeaderRestore\fR <device> \-\-header\-backup\-file <file>
367 Restores a binary backup of the LUKS header and keyslot area
368 from the specified file.
370 Note: Using '-' as filename reads the header backup from a file named '-'.
372 \fBWARNING:\fR Header and keyslots will be replaced, only
373 the passphrases from the backup will work afterwards.
375 This command requires that the master key size and data offset
376 of the LUKS header already on the device and of the header backup
377 match. Alternatively, if there is no LUKS header on the device,
378 the backup will also be written to it.
379 .SH loop-AES EXTENSION
380 cryptsetup supports mapping loop-AES encrypted partition using
381 a compatibility mode.
383 \fIopen\fR \-\-type loopaes <device> <name> \-\-key\-file <keyfile>
385 \fIloopaesOpen\fR <device> <name> \-\-key\-file <keyfile> (\fBold syntax\fR)
387 Opens the loop-AES <device> and sets up a mapping <name>.
389 If the key file is encrypted with GnuPG, then you have to use
390 \-\-key\-file=\- and decrypt it before use, e.g. like this:
392 gpg \-\-decrypt <keyfile> | cryptsetup loopaesOpen \-\-key\-file=\-
395 \fBWARNING:\fR The loop-AES extension cannot use direct input of key file
396 on real terminal because the keys are separated by end-of-line and only part
397 of the multi-key file would be read.
399 If you need it in script, just use the pipe redirection:
401 echo $keyfile | cryptsetup loopaesOpen \-\-key\-file=\- <device> <name>
403 Use \fB\-\-keyfile\-size\fR to specify the proper key length if needed.
405 Use \fB\-\-offset\fR to specify device offset. Note that the units
406 need to be specified in number of 512 byte sectors.
408 Use \fB\-\-skip\fR to specify the IV offset. If the original device
409 used an offset and but did not use it in IV sector calculations,
410 you have to explicitly use \fB\-\-skip 0\fR in addition to the offset
413 Use \fB\-\-hash\fR to override the default hash function for
414 passphrase hashing (otherwise it is detected according to key
417 \fB<options>\fR can be [\-\-key\-file, \-\-key\-size, \-\-offset, \-\-skip,
418 \-\-hash, \-\-readonly, \-\-allow\-discards].
420 See also section 7 of the FAQ and \fBhttp://loop-aes.sourceforge.net\fR
421 for more information regarding loop-AES.
422 .SH TCRYPT (TrueCrypt-compatible and VeraCrypt) EXTENSION
423 cryptsetup supports mapping of TrueCrypt, tcplay or VeraCrypt
424 (with \fB\-\-veracrypt\fR option) encrypted partition
425 using a native Linux kernel API.
426 Header formatting and TCRYPT header change is not supported, cryptsetup
427 never changes TCRYPT header on-device.
429 TCRYPT extension requires kernel userspace
430 crypto API to be available (introduced in Linux kernel 2.6.38).
431 If you are configuring kernel yourself, enable
432 "User-space interface for symmetric key cipher algorithms" in
433 "Cryptographic API" section (CRYPTO_USER_API_SKCIPHER .config option).
435 Because TCRYPT header is encrypted, you have to always provide valid
436 passphrase and keyfiles.
438 Cryptsetup should recognize all header variants, except legacy cipher chains
439 using LRW encryption mode with 64 bits encryption block (namely Blowfish
440 in LRW mode is not recognized, this is limitation of kernel crypto API).
442 To recognize VeraCrypt device use \fB\-\-veracrypt\fR option.
443 VeraCrypt is just extension of TrueCrypt header with increased
444 iteration count so unlocking can take quite a lot of time (in comparison
447 \fBNOTE:\fR Activation with \fBtcryptOpen\fR is supported only for cipher chains
448 using LRW or XTS encryption modes.
450 The \fBtcryptDump\fR command should work for all recognized TCRYPT devices
451 and doesn't require superuser privilege.
453 To map system device (device with boot loader where the whole encrypted
454 system resides) use \fB\-\-tcrypt\-system\fR option.
455 You can use partition device as the parameter (parameter must be real partition
456 device, not image in file), then only this partition is mapped.
458 If you have whole TCRYPT device as a file image and you want to map multiple
459 partition encrypted with system encryption, please create loopback mapping
460 with partitions first (\fBlosetup \-P\fR, see \fPlosetup(8)\fR man page for more info),
461 and use loop partition as the device parameter.
463 If you use whole base device as parameter, one device for the whole system
464 encryption is mapped. This mode is available only for backward compatibility
465 with older cryptsetup versions which mapped TCRYPT system encryption
468 To use hidden header (and map hidden device, if available),
469 use \fB\-\-tcrypt\-hidden\fR option.
471 To explicitly use backup (secondary) header, use \fB\-\-tcrypt\-backup\fR
474 \fBNOTE:\fR There is no protection for a hidden volume if
475 the outer volume is mounted. The reason is that if there
476 were any protection, it would require some metadata describing
477 what to protect in the outer volume and the hidden volume would
481 \fIopen\fR \-\-type tcrypt <device> <name>
483 \fItcryptOpen\fR <device> <name> (\fBold syntax\fR)
485 Opens the TCRYPT (a TrueCrypt-compatible) <device> and sets up
488 \fB<options>\fR can be [\-\-key\-file, \-\-tcrypt\-hidden,
489 \-\-tcrypt\-system, \-\-tcrypt\-backup, \-\-readonly, \-\-test\-passphrase,
492 The keyfile parameter allows combination of file content with the
493 passphrase and can be repeated. Note that using keyfiles is compatible
494 with TCRYPT and is different from LUKS keyfile logic.
496 \fBWARNING:\fR Option \fB\-\-allow\-discards\fR cannot be combined with
497 option \fB\-\-tcrypt\-hidden\fR. For normal mapping it can cause
498 \fBdestruction of hidden volume\fR (hidden volume appears as unused space
499 for outer volume so this space can be discarded).
502 \fItcryptDump\fR <device>
504 Dump the header information of a TCRYPT device.
506 If the \-\-dump\-master\-key option is used, the TCRYPT device master key
507 is dumped instead of TCRYPT header info. Beware that the master key
508 (or concatenated master keys if cipher chain is used)
509 can be used to decrypt the data stored in the TCRYPT container without
511 This means that if the master key is compromised, the whole device has
512 to be erased to prevent further access. Use this option carefully.
514 \fB<options>\fR can be [\-\-dump\-master\-key, \-\-key\-file,
515 \-\-tcrypt\-hidden, \-\-tcrypt\-system, \-\-tcrypt\-backup].
517 The keyfile parameter allows combination of file content with the
518 passphrase and can be repeated.
520 See also \fBhttp://www.truecrypt.org\fR for more information regarding
523 Please note that cryptsetup does not use TrueCrypt code, please report
524 all problems related to this compatibility extension to cryptsetup project.
527 \fIrepair\fR <device>
529 Tries to repair the device metadata if possible. Currently supported only
530 for LUKS device type.
532 This command is useful to fix some known benign LUKS metadata
533 header corruptions. Only basic corruptions of unused keyslot
534 are fixable. This command will only change the LUKS header, not
537 \fBWARNING:\fR Always create a binary backup of the original
538 header before calling this command.
540 \fIbenchmark\fR <options>
542 Benchmarks ciphers and KDF (key derivation function).
543 Without parameters it tries to measure few common configurations.
545 To benchmark other ciphers or modes, you need to specify \fB\-\-cipher\fR
546 and \fB\-\-key\-size\fR options or \fB\-\-hash\fR for KDF test.
548 \fBNOTE:\fR This benchmark is using memory only and is only informative.
549 You cannot directly predict real storage encryption speed from it.
551 For testing block ciphers, this benchmark requires kernel userspace
552 crypto API to be available (introduced in Linux kernel 2.6.38).
553 If you are configuring kernel yourself, enable
554 "User-space interface for symmetric key cipher algorithms" in
555 "Cryptographic API" section (CRYPTO_USER_API_SKCIPHER .config option).
557 \fB<options>\fR can be [\-\-cipher, \-\-key\-size, \-\-hash].
560 .B "\-\-verbose, \-v"
561 Print more information on command execution.
564 Run in debug mode with full diagnostic logs. Debug output
565 lines are always prefixed by '#'.
567 .B "\-\-hash, \-h \fI<hash\-spec>\fR"
568 Specifies the passphrase hash for \fIopen\fR (for plain and
569 loopaes device types).
571 Specifies the hash used in the LUKS key setup scheme and volume key digest
572 for \fIluksFormat\fR. The specified hash is used as hash-parameter
573 for PBKDF2 and for the AF splitter.
575 The specified hash name is passed to the compiled-in crypto backend.
576 Different backends may support different hashes.
577 For \fIluksFormat\fR, the hash
578 algorithm must provide at least 160 bits of output, which
579 excludes, e.g., MD5. Do not use a non-crypto hash like
580 \fB"crc32"\fR as this breaks security.
582 Values compatible with old version of cryptsetup are
583 \fB"ripemd160"\fR for \fIopen \-\-type plain\fR and
584 \fB"sha1"\fR for \fIluksFormat\fR.
586 Use \fIcryptsetup \-\-help\fR to show the defaults.
588 .B "\-\-cipher, \-c \fI<cipher\-spec>\fR"
589 Set the cipher specification string.
591 \fIcryptsetup \-\-help\fR shows the compiled-in defaults.
592 The current default in the distributed sources is
593 "aes-cbc-essiv:sha256" for plain dm-crypt and
594 "aes-xts-plain64" for LUKS.
596 If a hash is part of the cipher spefification, then it is
597 used as part of the IV generation. For example, ESSIV
598 needs a hash function, while "plain64" does not and
599 hence none is specified.
601 For XTS mode you can optionally set a key size of
602 512 bits with the \-s option. Key size for XTS
603 mode is twice that for other modes for the same
606 XTS mode requires kernel 2.6.24 or later and plain64 requires
607 kernel 2.6.33 or later. More information can be found in the FAQ.
609 .B "\-\-verify-passphrase, \-y"
610 When interactively asking for a passphrase, ask for it twice
611 and complain if both inputs do not match. Advised when creating
612 a regular mapping for the first time, or when running
613 \fIluksFormat\fR. Ignored on input from file or stdin.
615 .B "\-\-key-file, \-d \fIname\fR"
616 Read the passphrase from file.
618 If the name given is "-", then the passphrase will be read from stdin.
619 In this case, reading will not stop at newline characters.
621 With LUKS, passphrases supplied via \-\-key\-file are always
622 the existing passphrases requested by a command, except in
623 the case of \fIluksFormat\fR where \-\-key\-file is equivalent
624 to the positional key file argument.
626 If you want to set a new passphrase via key file, you have to
627 use a positional argument to \fIluksAddKey\fR.
629 See section \fBNOTES ON PASSPHRASE PROCESSING\fR for more information.
631 .B "\-\-keyfile\-offset \fIvalue\fR"
632 Skip \fIvalue\fR bytes at the beginning of the key file.
633 Works with all commands that accepts key files.
635 .B "\-\-keyfile\-size, \-l \fIvalue\fR"
636 Read a maximum of \fIvalue\fR bytes from the key file.
637 Default is to read the whole file up to the compiled-in
638 maximum that can be queried with \-\-help. Supplying more
639 data than the compiled-in maximum aborts the operation.
641 This option is useful
642 to cut trailing newlines, for example. If \-\-keyfile\-offset
643 is also given, the size count starts after the offset.
644 Works with all commands that accepts key files.
646 .B "\-\-new\-keyfile\-offset \fIvalue\fR"
647 Skip \fIvalue\fR bytes at the start when
648 adding a new passphrase from key file with
651 .B "\-\-new\-keyfile\-size \fIvalue\fR"
652 Read a maximum of \fIvalue\fR bytes when adding
653 a new passphrase from key file with \fIluksAddKey\fR.
654 Default is to read the whole file up to the compiled-in
655 maximum length that can be queried with \-\-help.
656 Supplying more than the compiled in maximum aborts the
658 When \-\-new\-keyfile\-offset is also given, reading starts
661 .B "\-\-master\-key\-file"
662 Use a master key stored in a file.
664 For \fIluksFormat\fR this
665 allows creating a LUKS header with this specific
666 master key. If the master key was taken from an existing
667 LUKS header and all other parameters are the same,
668 then the new header decrypts the data encrypted with the
669 header the master key was taken from.
671 \fBWARNING:\fR If you create your own master key, you
672 need to make sure to do it right. Otherwise you can end
673 up with a low-entropy or otherwise partially predictable
674 master key which will compromise security.
676 For \fIluksAddKey\fR this allows adding a new passphrase
677 without having to know an exiting one.
679 For \fIopen\fR this allows one to open the LUKS device
680 without giving a passphrase.
682 .B "\-\-dump\-master\-key"
683 For \fIluksDump\fR this option includes the master key in the displayed
684 information. Use with care, as the master key can be used to
685 bypass the passphrases, see also option \-\-master\-key\-file.
689 .B "\-\-use\-urandom"
690 For \fIluksFormat\fR these options define which kernel random number
691 generator will be used to create the master key (which is a
694 See \fBNOTES ON RANDOM NUMBER GENERATORS\fR for more
695 information. Use \fIcryptsetup \-\-help\fR
696 to show the compiled-in default random number generator.
698 \fBWARNING:\fR In a low-entropy situation (e.g. in an
699 embedded system), both selections are problematic.
700 Using /dev/urandom can lead to weak keys.
701 Using /dev/random can block a long time, potentially
702 forever, if not enough entropy can be harvested by
705 .B "\-\-key\-slot, \-S <0\-7>"
706 For LUKS operations that add key material, this options allows you
707 to specify which key slot is selected for the new key.
708 This option can be used for \fIluksFormat\fR,
709 and \fIluksAddKey\fR.
711 In addition, for \fIopen\fR, this option selects a
712 specific key-slot to compare the passphrase against.
713 If the given passphrase would only match a different key-slot,
716 .B "\-\-key\-size, \-s <bits>"
717 Sets key size in bits. The argument has to be a multiple of
718 8. The possible key-sizes are limited by the cipher and
721 See /proc/crypto for more information. Note that key-size
722 in /proc/crypto is stated in bytes.
724 This option can be used for \fIopen \-\-type plain\fR or \fIluksFormat\fR.
725 All other LUKS actions will use the key-size specified in the LUKS header.
726 Use \fIcryptsetup \-\-help\fR to show the compiled-in defaults.
728 .B "\-\-size, \-b <number of 512 byte sectors>"
729 Force the size of the underlying device in sectors of 512 bytes.
730 This option is only relevant for the \fIopen\fR and \fIresize\fR
733 .B "\-\-offset, \-o <number of 512 byte sectors>"
734 Start offset in the backend device in 512-byte sectors.
735 This option is only relevant for the \fIopen\fR action with plain
736 or loopaes device types.
738 .B "\-\-skip, \-p <number of 512 byte sectors>"
739 Start offset used in IV calculation in 512-byte sectors
740 (how many sectors of the encrypted data to skip at the beginning).
741 This option is only relevant for the \fIopen\fR action with plain
742 or loopaes device types.
744 Hence, if \-\-offset \fIn\fR, and \-\-skip \fIs\fR, sector \fIn\fR
745 (the first sector of encrypted device) will get a sector number
746 of \fIs\fR for the IV calculation.
748 .B "\-\-readonly, \-r"
749 set up a read-only mapping.
752 Creates an additional mapping for one common
753 ciphertext device. Arbitrary mappings are supported.
754 This option is only relevant for the
755 \fIopen \-\-type plain\fR action. Use \-\-offset, \-\-size and \-\-skip to
756 specify the mapped area.
758 .B "\-\-iter\-time, \-i <number of milliseconds>"
759 The number of milliseconds to spend with PBKDF2 passphrase processing.
760 This option is only relevant for LUKS operations that set or change
761 passphrases, such as \fIluksFormat\fR or \fIluksAddKey\fR.
762 Specifying 0 as parameter selects the compiled-in default.
764 .B "\-\-batch\-mode, \-q"
765 Suppresses all confirmation questions. Use with care!
767 If the \-y option is not specified, this option also switches off
768 the passphrase verification for \fIluksFormat\fR.
770 .B "\-\-timeout, \-t <number of seconds>"
771 The number of seconds to wait before timeout on passphrase input
772 via terminal. It is relevant every time a passphrase is asked,
773 for example for \fIopen\fR, \fIluksFormat\fR or \fIluksAddKey\fR.
774 It has no effect if used in conjunction with \-\-key-file.
776 This option is useful when the system
777 should not stall if the user does not input a passphrase,
778 e.g. during boot. The default is a value of 0 seconds,
779 which means to wait forever.
782 How often the input of the passphrase shall be retried.
783 This option is relevant
784 every time a passphrase is asked, for example for
785 \fIopen\fR, \fIluksFormat\fR or \fIluksAddKey\fR.
786 The default is 3 tries.
788 .B "\-\-align\-payload <number of 512 byte sectors>"
789 Align payload at a boundary of \fIvalue\fR 512-byte sectors.
790 This option is relevant for \fIluksFormat\fR.
792 If not specified, cryptsetup tries to use the topology info
793 provided by kernel for the underlying device to get optimal alignment.
794 If not available (or the calculated value is a multiple of the default)
795 data is by default aligned to a 1MiB boundary (i.e. 2048 512-byte sectors).
797 For a detached LUKS header this option specifies the offset on the
798 data device. See also the \-\-header option.
800 .B "\-\-uuid=\fIUUID\fR"
801 Use the provided \fIUUID\fR for the \fIluksFormat\fR command
802 instead of generating new one. Changes the existing UUID when
803 used with the \fIluksUUID\fR command.
805 The UUID must be provided in the standard UUID format,
806 e.g. 12345678-1234-1234-1234-123456789abc.
808 .B "\-\-allow\-discards\fR"
809 Allow the use of discard (TRIM) requests for device.
810 This option is only relevant for \fIopen\fR action.
812 \fBWARNING:\fR This command can have a negative security impact
813 because it can make filesystem-level operations visible on
814 the physical device. For example, information leaking
815 filesystem type, used space, etc. may be extractable from
816 the physical device if the discarded blocks can be located
817 later. If in doubt, do not use it.
819 A kernel version of 3.1 or later is needed. For earlier kernels
820 this option is ignored.
822 .B "\-\-perf\-same_cpu_crypt\fR"
823 Perform encryption using the same cpu that IO was submitted on.
824 The default is to use an unbound workqueue so that encryption work
825 is automatically balanced between available CPUs.
826 This option is only relevant for \fIopen\fR action.
828 \fBNOTE:\fR This option is available only for low-level dm-crypt
829 performance tuning, use only if you need a change to default dm-crypt
830 behaviour. Needs kernel 4.0 or later.
832 .B "\-\-perf\-submit_from_crypt_cpus\fR"
833 Disable offloading writes to a separate thread after encryption.
834 There are some situations where offloading write bios from the
835 encryption threads to a single thread degrades performance
836 significantly. The default is to offload write bios to the same
838 This option is only relevant for \fIopen\fR action.
840 \fBNOTE:\fR This option is available only for low-level dm-crypt
841 performance tuning, use only if you need a change to default dm-crypt
842 behaviour. Needs kernel 4.0 or later.
844 .B "\-\-test\-passphrase\fR"
845 Do not activate device, just verify passphrase.
846 This option is only relevant for \fIopen\fR action (the device
847 mapping name is not mandatory if this option is used).
849 .B "\-\-header\fR <device or file storing the LUKS header>"
850 Use a detached (separated) metadata device or file where the
851 LUKS header is stored. This options allows one to store ciphertext
852 and LUKS header on different devices.
854 This option is only relevant for LUKS devices and can be
855 used with the \fIluksFormat\fR, \fIopen\fR, \fIluksSuspend\fR,
856 \fIluksResume\fR, \fIstatus\fR and \fIresize\fR commands.
858 For \fIluksFormat\fR with a file name as argument to \-\-header,
859 it has to exist and be large enough to contain the LUKS header.
860 See the cryptsetup FAQ for header size calculation.
862 For other commands that change the LUKS header (e.g. \fIluksAddKey\fR),
863 specify the device or file with the LUKS header directly as the
866 If used with \fIluksFormat\fR, the \-\-align\-payload option is taken
867 as absolute sector alignment on ciphertext device and can be zero.
869 \fBWARNING:\fR There is no check whether the ciphertext device specified
870 actually belongs to the header given. In fact you can specify an
871 arbitrary device as the ciphertext device for \fIopen\fR
872 with the \-\-header option. Use with care.
874 .B "\-\-force\-password\fR"
875 Do not use password quality checking for new LUKS passwords.
877 This option applies only to \fIluksFormat\fR, \fIluksAddKey\fR and
878 \fIluksChangeKey\fR and is ignored if cryptsetup is built without
879 password quality checking support.
881 For more info about password quality check, see manual page
882 for \fBpwquality.conf(5)\fR.
885 Show the program version.
888 Show short option help.
891 Show help text and default parameters.
893 Cryptsetup returns 0 on success and a non-zero value on error.
895 Error codes are: 1 wrong parameters, 2 no permission (bad passphrase),
896 3 out of memory, 4 wrong device specified, 5 device already exists
898 .SH NOTES ON PASSPHRASE PROCESSING FOR PLAIN MODE
899 Note that no iterated hashing or salting is done in plain mode.
900 If hashing is done, it is a single direct hash. This means that
901 low-entropy passphrases are easy to attack in plain mode.
903 \fBFrom a terminal\fR: The passphrase is read until the
904 first newline, i.e. '\\n'.
905 The input without the newline character is processed with
906 the default hash or the hash specified with \-\-hash.
907 The hash result will be truncated to the key size
908 of the used cipher, or the size specified with \-s.
910 \fBFrom stdin\fR: Reading will continue until a newline (or until
911 the maximum input size is reached), with the trailing newline
912 stripped. The maximum input size is defined by the same
913 compiled-in default as for the maximum key file size and can
914 be overwritten using \-\-keyfile-size option.
916 The data read will be hashed with the default hash
917 or the hash specified with \-\-hash.
918 The hash result will be truncated to the key size
919 of the used cipher, or the size specified with \-s.
921 Note that if \-\-key-file=- is used for reading the key
922 from stdin, trailing newlines are not stripped from the input.
924 If "plain" is used as argument to \-\-hash, the input
925 data will not be hashed. Instead, it will be zero padded (if
926 shorter than the key size) or truncated (if longer than the
927 key size) and used directly as the binary key. This is useful for
928 directly specifying a binary key.
929 No warning will be given if the amount of data read from stdin is
930 less than the key size.
932 \fBFrom a key file\fR: It will be truncated to the
933 key size of the used cipher or the size given by \-s
934 and directly used as binary key.
936 \fBWARNING\fR: The \-\-hash argument is being ignored.
937 The \-\-hash option is usable only for stdin input in plain mode.
939 If the key file is shorter than the key, cryptsetup
940 will quit with an error.
941 The maximum input size is defined by the same
942 compiled-in default as for the maximum key file size and can
943 be overwritten using \-\-keyfile-size option.
946 .SH NOTES ON PASSPHRASE PROCESSING FOR LUKS
947 LUKS uses PBKDF2 to protect against dictionary attacks
948 and to give some protection to low-entropy passphrases
949 (see RFC 2898 and the cryptsetup FAQ).
951 \fBFrom a terminal\fR: The passphrase is read until the
952 first newline and then processed by PBKDF2 without
953 the newline character.
956 LUKS will read passphrases from stdin up to the
957 first newline character or the compiled-in
958 maximum key file length. If \-\-keyfile\-size is
959 given, it is ignored.
962 The complete keyfile is read up to the compiled-in
963 maximum size. Newline characters do not terminate the
964 input. The \-\-keyfile\-size option can be used to limit
967 \fBPassphrase processing\fR:
968 Whenever a passphrase is added to a LUKS header (luksAddKey, luksFormat),
969 the user may specify how much the time the passphrase processing
970 should consume. The time is used to determine the iteration count
971 for PBKDF2 and higher times will offer better protection for
972 low-entropy passphrases, but open will take longer to
973 complete. For passphrases that have entropy higher than the
974 used key length, higher iteration times will not increase security.
976 The default setting of one second is sufficient for most
977 practical cases. The only exception is a low-entropy
978 passphrase used on a device with a slow CPU, as this will
979 result in a low iteration count. On a slow device it may
980 be advisable to increase the iteration time using the
981 \-\-iter\-time option in order to obtain a higher
982 iteration count. This does slow down all later luksOpen
983 operations accordingly.
984 .SH INCOHERENT BEHAVIOR FOR INVALID PASSPHRASES/KEYS
985 LUKS checks for a valid passphrase when an encrypted partition
986 is unlocked. The behavior of plain dm-crypt is different.
987 It will always decrypt with the passphrase given. If the
988 given passphrase is wrong, the device mapped by plain
989 dm-crypt will essentially still contain encrypted data and
991 .SH NOTES ON SUPPORTED CIPHERS, MODES, HASHES AND KEY SIZES
992 The available combinations of ciphers, modes, hashes and key sizes
993 depend on kernel support. See /proc/crypto for a list of available
994 options. You might need to load additional kernel crypto modules
995 in order to get more options.
997 For the \-\-hash option, if the crypto backend is libgcrypt,
998 then all algorithms supported by the gcrypt library are available.
999 For other crypto backends some algorithms may be missing.
1000 .SH NOTES ON PASSPHRASES
1001 Mathematics can't be bribed. Make sure you keep your passphrases safe.
1002 There are a few nice tricks for constructing a fallback, when suddenly
1003 out of the blue, your brain refuses to cooperate.
1004 These fallbacks need LUKS, as it's only possible with LUKS
1005 to have multiple passphrases. Still, if your attacker model does
1006 not prevent it, storing your passphrase in a sealed envelope somewhere
1007 may be a good idea as well.
1008 .SH NOTES ON RANDOM NUMBER GENERATORS
1009 Random Number Generators (RNG) used in cryptsetup are always the
1010 kernel RNGs without any modifications or additions to data stream
1013 There are two types of randomness cryptsetup/LUKS needs. One type
1014 (which always uses /dev/urandom) is used for salts, the AF splitter
1015 and for wiping deleted keyslots.
1017 The second type is used for the volume (master) key. You can switch
1018 between using /dev/random and /dev/urandom here, see
1019 \fP\-\-use\-random\fR and \fP\-\-use\-urandom\fR
1020 options. Using /dev/random on a system without enough entropy sources
1021 can cause \fPluksFormat\fR to block until the requested amount of
1022 random data is gathered. In a low-entropy situation (embedded system),
1023 this can take a very long time and potentially forever. At the same
1024 time, using /dev/urandom in a low-entropy situation will
1025 produce low-quality keys. This is a serious problem, but solving
1026 it is out of scope for a mere man-page.
1027 See \fPurandom(4)\fR for more information.
1028 .SH NOTES ON LOOPBACK DEVICE USE
1029 Cryptsetup is usually used directly on a block device (disk
1030 partition or LVM volume). However, if the device argument is a
1031 file, cryptsetup tries to allocate a loopback device
1032 and map it into this file. This mode requires Linux kernel 2.6.25
1033 or more recent which supports the loop autoclear flag (loop device is
1034 cleared on last close automatically). Of course, you can
1035 always map a file to a loop-device manually. See the
1036 cryptsetup FAQ for an example.
1038 When device mapping is active, you can see the loop backing file in
1039 the status command output. Also see losetup(8).
1040 .SH DEPRECATED ACTIONS
1042 The \fIreload\fR action is no longer supported.
1043 Please use \fIdmsetup(8)\fR if you need to
1044 directly manipulate with the device mapping table.
1046 The \fIluksDelKey\fR was replaced with \fIluksKillSlot\fR.
1049 Report bugs, including ones in the documentation, on
1050 the cryptsetup mailing list at <dm-crypt@saout.de>
1051 or in the 'Issues' section on LUKS website.
1052 Please attach the output of the failed command with the
1053 \-\-debug option added.
1055 cryptsetup originally written by Jana Saout <jana@saout.de>
1057 The LUKS extensions and original man page were written by
1058 Clemens Fruhwirth <clemens@endorphin.org>.
1060 Man page extensions by Milan Broz <gmazyland@gmail.com>.
1062 Man page rewrite and extension by Arno Wagner <arno@wagner.name>.
1064 Copyright \(co 2004 Jana Saout
1066 Copyright \(co 2004-2006 Clemens Fruhwirth
1068 Copyright \(co 2009-2015 Red Hat, Inc.
1070 Copyright \(co 2009-2015 Milan Broz
1072 Copyright \(co 2012-2014 Arno Wagner
1074 This is free software; see the source for copying conditions. There is NO
1075 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1077 The LUKS website at \fBhttps://gitlab.com/cryptsetup/cryptsetup/\fR
1079 The cryptsetup FAQ, contained in the distribution package and
1081 \fBhttps://gitlab.com/cryptsetup/cryptsetup/wikis/FrequentlyAskedQuestions\fR
1083 The cryptsetup mailing list and list archive, see FAQ entry 1.6.
1085 The LUKS on-disk format specification available at
1086 \fBhttps://gitlab.com/cryptsetup/cryptsetup/wikis/Specification\fR