CRYPTSETUP(8) Maintenance Commands CRYPTSETUP(8)
NAME cryptsetup - setup cryptographic volumes for dm-crypt (including LUKS extension)
SYNOPSIS cryptsetup <options> <action> <action args>
DESCRIPTION cryptsetup is used to conveniently setup dm-crypt managed device-mapper mappings. For basic (plain) dm-crypt mappings, there are four opera- tions.
ACTIONS These strings are valid for <action>, followed by their <action args>:
create <name> <device>
creates a mapping with <name> backed by device <device>.
<options> can be [--hash, --cipher, --verify-passphrase, --key- file, --key-size, --offset, --skip, --readonly]
removes an existing mapping <name>.
reports the status for the mapping <name>.
resizes an active mapping <name>.
If --size (in sectors) is not specified, the size of the under- lying block device is used.
LUKS EXTENSION LUKS, Linux Unified Key Setup, is a standard for hard disk encryption. It standardizes a partition header, as well as the format of the bulk data. LUKS can manage multiple passwords, that can be revoked effec- tively and that are protected against dictionary attacks with PBKDF2.
These are valid LUKS actions:
luksFormat <device> [<key file>]
initializes a LUKS partition and sets the initial key, either via prompting or via <key file>.
<options> can be [--cipher, --verify-passphrase, --key-size, --key-slot, --key-file (takes precedence over optional second argument), --keyfile-size, --use-random | --use-urandom, --uuid].
luksOpen <device> <name>
opens the LUKS partition <device> and sets up a mapping <name> after successful verification of the supplied key material (either via key file by --key-file, or via prompting).
<options> can be [--key-file, --keyfile-size, --readonly].
identical to remove.
suspends active device (all IO operations are frozen) and wipes encryption key from kernel. Kernel version 2.6.19 or later is required.
After that operation you have to use luksResume to reinstate encryption key (and resume device) or luksClose to remove mapped device.
WARNING: never try to suspend device where is the cryptsetup binary itself.
Resumes suspended device and reinstates encryption key. You will need provide passphrase identical to luksOpen command (using prompting or key file).
<options> can be [--key-file, --keyfile-size]
luksAddKey <device> [<new key file>]
add a new key file/passphrase. An existing passphrase or key file (via --key-file) must be supplied. The key file with the new material is supplied as a positional argument.
<options> can be [--key-file, --keyfile-size, --new-keyfile- size, --key-slot].
luksRemoveKey <device> [<key file>]
remove supplied key or key file from LUKS device
luksKillSlot <device> <key slot number>
wipe key with number <key slot> from LUKS device. A remaining passphrase or key file (via --key-file) must be supplied.
<options> can be [--key-file, --keyfile-size].
print UUID, if <device> has a LUKS header.
set new UUID if --uuid option is specified.
returns true, if <device> is a LUKS partition. Otherwise, false.
dumps the header information of a LUKS partition.
If --dump-master-key option is used, the volume (master) key is dumped instead of keyslot info. Because this information can be used to access encrypted device without passphrase knowledge (even without LUKS header) use this option very carefully.
Dump with volume key (either printed or stored to file) should be always stored encrypted and on safe place.
LUKS passphrase or key file is required for volume key dump.
<options> can be [--dump-master-key, --key-file, --keyfile- size].
luksHeaderBackup <device> --header-backup-file <file>
Stores binary backup of LUKS header and keyslot areas.
WARNING: Please note that with this backup file (and old passphrase knowledge) you can decrypt data even if old passphrase was wiped from real device.
Also note that anti-forensic splitter is not used during manipu- lation with backup file.
luksHeaderRestore <device> --header-backup-file <file>
Restores binary backup of LUKS header and keyslot areas from specified file.
WARNING: All the keyslot areas are overwritten, only active keyslots form backup file are available after issuing this com- mand.
This command allows restoring header if device do not contain LUKS header or if the master key size and data offset in LUKS header on device match the backup file.
For more information about LUKS, see http://code.google.com/p/crypt- setup/wiki/Specification
OPTIONS --verbose, -v Print more verbose messages.
--debug Run in debug mode with full diagnostic logs.
--hash, -h For create action specifies hash to use for password hashing.
For luksFormat action specifies hash used in LUKS key setup scheme and volume key digest.
WARNING: setting hash other than sha1 causes LUKS device incom- patible with older version of cryptsetup.
The hash string is passed to libgcrypt, so all hash algorithms are supported (for luksFormat algorithm must provide at least 20 byte long hash). Default is set during compilation, compatible values with old version of cryptsetup are "ripemd160" for create action and "sha1" for luksFormat.
Use cryptsetup --help to show defaults.
--cipher, -c set cipher specification string.
Default mode is configurable during compilation, you can see compiled-in default using cryptsetup --help. If not changed, the default is for plain dm-crypt and LUKS mappings "aes-cbc- essiv:sha256".
For pre-2.6.10 kernels, use "aes-plain" as they don t understand the new cipher spec strings. To use ESSIV, use "aes-cbc- essiv:sha256".
For XTS mode, kernel version 2.6.24 or more recent is required. Use "aes-xts-plain" cipher specification and set key size to 256 (or 512) bits (see -s option).
--verify-passphrase, -y query for passwords twice. Useful when creating a (regular) map- ping for the first time, or when running luksFormat.
--key-file, -d use file as key material.
With LUKS, key material supplied in key files via -d are always used for existing passphrases, except in luksFormat action where -d is equivalent to positional key file argument. If you want to set a new key via a key file, you have to use a positional arg to luksAddKey.
If the key file is "-", stdin will be used. With the "-" key file reading will not stop when new line character is detected. See section NOTES ON PASSWORD PROCESSING for more information.
--keyfile-size, -d value Limits read from keyfile to value bytes. Usable together with all comands using key file.
--new-keyfile-size value Limits read from new keyfile to value bytes in luksAddKey when adding new key file. Default is exhaustive read from key file.
--master-key-file Use pre-generated master key stored in file. For luksFormat it allows LUKS header reformatting with the same master key (if all other parameters are the same existing encrypted data remains intact).
For luksAddKey it allows adding new passphrase with only master key knowledge.
--dump-master-key For luksDump it allows LUKS header dump including volume (mas- ter) key. Use with care (this information allows access to device without passphrase knowledge).
See luksDump for more info.
--use-urandom For luksFormat it defines which kernel random number generator will be used for long-term key (volume key).
See NOTES ON RNG for more information. Use cryptsetup --help to show default RNG.
--key-slot, -S For LUKS operations that add key material, this options allows to you specify which key slot is selected for the new key. This option can be used for luksFormat and luksAddKey.
--key-size, -s set key size in bits.
Has to be a multiple of 8 bits. The key size is limited by the used cipher. See output of /proc/crypto for more information. Can be used for create or luksFormat, all other LUKS actions will use key-size specified by the LUKS header. Default is set during compilation, if not changed it is 256 bits.
Use cryptsetup --help to show defaults.
--size, -b force the size of the underlying device in sectors. This option is only relevant for create and resize action.
--offset, -o start offset in the backend device (in 512-byte sectors). This option is only relevant for create action.
--skip, -p how many sectors of the encrypted data to skip at the beginning. This is different from the --offset options with respect to IV calculations. Using --offset will shift the IV calculation by the same negative amount. Hence, if --offset n, sector n will be the first sector on the mapping with IV 0. Using --skip would have resulted in sector n being the first sector also, but with IV n. This option is only relevant for create action.
--readonly set up a read-only mapping.
--iter-time, -i The number of milliseconds to spend with PBKDF2 password pro- cessing. This option is only relevant to the LUKS operations as luksFormat or luksAddKey.
--batch-mode, -q Do not ask for confirmation. Use with care! This option is only relevant for luksFormat, luksAddKey, luksRemoveKey or luksKill- Slot.
--timeout, -t The number of seconds to wait before timeout. This option is relevant every time a password is asked, like create, luksOpen, luksFormat or luksAddKey. It has no effect if used in conjunc- tion with --key-file.
--tries, -T How often the input of the passphrase shall be retried. This option is relevant every time a password is asked, like create, luksOpen, luksFormat or luksAddKey. The default is 3 tries.
--align-payload=value Align payload at a boundary of value 512-byte sectors. This option is relevant for luksFormat. If not specified, cryptsetup tries to use topology info provided by kernel for underlying device to get optimal alignment. If not available (or calcu- lated value is multiple of default) data is by default aligned to 1 MiB boundary (2048 512-byte sectors).
--uuid=UUID Use provided UUID in luksFormat command instead of generating new one or change existing UUID in luksUUID command.
The UUID must be provided in standard UUID format (e.g. 12345678-1234-1234-1234-123456789abc).
--version Show the version.
NOTES ON PASSWORD PROCESSING From a terminal: Password processing is new-line sensitive, meaning the reading will stop after encountering 0 It will process the read mate- rial (without newline) with the default hash or the hash given by --hash. After hashing, it will be cropped to the key size given by -s.
From stdin: Reading will continue until EOF (so using e.g. /dev/random as stdin will not work), with the trailing newline stripped. After that the read data will be hashed with the default hash or the hash given by --hash and the result will be cropped to the keysize given by -s. If "plain" is used as an argument to the hash option, the input data will not be hashed. Instead, it will be zero padded (if shorter than the keysize) or truncated (if longer than the keysize) and used directly as the key. No warning will be given if the amount of data read from stdin is less than the keysize.
From a key file: It will be cropped to the size given by -s. If there is insufficient key material in the key file, cryptsetup will quit with an error.
If --key-file=- is used for reading the key from stdin, no trailing newline is stripped from the input. Without that option, cryptsetup strips trailing newlines from stdin input.
NOTES ON PASSWORD PROCESSING FOR LUKS LUKS uses PBKDF2 to protect against dictionary attacks (see RFC 2898).
LUKS will always do an exhaustive password reading. Hence, password can not be read from /dev/random, /dev/zero or any other stream that does not terminate.
For any password creation action (luksAddKey, or luksFormat), the user may specify how much the time the password processing should consume. Increasing the time will lead to a more secure password, but also will take luksOpen longer to complete. The default setting of one second is sufficient for good security.
INCOHERENT BEHAVIOUR FOR INVALID PASSWORDS/KEYS LUKS checks for a valid password or key when an encrypted partition is unlocked. Thus the luksOpen action fails with invalid password or key, contrary to the plain dm-crypt create action.
Please also be sure that you are using the same keyboard and language setting as during device format.
NOTES ON SUPPORTED CIPHERS, MODES, HASHES AND KEY SIZES The available combinations of ciphers, modes, hashes and key sizes depend on kernel support. See /proc/crypto for a list of available options. You might need to load additional kernel crypto modules in order to get more options.
For --hash option all algorithms supported by gcrypt library are avail- able.
NOTES ON PASSWORDS Mathematics cant be bribed. Make sure you keep your passwords safe. There are a few nice tricks for constructing a fallback, when suddenly out of (or after being) blue, your brain refuses to cooperate. These fallbacks are possible with LUKS, as its only possible with LUKS to have multiple passwords.
NOTES ON RNG Random Number Generator (RNG) used in cryptsetup always uses kernel RNG without any modifications or additions to data stream procudes by ker- nel (like internal random pool operations or mixing with the other ran- dom sources).
There are two types of randomness cryptsetup/LUKS needs. One type (which always uses /dev/urandom) is used for salt, AF splitter and for wiping removed keyslot.
Second type is used for volume (master) key. You can switch between using /dev/random and /dev/urandom here, see --use-random and --use- urandom options. Using /dev/random on system without enough entropy sources can cause luksFormat to block until the requested amount of random data is gathered. See urandom(4) for more information.
AUTHORS cryptsetup is written by Christophe Saout <firstname.lastname@example.org> LUKS extensions, and man page by Clemens Fruhwirth <clemens@endor- phin.org>
DEPRECATED ACTIONS The reload action is no longer supported. Please use dmsetup(8) if you need to directly manipulate with the device mapping table.
The luksDelKey was replaced with luksKillSlot.
REPORTING BUGS Report bugs to <email@example.com> or Issues section on LUKS website. Please attach output of failed command with added --debug option.
COPYRIGHT Copyright © 2004 Christophe Saout Copyright © 2004-2006 Clemens Fruhwirth Copyright © 2009-2010 Red Hat, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
SEE ALSO LUKS website, http://code.google.com/p/cryptsetup/