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