* Add --shared option for creating non-overlapping crypt segments.
[platform/upstream/cryptsetup.git] / man / cryptsetup.8
1 .TH CRYPTSETUP "8" "" "cryptsetup" "Maintenance Commands"
2 .SH NAME
3 cryptsetup - setup cryptographic volumes for dm-crypt (including LUKS extension)
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 device-mapper mappings.
9 .SH PLAIN MODE
10 For basic (plain) dm-crypt mappings, there are four operations.
11
12 \fIcreate\fR <name> <device>
13 .IP
14 creates a mapping with <name> backed by device <device>.
15
16 \fB<options>\fR can be [\-\-hash, \-\-cipher, \-\-verify-passphrase,
17 \-\-key-file, \-\-key-size, \-\-offset, \-\-skip, \-\-size, \-\-readonly, \-\-shared]
18 .PP
19 \fIremove\fR <name>
20 .IP
21 removes an existing mapping <name>.
22 .PP
23 \fIstatus\fR <name>
24 .IP
25 reports the status for the mapping <name>.
26 .PP
27 \fIresize\fR <name>
28 .IP
29 resizes an active mapping <name>.
30
31 If \-\-size (in sectors) is not specified, the size of the underlying block device is used.
32 .SH LUKS EXTENSION
33 LUKS, Linux Unified Key Setup, is a standard for hard disk encryption.
34 It standardizes a partition header, as well as the format of the bulk data.
35 LUKS can manage multiple passwords, that can be revoked effectively
36 and that are protected against dictionary attacks with PBKDF2.
37
38 These are valid LUKS actions:
39
40 \fIluksFormat\fR <device> [<key file>]
41 .IP
42 initializes a LUKS partition and sets the initial key, either via prompting or via <key file>.
43
44 \fB<options>\fR can be [\-\-cipher, \-\-verify-passphrase, \-\-key-size,
45 \-\-key-slot, \-\-key-file (takes precedence over optional second argument),
46 \-\-keyfile-size, \-\-use-random | \-\-use-urandom, \-\-uuid].
47 .PP
48 \fIluksOpen\fR <device> <name>
49 .IP
50 opens the LUKS partition <device> and sets up a mapping <name> after
51 successful verification of the supplied key material
52 (either via key file by \-\-key-file, or via prompting).
53
54 \fB<options>\fR can be [\-\-key-file, \-\-keyfile-size, \-\-readonly].
55 .PP
56 \fIluksClose\fR <name>
57 .IP
58 identical to \fIremove\fR.
59 .PP
60 \fIluksSuspend\fR <name>
61 .IP
62 suspends active device (all IO operations are frozen) and wipes encryption
63 key from kernel. Kernel version 2.6.19 or later is required.
64
65 After that operation you have to use \fIluksResume\fR to reinstate
66 encryption key (and resume device) or \fIluksClose\fR to remove mapped device.
67
68 \fBWARNING:\fR never try to suspend device where is the cryptsetup binary itself.
69 .PP
70 \fIluksResume\fR <name>
71 .IP
72 Resumes suspended device and reinstates encryption key. You will need provide passphrase
73 identical to \fIluksOpen\fR command (using prompting or key file).
74
75 \fB<options>\fR can be [\-\-key-file, \-\-keyfile-size]
76 .PP
77 \fIluksAddKey\fR <device> [<new key file>]
78 .IP
79 add a new key file/passphrase. An existing passphrase or key file
80 (via \-\-key-file) must be supplied.
81 The key file with the new material is supplied as a positional argument.
82
83 \fB<options>\fR can be [\-\-key-file, \-\-keyfile-size, \-\-new-keyfile-size, \-\-key-slot].
84 .PP
85 \fIluksRemoveKey\fR <device> [<key file>] 
86 .IP
87 remove supplied key or key file from LUKS device
88 .PP
89 \fIluksChangeKey\fR <device> [<new key file>]
90 .IP
91 change existing key file or passphrase. An existing passphrase
92 or key file (via \-\-key-file) must be supplied.
93 The key file with the new material is supplied as a positional argument.
94
95 If no key slot is specified (and there is still free key slot on device)
96 new slot is allocated before the old is purged.
97
98 If \fB\-\-key\-slot\fR option is specified (or there is no free slot)
99 command will overwrite existing slot.
100
101 \fBWARNING:\fR Be sure you have another slot active or header backup
102 when using explicit key slot (so you can unlock the device even after
103 possible media failure during slot swap).
104
105 \fB<options>\fR can be [\-\-key-file, \-\-keyfile-size,\-\-new-keyfile-size,
106 \-\-key-slot].
107 .PP
108 \fIluksKillSlot\fR <device> <key slot number>
109 .IP
110 wipe key with number <key slot> from LUKS device. A remaining passphrase or
111 key file (via \-\-key-file) must be supplied.
112
113 \fB<options>\fR can be [\-\-key-file, \-\-keyfile-size].
114 .PP
115 \fIluksUUID\fR <device>
116 .IP
117 print UUID, if <device> has a LUKS header.
118
119 set new UUID if \fI\-\-uuid\fR option is specified.
120 .PP
121 \fIisLuks\fR <device>
122 .IP
123 returns true, if <device> is a LUKS partition. Otherwise, false.
124 .PP
125 \fIluksDump\fR <device>
126 .IP
127 dumps the header information of a LUKS partition.
128
129 If \-\-dump-master-key option is used, the volume (master) key is dumped
130 instead of keyslot info.
131
132 Because this information can be used to access encrypted device without
133 passphrase knowledge (even without LUKS header) use this option
134 very carefully.
135
136 Dump with volume key (either printed or stored to file) should be always
137 stored encrypted and on safe place.
138
139 LUKS passphrase or key file is required for volume key dump.
140
141 \fB<options>\fR can be [\-\-dump-master-key, \-\-key-file, \-\-keyfile-size].
142 .PP
143 \fIluksHeaderBackup\fR <device> \-\-header-backup-file <file>
144 .IP
145 Stores binary backup of LUKS header and keyslot areas.
146
147 \fBWARNING:\fR Please note that with this backup file (and old passphrase
148 knowledge) you can decrypt data even if old passphrase was wiped from real device.
149
150 Also note that anti-forensic splitter is not used during manipulation with backup file.
151 .PP
152 \fIluksHeaderRestore\fR <device> \-\-header-backup-file <file>
153 .IP
154 Restores binary backup of LUKS header and keyslot areas from specified file.
155
156 \fBWARNING:\fR All the keyslot areas are overwritten, only active keyslots
157 form backup file are available after issuing this command.
158
159 This command allows restoring header if device do not contain LUKS header
160 or if the master key size and data offset in LUKS header on device match the backup file.
161 .PP
162 For more information about LUKS, see
163 \fBhttp://code.google.com/p/cryptsetup/wiki/Specification\fR
164 .SH loop-AES EXTENSION
165 cryptsetup supports mapping of loop-AES encrypted partition using
166 compatible dm-crypt mode.
167 .PP
168 \fIloopaesOpen\fR <device> <name> \-\-key-file <keyfile>
169 .IP
170 opens the loop-AES <device> and sets up a mapping <name>.
171
172 N.B. If key file is in GPG encrypted format, you have to use
173 \-\-key-file=- and decrypt it before use.
174 gpg \-\-decrypt <keyfile> | cryptsetup loopaesOpen \-\-key-file=- <device> <name>
175
176 Use \fB\-\-key-file\fR to specify proper key length, default compiled-in
177 parameters are visible in \fB\-\-help\fR output.
178
179 Use \fB\-\-offset\fR to specify device offset. Note the units need to be
180 specified in 512 bytes sectors.
181
182 Use \fB\-\-skip\fR to specify IV offset. If original device used offset
183 and not used it in IV sector calculations, you have to explicitly use
184 \fB\-\-skip 0\fR in addition to offset parameter.
185
186 Use \fB\-\-hash\fR to override hash function for password hashing
187 (otherwise it is detected according to key size).
188
189 \fB<options>\fR can be [\-\-key-file, \-\-key-size, \-\-offset, \-\-skip, 
190 \-\-hash, \-\-readonly].
191 .PP
192 \fIloopaesClose\fR <name>
193 .IP
194 identical to \fIremove\fR.
195 .PP
196 For more information about loop-AES, see \fBhttp://loop-aes.sourceforge.net\fR
197 .SH OPTIONS
198 .TP
199 .B "\-\-verbose, \-v"
200 Print more verbose messages.
201 .TP
202 .B "\-\-debug"
203 Run in debug mode with full diagnostic logs.
204 .TP
205 .B "\-\-hash, \-h"
206 For \fIcreate\fR and \fIloopaesOpen\fR action specifies hash to use for password hashing.
207
208 For \fIluksFormat\fR action specifies hash used in LUKS key setup scheme
209 and volume key digest.
210
211 \fBWARNING:\fR setting hash other than \fBsha1\fR causes LUKS device
212 incompatible with older version of cryptsetup.
213
214 The hash string is passed to libgcrypt, so all hash algorithms are supported
215 (for \fIluksFormat\fR algorithm must provide at least 20 byte long hash).
216 Default is set during compilation, compatible values with old version of cryptsetup are
217 \fB"ripemd160"\fR for \fIcreate\fR action and \fB"sha1"\fR for \fIluksFormat\fR.
218
219 Use \fIcryptsetup \-\-help\fR to show defaults.
220 .TP
221 .B "\-\-cipher, \-c"
222 set cipher specification string.
223
224 Default mode is configurable during compilation,
225 you can see compiled-in default using \fIcryptsetup \-\-help\fR.
226 If not changed, the default is for plain dm-crypt and LUKS mappings
227 "aes-cbc-essiv:sha256".
228
229 For XTS mode, kernel version 2.6.24 or more recent is required.
230 Use "aes-xts-plain64" cipher specification and set key size to 256
231 (or 512) bits (see \-s option).
232 Note that plain64 IV (Initialization Vector) is available since kernel version 2.6.33
233 and it is full 64bit version of plain IV. For more info please see FAQ.
234 .TP
235 .B "\-\-verify-passphrase, \-y"
236 query for passwords twice. Useful when creating a (regular) mapping
237 for the first time, or when running \fIluksFormat\fR.
238 .TP
239 .B "\-\-key-file, \-d"
240 use file as key material.
241
242 With LUKS, key material supplied in key files via \-d are always used
243 for existing passphrases, except in \fIluksFormat\fR action where
244 \-d is equivalent to positional key file argument.
245
246 If you want to set a new key via a key file, you have to use
247 a positional arg to \fIluksAddKey\fR.
248
249 If the key file is "-", stdin will be used. With the "-" key file
250 reading will not stop when new line character is detected.
251
252 See section \fBNOTES ON PASSWORD PROCESSING\fR for more information.
253 .TP
254 .B "\-\-keyfile-size, \-l \fIvalue\fR"
255 Limits read from key file to \fIvalue\fR bytes.
256 Usable together with all commands using key file.
257 .TP
258 .B "\-\-new-keyfile-size  \fIvalue\fR"
259 Limits read from new key file to \fIvalue\fR bytes in \fIluksAddKey\fR when
260 adding new key file. Default is exhaustive read from key file.
261 .TP
262 .B "\-\-master-key-file"
263 Use pre-generated master key stored in file. For \fIluksFormat\fR it allows
264 LUKS header reformatting with the same master key (if all other parameters
265 are the same existing encrypted data remains intact).
266
267 For \fIluksAddKey\fR it allows adding new passphrase with only master key knowledge.
268 .TP
269 .B "\-\-dump-master-key"
270 For \fIluksDump\fR it allows LUKS header dump including volume (master) key.
271 Use with care (this information allows access to device without passphrase knowledge).
272
273 See \fIluksDump\fR for more info.
274 .TP
275 .B "\-\-use-random"
276 .TP
277 .B "\-\-use-urandom"
278 For \fIluksFormat\fR it defines which kernel random number generator will
279 be used for long-term key (volume key).
280
281 See \fBNOTES ON RNG\fR for more information. Use \fIcryptsetup \-\-help\fR
282 to show default RNG.
283 .TP
284 .B "\-\-key-slot, \-S"
285 For LUKS operations that add key material, this options allows you
286 to specify which key slot is selected for the new key.
287 This option can be used for \fIluksFormat\fR and \fIluksAddKey\fR.
288 .TP
289 .B "\-\-key-size, \-s"
290 set key size in bits.
291
292 Has to be a multiple of 8 bits. The key size is limited by the used cipher.
293
294 See output of /proc/crypto for more information.
295
296 Can be used for \fIcreate\fR or \fIluksFormat\fR, all other LUKS actions
297 will use key-size specified by the LUKS header.
298 Default is set during compilation, if not changed it is 256 bits.
299
300 Use \fIcryptsetup \-\-help\fR to show defaults.
301 .TP
302 .B "\-\-size, \-b"
303 force the size of the underlying device in sectors.
304 This option is only relevant for \fIcreate\fR and \fIresize\fR action.
305 .TP
306 .B "\-\-offset, \-o"
307 start offset in the backend device (in 512-byte sectors).
308 This option is only relevant for \fIcreate\fR and \fIloopaesOpen\fR action.
309 .TP
310 .B "\-\-skip, \-p"
311 how many sectors of the encrypted data to skip at the beginning.
312 This is different from the \-\-offset options with respect to IV calculations.
313 Using \-\-offset will shift the IV calculation by the same negative amount.
314 Hence, if \-\-offset \fIn\fR, sector \fIn\fR will be the first sector
315 on the mapping with IV \fI0\fR. Using \-\-skip would have resulted in sector
316 \fIn\fR being the first sector also, but with IV \fIn\fR.
317 This option is only relevant for \fIcreate\fR and \fIloopaesOpen\fR action.
318 .TP
319 .B "\-\-readonly"
320 set up a read-only mapping.
321 .TP
322 .B "\-\-shared"
323 create another non-overlapping mapping to one common ciphertext device,
324 e.g. to create hidden device inside another encrypted device.
325 This option is only relevant for \fIcreate\fR action.
326 Use \-\-offset, \-\-size and \-\-skip to specify mapped area.
327 .TP
328 .B "\-\-iter-time, \-i"
329 The number of milliseconds to spend with PBKDF2 password processing.
330 This option is only relevant to the LUKS operations as
331 \fIluksFormat\fR or \fIluksAddKey\fR.
332 Note that 0 means default.
333 .TP
334 .B "\-\-batch-mode, \-q"
335 Do not ask for confirmation. Use with care! This option is only relevant
336 for \fIluksFormat\fR, \fIluksAddKey\fR, \fIluksRemoveKey\fR or \fIluksKillSlot\fR.
337 .TP
338 .B "\-\-timeout, \-t"
339 The number of seconds to wait before timeout. This option is relevant every
340 time a password is asked, like \fIcreate\fR, \fIluksOpen\fR, \fIluksFormat\fR
341 or \fIluksAddKey\fR. It has no effect if used in conjunction with \-\-key-file.
342 .TP
343 .B "\-\-tries, \-T"
344 How often the input of the passphrase shall be retried. This option is relevant
345 every time a password is asked, like \fIcreate\fR, \fIluksOpen\fR, \fIluksFormat\fR
346 or \fIluksAddKey\fR. The default is 3 tries.
347 .TP
348 .B "\-\-align-payload=\fIvalue\fR"
349 Align payload at a boundary of \fIvalue\fR 512-byte sectors.
350 This option is relevant for \fIluksFormat\fR.
351
352 If not specified, cryptsetup tries to use topology info provided by kernel
353 for underlying device to get optimal alignment.
354 If not available (or calculated value is multiple of default) data is by
355 default aligned to 1 MiB boundary (2048 512-byte sectors).
356 .TP
357 .B "\-\-uuid=\fIUUID\fR"
358 Use provided \fIUUID\fR in \fIluksFormat\fR command instead of generating
359 new one or change existing UUID in \fIluksUUID\fR command.
360
361 The UUID must be provided in standard UUID format
362 (e.g. 12345678-1234-1234-1234-123456789abc).
363 .TP
364 .B "\-\-version"
365 Show the version.
366 .SH RETURN CODES
367 Crypsetup returns 0 on success or non-zero on error.
368
369 Error codes are: 1 wrong parameters, 2 no permission (bad passphrase),
370 3 out of memory, 4 wrong device specified, 5 device already exists
371 or device is busy.
372 .SH NOTES ON PASSWORD PROCESSING FOR PLAIN MODE
373 \fBFrom a terminal\fR: Password processing is new-line sensitive,
374 meaning the reading will stop after encountering \\n.
375 It will process the read material (without newline) with the default
376 hash or the hash given by \-\-hash.
377 After hashing, it will be cropped to the key size given by \-s.
378
379 \fBFrom stdin\fR: Reading will continue until EOF (or until
380 maximum input size is reached), with the trailing newline stripped.
381 The maximum input size is defined by the same compiled-in default
382 as for the maximum key file size or can be overwrittten
383 using \-\-keysfile-size option.
384
385 After that the read data will be hashed with the default hash
386 or the hash given by \-\-hash and the result will be cropped
387 to the keysize given by \-s.
388
389 If "plain" is used as an argument to the hash option, the input
390 data will not be hashed.
391 Instead, it will be zero padded (if shorter than the keysize) or
392 truncated (if longer than the keysize) and used directly as the key.
393 No warning will be given if the amount of data read from stdin is
394 less than the keysize.
395
396 \fBFrom a key file\fR: It will be cropped to the size given by \-s.
397 If there is insufficient key material in the key file, cryptsetup
398 will quit with an error.
399
400 If \-\-key-file=- is used for reading the key from stdin, no
401 trailing newline is stripped from the input. Without that option,
402 cryptsetup strips trailing newlines from stdin input.
403 .SH NOTES ON PASSWORD PROCESSING FOR LUKS
404 LUKS uses PBKDF2 to protect against dictionary attacks (see RFC 2898).
405
406 LUKS will always do an exhaustive password reading.
407 Hence, password can not be read from /dev/random, /dev/zero or any
408 other stream that does not terminate.
409 To prevent exhausting of system memory, cryptsetup limits
410 maximum key file size. Compiled-in default is displayed in \-\-help
411 output. You can limit reads from key file using \-\-key-size option,
412 this option takes precedence over compiled-in default.
413
414 For any password creation action (luksAddKey, or luksFormat),
415 the user may specify how much the time the password processing
416 should consume. Increasing the time will lead to a more secure
417 password, but also will take luksOpen longer to complete.
418 The default setting of one second is sufficient for good security.
419 .SH INCOHERENT BEHAVIOUR FOR INVALID PASSWORDS/KEYS
420 LUKS checks for a valid password or key when an encrypted partition
421 is unlocked. Thus the luksOpen action fails with invalid password
422 or key, contrary to the plain dm-crypt create action.
423
424 Please also be sure that you are using the same keyboard and
425 language setting as during device format.
426 .SH NOTES ON SUPPORTED CIPHERS, MODES, HASHES AND KEY SIZES
427 The available combinations of ciphers, modes, hashes and key sizes
428 depend on kernel support. See /proc/crypto for a list of available
429 options. You might need to load additional kernel crypto modules
430 in order to get more options.
431
432 For \-\-hash option all algorithms supported by gcrypt library are available.
433 .SH NOTES ON PASSWORDS
434 Mathematics can't be bribed. Make sure you keep your passwords safe.
435 There are a few nice tricks for constructing a fallback, when suddenly
436 out of (or after being) blue, your brain refuses to cooperate.
437 These fallbacks are possible with LUKS, as it's only possible with LUKS
438 to have multiple passwords.
439 .SH NOTES ON RNG
440 Random Number Generator (RNG) used in cryptsetup always uses kernel RNG without
441 any modifications or additions to data stream procudes by kernel (like internal
442 random pool operations or mixing with the other random sources).
443
444 There are two types of randomness cryptsetup/LUKS needs. One type (which always
445 uses /dev/urandom) is used for salt, AF splitter and for wiping removed
446 keyslot.
447
448 Second type is used for volume (master) key. You can switch between
449 using /dev/random and /dev/urandom  here, see \fP\-\-use-random\fR and \fP\-\-use-urandom\fR
450 options. Using /dev/random on system without enough entropy sources
451 can cause \fPluksFormat\fR to block until the requested amount of random data is gathered.
452 See \fPurandom(4)\fR for more information.
453 .SH NOTES ON LOOPBACK DEVICE USE
454 Cryptsetup is usually used directly over block device (like disk partition or LVM volume).
455 However if the device argument is file, cryptsetup tries to allocate loopback device
456 and map it into this file. This mode requires Linux kernel 2.6.25 or more recent which
457 supports loop autoclear flag (loop device is cleared on last close automatically).
458
459 When device mapping is active, you can see loop backing file in status command output.
460 Also see losetup(8).
461 .SH AUTHORS
462 cryptsetup is written by Christophe Saout <christophe@saout.de>
463 .br
464 LUKS extensions, and man page by Clemens Fruhwirth <clemens@endorphin.org>
465 .SH DEPRECATED ACTIONS
466 .PP
467 The \fIreload\fR action is no longer supported.
468 Please use \fIdmsetup(8)\fR if you need to
469 directly manipulate with the device mapping table.
470 .PP
471 The \fIluksDelKey\fR was replaced with \fIluksKillSlot\fR.
472 .PP
473 .SH REPORTING BUGS
474 Report bugs to <dm-crypt@saout.de> or Issues section on LUKS website.
475 Please attach output of failed command with added \-\-debug option.
476 .SH COPYRIGHT
477 Copyright \(co 2004 Christophe Saout
478 .br
479 Copyright \(co 2004-2006 Clemens Fruhwirth
480 .br
481 Copyright \(co 2009-2011 Red Hat, Inc.
482
483 This is free software; see the source for copying conditions.  There is NO
484 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
485 .SH SEE ALSO
486 LUKS website, \fBhttp://code.google.com/p/cryptsetup/\fR