1 .TH CRYPTSETUP "8" "" "cryptsetup" "Maintenance Commands"
3 cryptsetup - setup cryptographic volumes for dm-crypt (including LUKS extension)
5 .B cryptsetup <options> <action> <action args>
8 cryptsetup is used to conveniently setup dm-crypt managed device-mapper mappings.
10 For basic (plain) dm-crypt mappings, there are four operations.
12 \fIcreate\fR <name> <device>
14 creates a mapping with <name> backed by device <device>.
16 \fB<options>\fR can be [\-\-hash, \-\-cipher, \-\-verify-passphrase,
17 \-\-key-file, \-\-key-size, \-\-offset, \-\-skip, \-\-size, \-\-readonly, \-\-shared,
22 removes an existing mapping <name>.
26 reports the status for the mapping <name>.
30 resizes an active mapping <name>.
32 If \-\-size (in sectors) is not specified, the size of the underlying block device is used.
34 LUKS, Linux Unified Key Setup, is a standard for hard disk encryption.
35 It standardizes a partition header as well as the format of the bulk data.
36 LUKS can manage multiple passwords that can be individually revoked and
37 effectively scrubbed from persistent media, and that are protected
38 against dictionary attacks with PBKDF2.
40 Each password, usually called a
42 in this document, is associated with a slot, of which there are typically 8.
43 Key operations that do not specify a slot affect the first slot
44 matching the supplied key.
46 These are valid LUKS actions:
48 \fIluksFormat\fR <device> [<key file>]
50 initializes a LUKS partition and sets the initial key, either via prompting or via <key file>.
52 \fB<options>\fR can be [\-\-cipher, \-\-verify-passphrase, \-\-key-size,
53 \-\-key-slot, \-\-key-file (takes precedence over optional second argument),
54 \-\-keyfile-size, \-\-use-random | \-\-use-urandom, \-\-uuid, \-\-master-key-file].
56 \fIluksOpen\fR <device> <name>
58 opens the LUKS partition <device> and sets up a mapping <name> after
59 successful verification of the supplied key material
60 (either via key file by \-\-key-file, or via prompting).
62 Device parameter can be also specified by LUKS UUID in the format UUID=<uuid>
63 (then cryptsetup will use /dev/disk/by-uuid symlinks).
65 \fB<options>\fR can be [\-\-key-file, \-\-keyfile-size, \-\-readonly, \-\-allow-discards,
66 \-\-header, \-\-key-slot, \-\-master-key-file].
68 \fIluksClose\fR <name>
70 identical to \fIremove\fR.
72 \fIluksSuspend\fR <name>
74 suspends active device (all IO operations are frozen) and wipes encryption
75 key from kernel. Kernel version 2.6.19 or later is required.
77 After that operation you have to use \fIluksResume\fR to reinstate
78 encryption key (and resume device) or \fIluksClose\fR to remove mapped device.
80 \fBWARNING:\fR never try to suspend device where is the cryptsetup binary itself.
82 \fB<options>\fR can be [\-\-header].
84 \fIluksResume\fR <name>
86 Resumes suspended device and reinstates encryption key. You will need provide passphrase
87 identical to \fIluksOpen\fR command (using prompting or key file).
89 \fB<options>\fR can be [\-\-key-file, \-\-keyfile-size, \-\-header]
91 \fIluksAddKey\fR <device> [<new key file>]
93 add a new key file/passphrase. An existing passphrase or key file
94 (via \-\-key-file) must be supplied.
95 The key file with the new material is supplied as a positional argument.
97 \fB<options>\fR can be [\-\-key-file, \-\-keyfile-size, \-\-new-keyfile-size, \-\-key-slot,
100 \fIluksRemoveKey\fR <device> [<key file>]
102 remove supplied key or key file from LUKS device in the manner of \fIluksKillSlot\fR.
104 \fIluksChangeKey\fR <device> [<new key file>]
106 change existing key file or passphrase. An existing passphrase
107 or key file (via \-\-key-file) must be supplied.
108 The key file with the new material is supplied as a positional argument.
110 If no key slot is specified (and there is still free key slot on device)
111 new slot is allocated before the old is purged.
113 If \fB\-\-key\-slot\fR option is specified (or there is no free slot)
114 command will overwrite existing slot.
116 \fBWARNING:\fR Be sure you have another slot active or header backup
117 when using explicit key slot (so you can unlock the device even after
118 possible media failure during slot swap).
120 \fB<options>\fR can be [\-\-key-file, \-\-keyfile-size,\-\-new-keyfile-size,
123 \fIluksKillSlot\fR <device> <key slot number>
125 wipe key with number <key slot> from LUKS device. A remaining passphrase or
126 key file (via \-\-key-file) must be supplied.
128 \fB<options>\fR can be [\-\-key-file, \-\-keyfile-size].
130 \fIluksUUID\fR <device>
132 print UUID, if <device> has a LUKS header.
134 set new UUID if \fI\-\-uuid\fR option is specified.
136 \fIisLuks\fR <device>
138 returns true, if <device> is a LUKS partition. Otherwise, false.
140 \fIluksDump\fR <device>
142 dumps the header information of a LUKS partition.
144 If \-\-dump-master-key option is used, the volume (master) key is dumped
145 instead of keyslot info.
147 Because this information can be used to access encrypted device without
148 passphrase knowledge (even without LUKS header) use this option
151 Dump with volume key (either printed or stored to file) should be always
152 stored encrypted and on safe place.
154 LUKS passphrase or key file is required for volume key dump.
156 \fB<options>\fR can be [\-\-dump-master-key, \-\-key-file, \-\-keyfile-size].
158 \fIluksHeaderBackup\fR <device> \-\-header-backup-file <file>
160 Stores binary backup of LUKS header and keyslot areas.
162 \fBWARNING:\fR Please note that with this backup file (and old passphrase
163 knowledge) you can decrypt data even if old passphrase was wiped from real device.
165 Also note that anti-forensic splitter is not used during manipulation with backup file.
167 \fIluksHeaderRestore\fR <device> \-\-header-backup-file <file>
169 Restores binary backup of LUKS header and keyslot areas from specified file.
171 \fBWARNING:\fR All the keyslot areas are overwritten, only active keyslots
172 form backup file are available after issuing this command.
174 This command allows restoring header if device do not contain LUKS header
175 or if the master key size and data offset in LUKS header on device match the backup file.
177 For more information about LUKS, see
178 \fBhttp://code.google.com/p/cryptsetup/wiki/Specification\fR
179 .SH loop-AES EXTENSION
180 cryptsetup supports mapping of loop-AES encrypted partition using
181 compatible dm-crypt mode.
183 \fIloopaesOpen\fR <device> <name> \-\-key-file <keyfile>
185 opens the loop-AES <device> and sets up a mapping <name>.
187 N.B. If key file is in GPG encrypted format, you have to use
188 \-\-key-file=- and decrypt it before use.
189 gpg \-\-decrypt <keyfile> | cryptsetup loopaesOpen \-\-key-file=- <device> <name>
191 Use \fB\-\-key-file\fR to specify proper key length, default compiled-in
192 parameters are visible in \fB\-\-help\fR output.
194 Use \fB\-\-offset\fR to specify device offset. Note the units need to be
195 specified in 512 bytes sectors.
197 Use \fB\-\-skip\fR to specify IV offset. If original device used offset
198 and not used it in IV sector calculations, you have to explicitly use
199 \fB\-\-skip 0\fR in addition to offset parameter.
201 Use \fB\-\-hash\fR to override hash function for password hashing
202 (otherwise it is detected according to key size).
204 \fB<options>\fR can be [\-\-key-file, \-\-key-size, \-\-offset, \-\-skip,
205 \-\-hash, \-\-readonly, \-\-allow-discards].
207 \fIloopaesClose\fR <name>
209 identical to \fIremove\fR.
211 For more information about loop-AES, see \fBhttp://loop-aes.sourceforge.net\fR
214 .B "\-\-verbose, \-v"
215 Print more verbose messages.
218 Run in debug mode with full diagnostic logs.
221 For \fIcreate\fR and \fIloopaesOpen\fR action specifies hash to use for password hashing.
223 For \fIluksFormat\fR action specifies hash used in LUKS key setup scheme
224 and volume key digest.
226 \fBWARNING:\fR setting hash other than \fBsha1\fR causes LUKS device
227 incompatible with older version of cryptsetup.
229 The hash string is passed to libgcrypt, so all hash algorithms are supported
230 (for \fIluksFormat\fR algorithm must provide at least 20 byte long hash).
231 Default is set during compilation, compatible values with old version of cryptsetup are
232 \fB"ripemd160"\fR for \fIcreate\fR action and \fB"sha1"\fR for \fIluksFormat\fR.
234 Use \fIcryptsetup \-\-help\fR to show defaults.
237 set cipher specification string.
239 Default mode is configurable during compilation,
240 you can see compiled-in default using \fIcryptsetup \-\-help\fR.
241 If not changed, the default is for plain dm-crypt and LUKS mappings
242 "aes-cbc-essiv:sha256".
244 For XTS mode, kernel version 2.6.24 or more recent is required.
245 Use "aes-xts-plain64" cipher specification and set key size to 256
246 (or 512) bits (see \-s option).
247 Note that plain64 IV (Initialization Vector) is available since kernel version 2.6.33
248 and it is full 64bit version of plain IV. For more info please see FAQ.
250 .B "\-\-verify-passphrase, \-y"
251 query for passwords twice. Useful when creating a (regular) mapping
252 for the first time, or when running \fIluksFormat\fR.
254 Password verification option is ignored if requested on non terminal
255 input (like pipe of file).
257 .B "\-\-key-file, \-d"
258 use file as key material.
260 With LUKS, key material supplied in key files via \-d are always used
261 for existing passphrases, except in \fIluksFormat\fR action where
262 \-d is equivalent to positional key file argument.
264 If you want to set a new key via a key file, you have to use
265 a positional arg to \fIluksAddKey\fR.
267 If the key file is "-", stdin will be used. With the "-" key file
268 reading will not stop when new line character is detected.
270 See section \fBNOTES ON PASSWORD PROCESSING\fR for more information.
272 .B "\-\-keyfile-size, \-l \fIvalue\fR"
273 Limits read from key file to \fIvalue\fR bytes.
274 Usable together with all commands using key file.
276 .B "\-\-new-keyfile-size \fIvalue\fR"
277 Limits read from new key file to \fIvalue\fR bytes in \fIluksAddKey\fR when
278 adding new key file. Default is exhaustive read from key file.
280 .B "\-\-master-key-file"
281 Use pre-generated master key stored in file. For \fIluksFormat\fR it allows
282 LUKS header reformatting with the same master key (if all other parameters
283 are the same existing encrypted data remains intact).
285 For \fIluksAddKey\fR it allows adding new passphrase with only master key knowledge.
287 For \fIluksOpen\fR it allows to open the LUKS device with only master key knowledge.
290 .B "\-\-dump-master-key"
291 For \fIluksDump\fR it allows LUKS header dump including volume (master) key.
292 Use with care (this information allows access to device without passphrase knowledge).
294 See \fIluksDump\fR for more info.
299 For \fIluksFormat\fR it defines which kernel random number generator will
300 be used for long-term key (volume key).
302 See \fBNOTES ON RNG\fR for more information. Use \fIcryptsetup \-\-help\fR
305 .B "\-\-key-slot, \-S"
306 For LUKS operations that add key material, this options allows you
307 to specify which key slot is selected for the new key.
308 This option can be used for \fIluksFormat\fR, \fIluksOpen\fR and \fIluksAddKey\fR.
310 .B "\-\-key-size, \-s"
311 set key size in bits.
313 Has to be a multiple of 8 bits. The key size is limited by the used cipher.
315 See output of /proc/crypto for more information.
317 Can be used for \fIcreate\fR or \fIluksFormat\fR, all other LUKS actions
318 will use key-size specified by the LUKS header.
319 Default is set during compilation, if not changed it is 256 bits.
321 Use \fIcryptsetup \-\-help\fR to show defaults.
324 force the size of the underlying device in sectors.
325 This option is only relevant for \fIcreate\fR and \fIresize\fR action.
328 start offset in the backend device (in 512-byte sectors).
329 This option is only relevant for \fIcreate\fR and \fIloopaesOpen\fR action.
332 how many sectors of the encrypted data to skip at the beginning.
333 This is different from the \-\-offset options with respect to IV calculations.
334 Using \-\-offset will shift the IV calculation by the same negative amount.
335 Hence, if \-\-offset \fIn\fR, sector \fIn\fR will be the first sector
336 on the mapping with IV \fI0\fR. Using \-\-skip would have resulted in sector
337 \fIn\fR being the first sector also, but with IV \fIn\fR.
338 This option is only relevant for \fIcreate\fR and \fIloopaesOpen\fR action.
341 set up a read-only mapping.
344 create another non-overlapping mapping to one common ciphertext device,
345 e.g. to create hidden device inside another encrypted device.
346 This option is only relevant for \fIcreate\fR action.
347 Use \-\-offset, \-\-size and \-\-skip to specify mapped area.
349 .B "\-\-iter-time, \-i"
350 The number of milliseconds to spend with PBKDF2 password processing.
351 This option is only relevant to the LUKS operations as
352 \fIluksFormat\fR or \fIluksAddKey\fR.
353 Note that 0 means default.
355 .B "\-\-batch-mode, \-q"
356 Do not ask for confirmation. Use with care!
358 If \-y option is not specified, batch mode option also switches off
359 passphrase verification for \fIluksFormat\fR.
361 .B "\-\-timeout, \-t"
362 The number of seconds to wait before timeout. This option is relevant every
363 time a password is asked, like \fIcreate\fR, \fIluksOpen\fR, \fIluksFormat\fR
364 or \fIluksAddKey\fR. It has no effect if used in conjunction with \-\-key-file.
367 How often the input of the passphrase shall be retried. This option is relevant
368 every time a password is asked, like \fIcreate\fR, \fIluksOpen\fR, \fIluksFormat\fR
369 or \fIluksAddKey\fR. The default is 3 tries.
371 .B "\-\-align-payload=\fIvalue\fR"
372 Align payload at a boundary of \fIvalue\fR 512-byte sectors.
373 This option is relevant for \fIluksFormat\fR.
375 If not specified, cryptsetup tries to use topology info provided by kernel
376 for underlying device to get optimal alignment.
377 If not available (or calculated value is multiple of default) data is by
378 default aligned to 1 MiB boundary (2048 512-byte sectors).
380 For detached LUKS header it specifies offset on data device.
381 See also \-\-header option.
383 .B "\-\-uuid=\fIUUID\fR"
384 Use provided \fIUUID\fR in \fIluksFormat\fR command instead of generating
385 new one or change existing UUID in \fIluksUUID\fR command.
387 The UUID must be provided in standard UUID format
388 (e.g. 12345678-1234-1234-1234-123456789abc).
390 .B "\-\-allow-discards\fR"
391 Allow using of discards (TRIM) requests for device.
392 This option is only relevant for \fIcreate\fR, \fIluksOpen\fR or \fIloopaesOpen\fR.
394 \fBWARNING:\fR Assess the specific security risks carefully before enabling this
395 option. For example, allowing discards on encrypted devices may lead to the leak
396 of information about the ciphertext device (filesystem type, used space etc.)
397 if the discarded blocks can be located easily on the device later.
399 Kernel version 3.1 or more recent is required.
400 For older versions is the option ignored.
403 Set detached (separated) metadata device or file with LUKS header.
405 This options allows separation of ciphertext device and on-disk metadata header.
407 This option is only relevant for LUKS devices and can be used in \fIluksFormat\fR,
408 \fIluksOpen\fR, \fIluksSuspend\fR, \fIluksResume\fR, \fIstatus\fR and
409 \fIresize\fR commands.
411 If used with \fIluksFormat\fR the \-\-align-payload option is taken
412 as absolute sector alignment on ciphertext device and can be zero.
414 For other commands with separated metadata device you have to always specify
415 path to metadata device (not to the ciphertext device).
417 \fBWARNING:\fR There is no possible check that specified ciphertext device
418 is correct if on-disk header is detached. Use with care.
423 Crypsetup returns 0 on success or non-zero on error.
425 Error codes are: 1 wrong parameters, 2 no permission (bad passphrase),
426 3 out of memory, 4 wrong device specified, 5 device already exists
428 .SH NOTES ON PASSWORD PROCESSING FOR PLAIN MODE
429 \fBFrom a terminal\fR: Password processing is new-line sensitive,
430 meaning the reading will stop after encountering \\n.
431 It will process the read material (without newline) with the default
432 hash or the hash given by \-\-hash.
433 After hashing, it will be cropped to the key size given by \-s.
435 \fBFrom stdin\fR: Reading will continue until EOF (or until
436 maximum input size is reached), with the trailing newline stripped.
437 The maximum input size is defined by the same compiled-in default
438 as for the maximum key file size or can be overwrittten
439 using \-\-keysfile-size option.
441 After that the read data will be hashed with the default hash
442 or the hash given by \-\-hash and the result will be cropped
443 to the keysize given by \-s.
445 If "plain" is used as an argument to the hash option, the input
446 data will not be hashed.
447 Instead, it will be zero padded (if shorter than the keysize) or
448 truncated (if longer than the keysize) and used directly as the key.
449 No warning will be given if the amount of data read from stdin is
450 less than the keysize.
452 \fBFrom a key file\fR: It will be cropped to the size given by \-s.
453 If there is insufficient key material in the key file, cryptsetup
454 will quit with an error.
456 If \-\-key-file=- is used for reading the key from stdin, no
457 trailing newline is stripped from the input. Without that option,
458 cryptsetup strips trailing newlines from stdin input.
459 .SH NOTES ON PASSWORD PROCESSING FOR LUKS
460 LUKS uses PBKDF2 to protect against dictionary attacks (see RFC 2898).
462 LUKS will always do an exhaustive password reading.
463 Hence, password can not be read from /dev/random, /dev/zero or any
464 other stream that does not terminate.
465 To prevent exhausting of system memory, cryptsetup limits
466 maximum key file size. Compiled-in default is displayed in \-\-help
467 output. You can limit reads from key file using \-\-key-size option,
468 this option takes precedence over compiled-in default.
470 For any password creation action (luksAddKey, or luksFormat),
471 the user may specify how much the time the password processing
472 should consume. Increasing the time will lead to a more secure
473 password, but also will take luksOpen longer to complete.
474 The default setting of one second is sufficient for good security.
475 .SH INCOHERENT BEHAVIOUR FOR INVALID PASSWORDS/KEYS
476 LUKS checks for a valid password or key when an encrypted partition
477 is unlocked. Thus the luksOpen action fails with invalid password
478 or key, contrary to the plain dm-crypt create action.
480 Please also be sure that you are using the same keyboard and
481 language setting as during device format.
482 .SH NOTES ON SUPPORTED CIPHERS, MODES, HASHES AND KEY SIZES
483 The available combinations of ciphers, modes, hashes and key sizes
484 depend on kernel support. See /proc/crypto for a list of available
485 options. You might need to load additional kernel crypto modules
486 in order to get more options.
488 For \-\-hash option all algorithms supported by gcrypt library are available.
489 .SH NOTES ON PASSWORDS
490 Mathematics can't be bribed. Make sure you keep your passwords safe.
491 There are a few nice tricks for constructing a fallback, when suddenly
492 out of (or after being) blue, your brain refuses to cooperate.
493 These fallbacks are possible with LUKS, as it's only possible with LUKS
494 to have multiple passwords.
496 Random Number Generator (RNG) used in cryptsetup always uses kernel RNG without
497 any modifications or additions to data stream procudes by kernel (like internal
498 random pool operations or mixing with the other random sources).
500 There are two types of randomness cryptsetup/LUKS needs. One type (which always
501 uses /dev/urandom) is used for salt, AF splitter and for wiping removed
504 Second type is used for volume (master) key. You can switch between
505 using /dev/random and /dev/urandom here, see \fP\-\-use-random\fR and \fP\-\-use-urandom\fR
506 options. Using /dev/random on system without enough entropy sources
507 can cause \fPluksFormat\fR to block until the requested amount of random data is gathered.
508 See \fPurandom(4)\fR for more information.
509 .SH NOTES ON LOOPBACK DEVICE USE
510 Cryptsetup is usually used directly over block device (like disk partition or LVM volume).
511 However if the device argument is file, cryptsetup tries to allocate loopback device
512 and map it into this file. This mode requires Linux kernel 2.6.25 or more recent which
513 supports loop autoclear flag (loop device is cleared on last close automatically).
515 When device mapping is active, you can see loop backing file in status command output.
518 cryptsetup is written by Christophe Saout <christophe@saout.de>
520 LUKS extensions, and man page by Clemens Fruhwirth <clemens@endorphin.org>
521 .SH DEPRECATED ACTIONS
523 The \fIreload\fR action is no longer supported.
524 Please use \fIdmsetup(8)\fR if you need to
525 directly manipulate with the device mapping table.
527 The \fIluksDelKey\fR was replaced with \fIluksKillSlot\fR.
530 Report bugs to <dm-crypt@saout.de> or Issues section on LUKS website.
531 Please attach output of failed command with added \-\-debug option.
533 Copyright \(co 2004 Christophe Saout
535 Copyright \(co 2004-2006 Clemens Fruhwirth
537 Copyright \(co 2009-2011 Red Hat, Inc.
539 This is free software; see the source for copying conditions. There is NO
540 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
542 LUKS website, \fBhttp://code.google.com/p/cryptsetup/\fR