'\" t .\" Title: cryptsetup .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.23 .\" Date: 2024-09-02 .\" Manual: Maintenance Commands .\" Source: cryptsetup 2.7.5 .\" Language: English .\" .TH "CRYPTSETUP" "8" "2024-09-02" "cryptsetup 2.7.5" "Maintenance Commands" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 .nh .ad l .de URL \fI\\$2\fP <\\$1>\\$3 .. .als MTO URL .if \n[.g] \{\ . mso www.tmac . am URL . ad l . . . am MTO . ad l . . . LINKSTYLE blue R < > .\} .SH "NAME" cryptsetup \- manage plain dm\-crypt, LUKS, and other encrypted volumes .SH "SYNOPSIS" .sp \fBcryptsetup [] \fP .SH "DESCRIPTION" .sp cryptsetup is used to conveniently setup dm\-crypt managed device\-mapper mappings. These include plain dm\-crypt volumes and LUKS volumes. The difference is that LUKS uses a metadata header and can hence offer more features than plain dm\-crypt. On the other hand, the header is visible and vulnerable to damage. .sp In addition, cryptsetup provides limited support for the use of loop\-AES volumes, TrueCrypt, VeraCrypt, BitLocker and FileVault2 compatible volumes, and for hardware\-based encryption on OPAL capable drives. .sp For more information about specific cryptsetup action see \fBcryptsetup\-\fP(8), where \fB\fP is the name of the cryptsetup action. .SH "BASIC ACTIONS" .sp The following are valid actions for all supported device types. .SS "OPEN" .sp \fBopen \-\-type \fP .sp Opens (creates a mapping with) backed by device . .br See \fBcryptsetup\-open\fP(8). .SS "CLOSE" .sp \fBclose \fP .sp Removes the existing mapping and wipes the key from kernel memory. .br See \fBcryptsetup\-close\fP(8). .SS "STATUS" .sp \fBstatus \fP .sp Reports the status for the mapping . .br See \fBcryptsetup\-status\fP(8). .SS "RESIZE" .sp \fBresize \fP .sp Resizes an active mapping . .br See \fBcryptsetup\-resize\fP(8). .SS "REFRESH" .sp \fBrefresh \fP .sp Refreshes parameters of active mapping . .br See \fBcryptsetup\-refresh\fP(8). .SS "REENCRYPT" .sp \fBreencrypt or \-\-active\-name []\fP .sp Run LUKS device reencryption. .br See \fBcryptsetup\-reencrypt\fP(8). .SH "PLAIN MODE" .sp Plain dm\-crypt encrypts the device sector\-by\-sector with a single, non\-salted hash of the passphrase. No checks are performed, no metadata is used. There is no formatting operation. When the raw device is mapped (opened), the usual device operations can be used on the mapped device, including filesystem creation. Mapped devices usually reside in /dev/mapper/. .sp The following are valid plain device type actions: .SS "OPEN" .sp \fBopen \-\-type plain \fP .br create (\fBOBSOLETE syntax\fP) .sp Opens (creates a mapping with) backed by device . .br See \fBcryptsetup\-open\fP(8). .SH "LUKS EXTENSION" .sp LUKS, the Linux Unified Key Setup, is a standard for disk encryption. It adds a standardized header at the start of the device, a key\-slot area directly behind the header and the bulk data area behind that. The whole set is called a \*(AqLUKS container\*(Aq. The device that a LUKS container resides on is called a \*(AqLUKS device\*(Aq. For most purposes, both terms can be used interchangeably. But note that when the LUKS header is at a nonzero offset in a device, then the device is not a LUKS device anymore, but has a LUKS container stored in it at an offset. .sp LUKS can manage multiple passphrases that can be individually revoked or changed and that can be securely scrubbed from persistent media due to the use of anti\-forensic stripes. Passphrases are protected against brute\-force and dictionary attacks by Password\-Based Key Derivation Function (PBKDF). .sp LUKS2 is a new version of header format that allows additional extensions like different PBKDF algorithm or authenticated encryption. You can format device with LUKS2 header if you specify \fB\-\-type luks2\fP in \fBluksFormat\fP command. For activation, the format is already recognized automatically. .sp Each passphrase, also called a \fBkey\fP in this document, is associated with one of 8 key\-slots. Key operations that do not specify a slot affect the first slot that matches the supplied passphrase or the first empty slot if a new passphrase is added. .sp The \fB\fP parameter can also be specified by a LUKS UUID in the format UUID=. Translation to real device name uses symlinks in /dev/disk/by\-uuid directory. .sp To specify a detached header, the \fB\-\-header\fP parameter can be used in all LUKS commands and always takes precedence over the positional \fB\fP parameter. .sp The following are valid LUKS actions: .SS "FORMAT" .sp \fBluksFormat []\fP .sp Initializes a LUKS partition and sets the initial passphrase (for key\-slot 0). .br See \fBcryptsetup\-luksFormat\fP(8). .SS "OPEN" .sp \fBopen \-\-type luks \fP .br luksOpen (\fBold syntax\fP) .sp Opens the LUKS device and sets up a mapping after successful verification of the supplied passphrase. .br See \fBcryptsetup\-open\fP(8). .SS "SUSPEND" .sp \fBluksSuspend \fP .sp Suspends an active device (all IO operations will block and accesses to the device will wait indefinitely) and wipes the encryption key from kernel memory. .br See \fBcryptsetup\-luksSuspend\fP(8). .SS "RESUME" .sp \fBluksResume \fP .sp Resumes a suspended device and reinstates the encryption key. .br See \fBcryptsetup\-luksResume\fP(8). .SS "ADD KEY" .sp \fBluksAddKey []\fP .sp Adds a new passphrase using an existing passphrase. .br See \fBcryptsetup\-luksAddKey\fP(8). .SS "REMOVE KEY" .sp \fBluksRemoveKey []\fP .sp Removes the supplied passphrase from the LUKS device. .br See \fBcryptsetup\-luksRemoveKey\fP(8). .SS "CHANGE KEY" .sp \fBluksChangeKey []\fP .sp Changes an existing passphrase. .br See \fBcryptsetup\-luksChangeKey\fP(8). .SS "CONVERT KEY" .sp \fBluksConvertKey \fP .sp Converts an existing LUKS2 keyslot to new PBKDF parameters. .br See \fBcryptsetup\-luksConvertKey\fP(8). .SS "KILL SLOT" .sp \fBluksKillSlot \fP .sp Wipe the key\-slot number from the LUKS device. .br See \fBcryptsetup\-luksKillSlot\fP(8). .SS "ERASE" .sp \fBerase \fP .br luksErase (\fBold syntax\fP) .sp Erase all keyslots and make the LUKS container permanently inaccessible. .br See \fBcryptsetup\-erase\fP(8). .SS "UUID" .sp \fBluksUUID \fP .sp Print or set the UUID of a LUKS device. .br See \fBcryptsetup\-luksUUID\fP(8). .SS "IS LUKS" .sp \fBisLuks \fP .sp Returns true, if is a LUKS device, false otherwise. .br See \fBcryptsetup\-isLuks\fP(8). .SS "DUMP" .sp \fBluksDump \fP .sp Dump the header information of a LUKS device. .br See \fBcryptsetup\-luksDump\fP(8). .SS "HEADER BACKUP" .sp \fBluksHeaderBackup \-\-header\-backup\-file \fP .sp Stores a binary backup of the LUKS header and keyslot area. .br See \fBcryptsetup\-luksHeaderBackup\fP(8). .SS "HEADER RESTORE" .sp \fBluksHeaderRestore \-\-header\-backup\-file \fP .sp Restores a binary backup of the LUKS header and keyslot area from the specified file. .br See \fBcryptsetup\-luksHeaderRestore\fP(8). .SS "TOKEN" .sp \fBtoken \fP .sp Manipulate token objects used for obtaining passphrases. .br See \fBcryptsetup\-token\fP(8). .SS "CONVERT" .sp \fBconvert \-\-type \fP .sp Converts the device between LUKS1 and LUKS2 format (if possible). .br See \fBcryptsetup\-convert\fP(8). .SS "CONFIG" .sp \fBconfig \fP .sp Set permanent configuration options (store to LUKS header). .br See \fBcryptsetup\-config\fP(8). .SH "LOOP\-AES EXTENSION" .sp cryptsetup supports mapping loop\-AES encrypted partition using a compatibility mode. .SS "OPEN" .sp \fBopen \-\-type loopaes \-\-key\-file \fP .br loopaesOpen \-\-key\-file (\fBold syntax\fP) .sp Opens the loop\-AES and sets up a mapping . .br See \fBcryptsetup\-open\fP(8). .sp See also section 7 of the FAQ and \c .URL "http://loop\-aes.sourceforge.net" "loop\-AES" for more information regarding loop\-AES. .SH "TCRYPT (TRUECRYPT AND VERACRYPT COMPATIBLE) EXTENSION" .sp cryptsetup supports mapping of TrueCrypt, tcplay or VeraCrypt encrypted partition using a native Linux kernel API. Header formatting and TCRYPT header change is not supported, cryptsetup never changes TCRYPT header on\-device. .sp TCRYPT extension requires kernel userspace crypto API to be available (introduced in Linux kernel 2.6.38). If you are configuring kernel yourself, enable "User\-space interface for symmetric key cipher algorithms" in "Cryptographic API" section (CRYPTO_USER_API_SKCIPHER .config option). .sp Because TCRYPT header is encrypted, you have to always provide valid passphrase and keyfiles. .sp Cryptsetup should recognize all header variants, except legacy cipher chains using LRW encryption mode with 64 bits encryption block (namely Blowfish in LRW mode is not recognized, this is limitation of kernel crypto API). .sp VeraCrypt is extension of TrueCrypt header with increased iteration count so unlocking can take quite a lot of time. .sp To open a VeraCrypt device with a custom Personal Iteration Multiplier (PIM) value, use either the \fB\-\-veracrypt\-pim=\fP option to directly specify the PIM on the command\- line or use \fB\-\-veracrypt\-query\-pim\fP to be prompted for the PIM. .sp The PIM value affects the number of iterations applied during key derivation. Please refer to \c .URL "https://www.veracrypt.fr/en/Personal%20Iterations%20Multiplier%20%28PIM%29.html" "PIM" for more detailed information. .sp If you need to disable VeraCrypt device support, use \fB\-\-disable\-veracrypt\fP option. .sp \fBNOTE:\fP Activation with \fBtcryptOpen\fP is supported only for cipher chains using LRW or XTS encryption modes. .sp The \fBtcryptDump\fP command should work for all recognized TCRYPT devices and doesn\(cqt require superuser privilege. .sp To map system device (device with boot loader where the whole encrypted system resides) use \fB\-\-tcrypt\-system\fP option. You can use partition device as the parameter (parameter must be real partition device, not an image in a file), then only this partition is mapped. .sp If you have the whole TCRYPT device as a file image and you want to map multiple partition encrypted with system encryption, please create loopback mapping with partitions first (\fBlosetup \-P\fP, see \fBlosetup(8)\fP man page for more info), and use loop partition as the device parameter. .sp If you use the whole base device as a parameter, one device for the whole system encryption is mapped. This mode is available only for backward compatibility with older cryptsetup versions which mapped TCRYPT system encryption using the whole device. .sp To use hidden header (and map hidden device, if available), use \fB\-\-tcrypt\-hidden\fP option. .sp To explicitly use backup (secondary) header, use \fB\-\-tcrypt\-backup\fP option. .sp \fBNOTE:\fP There is no protection for a hidden volume if the outer volume is mounted. The reason is that if there were any protection, it would require some metadata describing what to protect in the outer volume and the hidden volume would become detectable. .SS "OPEN" .sp \fBopen \-\-type tcrypt \fP .br tcryptOpen_ (\fBold syntax\fP) .sp Opens the TCRYPT (a TrueCrypt\-compatible) and sets up a mapping . .br See \fBcryptsetup\-open\fP(8). .SS "DUMP" .sp \fBtcryptDump \fP .sp Dump the header information of a TCRYPT device. .br See \fBcryptsetup\-tcryptDump\fP(8). .sp See also \c .URL "https://en.wikipedia.org/wiki/TrueCrypt" "\fBTrueCrypt\fP" "" and .URL "https://en.wikipedia.org/wiki/VeraCrypt" "\fBVeraCrypt\fP" "" pages for more information. .sp Please note that cryptsetup does not use TrueCrypt or VeraCrypt code, please report all problems related to this compatibility extension to the cryptsetup project. .SH "BITLK (WINDOWS BITLOCKER COMPATIBLE) EXTENSION" .sp cryptsetup supports mapping of BitLocker and BitLocker to Go encrypted partition using a native Linux kernel API. Header formatting and BITLK header changes are not supported, cryptsetup never changes BITLK header on\-device. .sp BITLK extension requires kernel userspace crypto API to be available (for details see TCRYPT section). .sp Cryptsetup should recognize all BITLK header variants, except legacy header used in Windows Vista systems and partially decrypted BitLocker devices. Activation of legacy devices encrypted in CBC mode requires at least Linux kernel version 5.3 and for devices using Elephant diffuser kernel 5.6. .sp The \fBbitlkDump\fP command should work for all recognized BITLK devices and doesn\(cqt require superuser privilege. .sp For unlocking with the \fBopen\fP a password or a recovery passphrase or a startup key must be provided. .sp Additionally unlocking using volume key is supported. You must provide BitLocker Full Volume Encryption Key (FVEK) using the \-\-volume\-key\-file option. The key must be decrypted and without the header (only 128/256/512 bits of key data depending on used cipher and mode). .sp Other unlocking methods (TPM, SmartCard) are not supported. .SS "OPEN" .sp \fBopen \-\-type bitlk \fP .br bitlkOpen (\fBold syntax\fP) .sp Opens the BITLK (a BitLocker\-compatible) and sets up a mapping . .br See \fBcryptsetup\-open\fP(8). .SS "DUMP" .sp \fBbitlkDump \fP .sp Dump the header information of a BITLK device. .br See \fBcryptsetup\-bitlkDump\fP(8). .sp Please note that cryptsetup does not use any Windows BitLocker code, please report all problems related to this compatibility extension to the cryptsetup project. .SH "FVAULT2 (APPLE MACOS FILEVAULT2 COMPATIBLE) EXTENSION" .sp cryptsetup supports the mapping of FileVault2 (FileVault2 full\-disk encryption) by Apple for the macOS operating system using a native Linux kernel API. .sp \fBNOTE:\fP cryptsetup supports only FileVault2 based on Core Storage and HFS+ filesystem (introduced in MacOS X 10.7 Lion). It does NOT support the new version of FileVault based on the APFS filesystem used in recent macOS versions. .sp Header formatting and FVAULT2 header changes are not supported; cryptsetup never changes the FVAULT2 header on\-device. .sp FVAULT2 extension requires kernel userspace crypto API to be available (for details, see TCRYPT section) and kernel driver for HFS+ (hfsplus) filesystem. .sp Cryptsetup should recognize the basic configuration for portable drives. .sp The \fBfvault2Dump\fP command should work for all recognized FVAULT2 devices and doesn\(cqt require superuser privilege. .sp For unlocking with the \fBopen\fP, a password must be provided. Other unlocking methods are not supported. .SS "OPEN" .sp \fBopen \-\-type fvault2 \fP .br fvault2Open (\fBold syntax\fP) .sp Opens the FVAULT2 (a FileVault2\-compatible) (usually the second partition on the device) and sets up a mapping . .br See \fBcryptsetup\-open\fP(8). .SH "SED (SELF ENCRYPTING DRIVE) OPAL EXTENSION" .sp cryptsetup supports using native hardware encryption on drives that provide an \fBOPAL\fP interface, both nested with \fBdm\-crypt\fP and standalone. Passphrases, tokens and metadata are stored using the LUKS2 header format, and are thus compatible with any software or system that uses LUKS2 (e.g.: tokens). .sp \fBWARNING:\fP this support is new and experimental, and requires at least kernel v6.4. Resizing devices is not supported. .sp \fB\-\-hw\-opal\fP can be specified for OPAL + dm\-crypt, and \fB\-\-hw\-opal\-only\fP can be specified to use OPAL only, without a dm\-crypt layer. .sp Opening, closing and enrolling tokens work in the same way as with LUKS2 and dm\-crypt. The new parameters are only necessary when formatting, the LUKS2 metadata will ensure the right setup is performed when opening or closing. If no \fBsubsystem\fP is specified, it will be automatically set to \fBHW\-OPAL\fP so that it is immediately apparent when a device uses OPAL. .SS "FORMAT" .sp \fBluksFormat \-\-type luks2 \-\-hw\-opal []\fP .sp Additionally specify \fB\-\-hw\-opal\-only\fP instead of \fB\-\-hw\-opal\fP to avoid the dm\-crypt layer. Other than the usual passphrase, an admin password will have to be specified when formatting the first partition of the drive, and will have to be re\-supplied when formatting any other partition until a factory reset is performed. .SS "ERASE" .sp \fBerase \fP .sp Securely erase a partition or device. Requires admin password. Additionally specify \fB\-\-hw\-opal\-factory\-reset\fP for a FULL factory reset of the drive, using the drive\(cqs \fBPSID\fP (typically printed on the label) instead of the admin password. \fBWARNING\fP: a factory reset will cause ALL data on the device to be lost, regardless of the partition it is ran on, if any, and regardless of any LUKS2 header backup. .SH "MISCELLANEOUS ACTIONS" .SS "REPAIR" .sp \fBrepair \fP .sp Tries to repair the device metadata if possible. Currently supported only for LUKS device type. .br See \fBcryptsetup\-repair\fP(8). .SS "BENCHMARK" .sp \fBbenchmark \fP .sp Benchmarks ciphers and KDF (key derivation function). .br See \fBcryptsetup\-benchmark\fP(8). .SH "PLAIN DM\-CRYPT OR LUKS?" .sp Unless you understand the cryptographic background well, use LUKS. With plain dm\-crypt there are a number of possible user errors that massively decrease security. While LUKS cannot fix them all, it can lessen the impact for many of them. .SH "WARNINGS" .sp A lot of good information on the risks of using encrypted storage, on handling problems and on security aspects can be found in the Cryptsetup FAQ. Read it. Nonetheless, some risks deserve to be mentioned here. .sp \fBBackup:\fP Storage media die. Encryption has no influence on that. Backup is mandatory for encrypted data as well, if the data has any worth. See the Cryptsetup FAQ for advice on how to do a backup of an encrypted volume. .sp \fBCharacter encoding:\fP If you enter a passphrase with special symbols, the passphrase can change depending on character encoding. Keyboard settings can also change, which can make blind input hard or impossible. For example, switching from some ASCII 8\-bit variant to UTF\-8 can lead to a different binary encoding and hence different passphrase seen by cryptsetup, even if what you see on the terminal is exactly the same. It is therefore highly recommended to select passphrase characters only from 7\-bit ASCII, as the encoding for 7\-bit ASCII stays the same for all ASCII variants and UTF\-8. .sp \fBLUKS header:\fP If the header of a LUKS volume gets damaged, all data is permanently lost unless you have a header\-backup. If a key\-slot is damaged, it can only be restored from a header\-backup or if another active key\-slot with known passphrase is undamaged. Damaging the LUKS header is something people manage to do with surprising frequency. This risk is the result of a trade\-off between security and safety, as LUKS is designed for fast and secure wiping by just overwriting header and key\-slot area. .sp \fBPreviously used partitions:\fP If a partition was previously used, it is a very good idea to wipe filesystem signatures, data, etc. before creating a LUKS or plain dm\-crypt container on it. For a quick removal of filesystem signatures, use \fBwipefs\fP(8). Take care though that this may not remove everything. In particular, MD RAID signatures at the end of a device may survive. It also does not remove data. For a full wipe, overwrite the whole partition before container creation. If you do not know how to do that, the cryptsetup FAQ describes several options. .SH "EXAMPLES" .sp Example 1: Create LUKS 2 container on block device /dev/sdX. .RS 4 sudo cryptsetup \-\-type luks2 luksFormat /dev/sdX .RE .sp Example 2: Add an additional passphrase to key slot 5. .RS 4 sudo cryptsetup luksAddKey \-\-key\-slot 5 /dev/sdX .RE .sp Example 3: Create LUKS header backup and save it to file. .RS 4 sudo cryptsetup luksHeaderBackup /dev/sdX \-\-header\-backup\-file /var/tmp/NameOfBackupFile .RE .sp Example 4: Open LUKS container on /dev/sdX and map it to sdX_crypt. .RS 4 sudo cryptsetup open /dev/sdX sdX_crypt .RE .sp \fBWARNING: The command in example 5 will erase all key slots.\fP .RS 4 Your cannot use your LUKS container afterward anymore unless you have a backup to restore. .RE .sp Example 5: Erase all key slots on /dev/sdX. .RS 4 sudo cryptsetup erase /dev/sdX .RE .sp Example 6: Restore LUKS header from backup file. .RS 4 sudo cryptsetup luksHeaderRestore /dev/sdX \-\-header\-backup\-file /var/tmp/NameOfBackupFile .RE .SH "RETURN CODES" .sp Cryptsetup returns \fB0\fP on success and a non\-zero value on error. .sp Error codes are: \fB1\fP wrong parameters, \fB2\fP no permission (bad passphrase), \fB3\fP out of memory, \fB4\fP wrong device specified, \fB5\fP device already exists or device is busy. .SH "NOTES" .SS "Passphrase processing for PLAIN mode" .sp Note that no iterated hashing or salting is done in plain mode. If hashing is done, it is a single direct hash. This means that low\-entropy passphrases are easy to attack in plain mode. .sp \fBFrom a terminal\fP: The passphrase is read until the first newline, i.e. \*(Aq\(rsn\*(Aq. The input without the newline character is processed with the default hash or the hash specified with \-\-hash. The hash result will be truncated to the key size of the used cipher, or the size specified with \-s. .sp \fBFrom stdin\fP: Reading will continue until a newline (or until the maximum input size is reached), with the trailing newline stripped. The maximum input size is defined by the same compiled\-in default as for the maximum key file size and can be overwritten using \-\-keyfile\-size option. .sp The data read will be hashed with the default hash or the hash specified with \-\-hash. The hash result will be truncated to the key size of the used cipher, or the size specified with \-s. .sp Note that if \-\-key\-file=\- is used for reading the key from stdin, trailing newlines are not stripped from the input. .sp If "plain" is used as argument to \-\-hash, the input data will not be hashed. Instead, it will be zero padded (if shorter than the key size) or truncated (if longer than the key size) and used directly as the binary key. This is useful for directly specifying a binary key. No warning will be given if the amount of data read from stdin is less than the key size. .sp \fBFrom a key file\fP: It will be truncated to the key size of the used cipher or the size given by \-s and directly used as a binary key. .sp \fBWARNING\fP: The \-\-hash argument is being ignored. The \-\-hash option is usable only for stdin input in plain mode. .sp If the key file is shorter than the key, cryptsetup will quit with an error. The maximum input size is defined by the same compiled\-in default as for the maximum key file size and can be overwritten using \-\-keyfile\-size option. .SS "Passphrase processing for LUKS" .sp LUKS uses PBKDF to protect against dictionary attacks and to give some protection to low\-entropy passphrases (see cryptsetup FAQ). .sp \fBFrom a terminal\fP: The passphrase is read until the first newline and then processed by PBKDF2 without the newline character. .sp \fBFrom stdin\fP: LUKS will read passphrases from stdin up to the first newline character or the compiled\-in maximum key file length. If \-\-keyfile\-size is given, it is ignored. .sp \fBFrom key file\fP: The complete keyfile is read up to the compiled\-in maximum size. Newline characters do not terminate the input. The \-\-keyfile\-size option can be used to limit what is read. .sp \fBPassphrase processing\fP: Whenever a passphrase is added to a LUKS header (luksAddKey, luksFormat), the user may specify how much the time the passphrase processing should consume. The time is used to determine the iteration count for PBKDF2 and higher times will offer better protection for low\-entropy passphrases, but open will take longer to complete. For passphrases that have entropy higher than the used key length, higher iteration times will not increase security. .sp The default setting of one or two seconds is sufficient for most practical cases. The only exception is a low\-entropy passphrase used on a device with a slow CPU, as this will result in a low iteration count. On a slow device, it may be advisable to increase the iteration time using the \-\-iter\-time option in order to obtain a higher iteration count. This does slow down all later luksOpen operations accordingly. .SS "Incoherent behavior for invalid passphrases/keys" .sp LUKS checks for a valid passphrase when an encrypted partition is unlocked. The behavior of plain dm\-crypt is different. It will always decrypt with the passphrase given. If the given passphrase is wrong, the device mapped by plain dm\-crypt will essentially still contain encrypted data and will be unreadable. .SS "Supported ciphers, modes, hashes and key sizes" .sp 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. .sp For the \-\-hash option, if the crypto backend is libgcrypt, then all algorithms supported by the gcrypt library are available. For other crypto backends, some algorithms may be missing. .SS "Notes on passphrases" .sp Mathematics can\(cqt be bribed. Make sure you keep your passphrases safe. There are a few nice tricks for constructing a fallback, when suddenly out of the blue, your brain refuses to cooperate. These fallbacks need LUKS, as it\(cqs only possible with LUKS to have multiple passphrases. Still, if your attacker model does not prevent it, storing your passphrase in a sealed envelope somewhere may be a good idea as well. .SS "Notes on Random Number Generators" .sp Random Number Generators (RNG) used in cryptsetup are always the kernel RNGs without any modifications or additions to data stream produced. .sp There are two types of randomness cryptsetup/LUKS needs. One type (which always uses /dev/urandom) is used for salts, the AF splitter and for wiping deleted keyslots. .sp The second type is used for the volume key. You can switch between using /dev/random and /dev/urandom here, see \fB\-\-use\-random\fP and \fB\-\-use\-urandom\fP options. Using /dev/random on a system without enough entropy sources can cause \fBluksFormat\fP to block until the requested amount of random data is gathered. In a low\-entropy situation (embedded system), this can take a very long time and potentially forever. At the same time, using /dev/urandom in a low\-entropy situation will produce low\-quality keys. This is a serious problem, but solving it is out of scope for a mere man\-page. See \fBurandom(4)\fP for more information. .SS "Authenticated disk encryption (EXPERIMENTAL)" .sp Since Linux kernel version 4.12 dm\-crypt supports authenticated disk encryption. .sp Normal disk encryption modes are length\-preserving (plaintext sector is of the same size as a ciphertext sector) and can provide only confidentiality protection, but not cryptographically sound data integrity protection. .sp Authenticated modes require additional space per\-sector for authentication tag and use Authenticated Encryption with Additional Data (AEAD) algorithms. .sp If you configure LUKS2 device with data integrity protection, there will be an underlying dm\-integrity device, which provides additional per\-sector metadata space and also provide data journal protection to ensure atomicity of data and metadata update. Because there must be additional space for metadata and journal, the available space for the device will be smaller than for length\-preserving modes. .sp The dm\-crypt device then resides on top of such a dm\-integrity device. All activation and deactivation of this device stack is performed by cryptsetup, there is no difference in using \fBluksOpen\fP for integrity protected devices. If you want to format LUKS2 device with data integrity protection, use \fB\-\-integrity\fP option (see \fBcryptsetup\-luksFormat(8)\fP). .sp Albeit Linux kernel 5.7 added TRIM support for standalone dm\-integrity devices, \fBcryptsetup(8)\fP can\(cqt offer support for discards (TRIM) in authenticated encryption mode, because the underlying dm\-crypt kernel module does not support this functionality when dm\-integrity is used as auth tag space allocator (see \fB\-\-allow\-discards\fP in \fBcryptsetup\-luksFormat(8)\fP). .sp Some integrity modes requires two independent keys (key for encryption and for authentication). Both these keys are stored in one LUKS keyslot. .sp \fBWARNING:\fP All support for authenticated modes is experimental and there are only some modes available for now. Note that there are a very few authenticated encryption algorithms that are suitable for disk encryption. You also cannot use CRC32 or any other non\-cryptographic checksums (other than the special integrity mode "none"). If for some reason you want to have integrity control without using authentication mode, then you should separately configure dm\-integrity independently of LUKS2. .SS "Notes on loopback device use" .sp Cryptsetup is usually used directly on a block device (disk partition or LVM volume). However, if the device argument is a file, cryptsetup tries to allocate a loopback device and map it into this file. This mode requires Linux kernel 2.6.25 or more recent which supports the loop autoclear flag (loop device is cleared on the last close automatically). Of course, you can always map a file to a loop\-device manually. See the cryptsetup FAQ for an example. .sp When device mapping is active, you can see the loop backing file in the status command output. Also see losetup(8). .SS "LUKS2 header locking" .sp The LUKS2 on\-disk metadata is updated in several steps and to achieve proper atomic update, there is a locking mechanism. For an image in file, code uses \fBflock(2)\fP system call. For a block device, lock is performed over a special file stored in a locking directory (by default \fB/run/cryptsetup\fP). The locking directory should be created with the proper security context by the distribution during the boot\-up phase. Only LUKS2 uses locks, other formats do not use this mechanism. .SS "LUKS on\-disk format specification" .sp For LUKS on\-disk metadata specification see .URL "https://gitlab.com/cryptsetup/cryptsetup/wikis/Specification" "\fBLUKS1\fP" "" and .URL "https://gitlab.com/cryptsetup/LUKS2\-docs" "\fBLUKS2\fP" "." .SH "AUTHORS" .sp Cryptsetup is originally written by \c .MTO "jana\(atsaout.de" "Jana Saout" "." .br The LUKS extensions and original man page were written by .MTO "clemens\(atendorphin.org" "Clemens Fruhwirth" "." .br Man page extensions by \c .MTO "gmazyland\(atgmail.com" "Milan Broz" "." .br Man page rewrite and extension by \c .MTO "arno\(atwagner.name" "Arno Wagner" "." .SH "REPORTING BUGS" .sp Report bugs at \c .MTO "cryptsetup\(atlists.linux.dev" "\fBcryptsetup mailing list\fP" or in \c .URL "https://gitlab.com/cryptsetup/cryptsetup/\-/issues/new" "\fBIssues project section\fP" "." .sp Please attach output of the failed command with \-\-debug option added. .SH "SEE ALSO" .sp .URL "https://gitlab.com/cryptsetup/cryptsetup/wikis/FrequentlyAskedQuestions" "\fBCryptsetup FAQ\fP" "" .sp \fBcryptsetup\fP(8), \fBintegritysetup\fP(8) and \fBveritysetup\fP(8) .SH "CRYPTSETUP" .sp Part of \c .URL "https://gitlab.com/cryptsetup/cryptsetup/" "\fBcryptsetup project\fP" "."