CRYPTSETUP(8)

๐Ÿ’– CRYPTSETUP(8) ๐Ÿ’–

maintenance commands, but make it cute โœจ

okay bestie, buckle up โ€” this is the cryptsetup(8) manual page and it's a whole journey. ๐Ÿ’…


โœจ NAME โœจ

cryptsetup โ€” the utility for configuring and managing encrypted storage devices. that's it, that's the girl. ๐ŸŽ€


โœจ SYNOPSIS โœจ

cryptsetup <action> [<options>] <action args>

โœจ DESCRIPTION โœจ

So like, Cryptsetup is a utility for configuring and managing full-disk encryption on storage devices. she can encrypt block devices (think hard drives, partitions โ€” the classics) and also containers (disk images that live as regular files, she's versatile ๐Ÿ’…).

When you unlock an encrypted volume, cryptsetup creates a new device mapping that applications can access like any regular storage device. The actual encryption and decryption work? Not her problem โ€” it's performed transparently by the kernel's device-mapper dm-crypt driver. iconic delegation. ๐Ÿ‘‘

Cryptsetup works with two main volume types: plain encrypted volumes and LUKS (Linux Unified Key Setup) volumes. Plain volumes provide basic encryption, while LUKS volumes include a metadata header that enables advanced features like multiple keyslots and key management. And additionally, LUKS can be used to manage hardware-based encryption on OPAL-capable storage drives. the range? unmatched. โœจ

Cryptsetup also provides limited support for volumes created by other encryption systems, including loop-AES, TrueCrypt, VeraCrypt, BitLocker, and FileVault2. (limited, bestie โ€” she's being polite about it ๐Ÿซถ)

For more info about a specific cryptsetup action, see cryptsetup-<action>(8), where <action> is the name of the cryptsetup action.

Cryptsetup devices can be activated during boot through crypttab(5), which is part of systemd(1) or other system init scripts. boot-time glow-up. ๐ŸŒธ


โœจ BASIC ACTIONS โœจ

The following are valid actions for all supported device types. no gatekeeping here. ๐ŸŒˆ

๐Ÿฆ‹ OPEN

open <device> <name> --type <device_type>

Opens (creates a mapping with) <name> backed by device <device>. See cryptsetup-open(8).

๐Ÿฆ‹ CLOSE

close <name>

Removes the existing mapping <name> and wipes the key from kernel memory. See cryptsetup-close(8).

๐Ÿฆ‹ STATUS

status <name>

Reports the status for the mapping <name>. See cryptsetup-status(8).

๐Ÿฆ‹ RESIZE

resize <name>

Resizes an active mapping <name>. See cryptsetup-resize(8).

๐Ÿฆ‹ REFRESH

refresh <name>

Refreshes parameters of active mapping <name>. See cryptsetup-refresh(8).

๐Ÿฆ‹ REENCRYPT

reencrypt <device> or --active-name <name> [<new_name>]

Run LUKS device reencryption. See cryptsetup-reencrypt(8).


โœจ PLAIN MODE โœจ

Plain dm-crypt encrypts the device sector-by-sector with a single, non-salted hash of the passphrase. No checks are performed, and no metadata is used. There is no formatting operation. ngl it's giving minimalist. ๐Ÿ™ˆ

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/<name>.

The following are valid plain device type actions:

๐Ÿฆ‹ OPEN

open --type plain <device> <name>
create <name> <device> (OBSOLETE syntax)

Opens (creates a mapping with) <name> backed by device <device>. See cryptsetup-open(8).

โš ๏ธ heads up: the create <name> <device> syntax is OBSOLETE. it's giving vintage but not in a cute way. ๐Ÿ’€

โœจ LUKS EXTENSION โœจ

LUKS, the Linux Unified Key Setup, is a standard for disk encryption. It adds a standardized header at the start of the device, a keyslot area directly behind the header and the bulk data area behind that. The whole set is called a 'LUKS container'. The device that a LUKS container resides on is called a 'LUKS device'. For most purposes, both terms can be used interchangeably. (yes bestie, she said interchangeably, so don't stress about it ๐Ÿ’œ)

LUKS can manage multiple passphrases that can be individually revoked or changed. Each passphrase uses an individual keyslot containing a volume key for data encryption. Keyslots can be securely scrubbed from persistent media due to the use of anti-forensic stripes (spooky and efficient, we love her ๐Ÿ”ฅ). Passphrases are protected against brute-force attacks by the Password-Based Key Derivation Function (PBKDF). A passphrase stored in a file is called a key file. The only difference between a passphrase and a key file is that a key file can contain binary data. Both are processed the same. โœจ

LUKS version 1 (or LUKS1) is the original metadata format, while LUKS2 is a new version that allows additional extensions like different PBKDF algorithms or authenticated encryption. You can format the device with a specific LUKS version with --type luks1 or --type luks2 in the luksFormat command. Normally, you do not need to specify any version as it is recognized automatically. The default format is LUKS2. ๐Ÿ‘‘

The <device> parameter can also be specified by a LUKS UUID in the format UUID=<uuid>.

The LUKS header can be detached from data (stored separately). To specify a detached header, the --header parameter can be used in all LUKS commands and always takes precedence over the positional <device> parameter.

The following are valid LUKS actions:

๐Ÿฆ‹ FORMAT

luksFormat <device> [<key file>]

Initializes a LUKS partition and sets the initial passphrase (for keyslot 0). See cryptsetup-luksFormat(8).

๐Ÿฆ‹ OPEN

open --type luks <device> <name>
luksOpen <device> <name> (old syntax)

Opens the LUKS device <device> and sets up a mapping <name> after successful verification of the supplied passphrase. See cryptsetup-open(8).

๐Ÿฆ‹ SUSPEND

luksSuspend <name>

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. See cryptsetup-luksSuspend(8).

๐Ÿ˜ญ yes bestie, indefinitely โ€” the IO really does just sit there waiting. plan accordingly.

๐Ÿฆ‹ RESUME

luksResume <name>

Resumes a suspended device and reinstates the encryption key. See cryptsetup-luksResume(8).

๐Ÿฆ‹ ADD KEY

luksAddKey <device> [<key file with new key>]

Adds a new passphrase using an existing passphrase. See cryptsetup-luksAddKey(8).

๐Ÿฆ‹ REMOVE KEY

luksRemoveKey <device> [<key file with passphrase to be removed>]

Removes the supplied passphrase from the LUKS device. See cryptsetup-luksRemoveKey(8).

๐Ÿฆ‹ CHANGE KEY

luksChangeKey <device> [<new key file>]

Changes an existing passphrase. See cryptsetup-luksChangeKey(8).

๐Ÿฆ‹ CONVERT KEY

luksConvertKey <device>

Converts an existing LUKS2 keyslot to new PBKDF parameters. See cryptsetup-luksConvertKey(8).

๐Ÿฆ‹ KILL SLOT

luksKillSlot <device> <number>

Wipe the keyslot with the <number> from the LUKS device. See cryptsetup-luksKillSlot(8).

๐Ÿฆ‹ ERASE

erase <device>
luksErase <device> (old syntax)

Erase all keyslots and make the LUKS container permanently inaccessible. See cryptsetup-erase(8).

๐Ÿ’€ bestie this one is forever. "permanently inaccessible" is not a vibe, it's a fact. no take-backs.

๐Ÿฆ‹ UUID

luksUUID <device>

Print or set the UUID of a LUKS device. See cryptsetup-luksUUID(8).

๐Ÿฆ‹ IS LUKS

isLuks <device>

Returns true, if <device> is a LUKS device, false otherwise. See cryptsetup-isLuks(8).

๐Ÿฆ‹ DUMP

luksDump <device>

Dump the header information of a LUKS device. See cryptsetup-luksDump(8).

๐Ÿฆ‹ HEADER BACKUP

luksHeaderBackup <device> --header-backup-file <file>

Stores a binary backup of the LUKS header and keyslot area. See cryptsetup-luksHeaderBackup(8).

๐Ÿฆ‹ HEADER RESTORE

luksHeaderRestore <device> --header-backup-file <file>

Restores a binary backup of the LUKS header and keyslot area from the specified file. See cryptsetup-luksHeaderRestore(8).

๐Ÿฆ‹ TOKEN

token <add|remove|import|export> <device>

Manipulate token objects used for obtaining passphrases. See cryptsetup-token(8).

๐Ÿฆ‹ CONVERT

convert <device> --type <format>

Converts the device between LUKS1 and LUKS2 format (if possible). See cryptsetup-convert(8).

๐Ÿฆ‹ CONFIG

config <device>

Set permanent configuration options (store to LUKS header). See cryptsetup-config(8).


โœจ LOOP-AES EXTENSION โœจ

Cryptsetup supports mapping a loop-AES encrypted partition using a compatibility mode. retro but make it functional. ๐Ÿงš

๐Ÿฆ‹ OPEN

open --type loopaes <device> <name> --key-file <keyfile>
loopaesOpen <device> <name> --key-file <keyfile> (old syntax)

Opens the loop-AES <device> and sets up a mapping <name>. See cryptsetup-open(8).

See also section 7 of the FAQ and loop-AES http://loop-aes.sourceforge.net for more information regarding loop-AES.


...and that's part 1, bestie โ€” there's more coming, don't go anywhere ๐Ÿ’–

โœจ TCRYPT (TRUECRYPT AND VERACRYPT COMPATIBLE) EXTENSION โœจ

okay so cryptsetup can also map TrueCrypt, tcplay, or VeraCrypt encrypted partitions using a native Linux kernel API. and the vibe here? cryptsetup is a guest, not a host โ€” header formatting and TCRYPT header change are not supported, and cryptsetup never changes the TCRYPT header on-device. it literally will not touch your header, no cap.

the TCRYPT extension needs the kernel userspace crypto API to be available. so if you're the kind of girl who configures her own kernel (iconic honestly), go enable "User-space interface for symmetric key cipher algorithms" in the "Cryptographic API" section โ€” that's the CRYPTO_USER_API_SKCIPHER .config option. ๐Ÿ’…

because the TCRYPT header is encrypted, you must always give a valid passphrase and keyfiles. both. no skipping.

cryptsetup should recognize all header variants, except legacy cipher chains using LRW encryption mode with a 64-bit encryption block (aka: Blowfish in LRW mode is not recognized โ€” that's a limitation of the kernel crypto API, not a cryptsetup thing, so don't come for her ๐Ÿซถ).

VeraCrypt is an extension of TrueCrypt with an increased iteration count, so unlocking can take quite a lot of time. it's giving "go get a snack bestie, this one's thinking."

to open a VeraCrypt device with a custom Personal Iteration Multiplier (PIM) value, use either the --veracrypt-pim PIM option to directly specify the PIM on the command line, or use --veracrypt-query-pim to be prompted for the PIM.

the PIM value affects the number of iterations applied during key derivation. more detail lives over at PIM โ€” https://veracrypt.io/en/Personal%20Iterations%20Multiplier%20(PIM).html โœจ

if you need to disable VeraCrypt device support, use --disable-veracrypt. bye felicia.

activation with tcryptOpen is supported only for cipher chains using LRW or XTS encryption modes. that's the list, periodt.

the tcryptDump command should work for all recognized TCRYPT devices and doesn't require superuser privilege. (no sudo, no problem ๐Ÿ’…)

to map the system device โ€” that's the device with the boot loader where the whole encrypted system resides โ€” use --tcrypt-system. please read the specific info in cryptsetup-tcryptOpen(8) --tcrypt-system option section, because mapping a system-encrypted device is tricky fr fr.

to use a hidden header (and map the hidden device, if available), use --tcrypt-hidden. ๐Ÿซฃ

to explicitly use the backup (secondary) header, use --tcrypt-backup.

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. so yeah, that's a whole trade-off.

๐Ÿ”“ OPEN

open --type tcrypt <device> <name>
tcryptOpen_ <device> <name> (old syntax)

opens the TCRYPT (a TrueCrypt-compatible) <device> and sets up a mapping <name>. see cryptsetup-open(8).

๐Ÿ” DUMP

tcryptDump <device>

dumps the header information of a TCRYPT device. see cryptsetup-tcryptDump(8).

also check out the TrueCrypt page โ€” https://en.wikipedia.org/wiki/TrueCrypt โ€” and the VeraCrypt page โ€” https://en.wikipedia.org/wiki/VeraCrypt โ€” for more info. ๐Ÿ“š

please note that cryptsetup does not use TrueCrypt or VeraCrypt code. please report all problems related to this compatibility extension to the cryptsetup project. (don't yell at the wrong devs bestie, that's rude ๐Ÿ™ˆ)

๐ŸชŸ BITLK (WINDOWS BITLOCKER COMPATIBLE) EXTENSION ๐ŸชŸ

cryptsetup supports mapping of BitLocker and BitLocker to Go encrypted partitions using a native Linux kernel API. and same energy as before: header formatting and BITLK header changes are not supported โ€” cryptsetup never changes the BITLK header on-device. hands off. โœ‹

the BITLK extension requires the kernel userspace crypto API to be available (for details, see the TCRYPT section above โ€” it's the same requirement, go reread it, i'll wait ๐Ÿ’–).

cryptsetup should recognize all BITLK header variants, except the legacy header used in Windows Vista systems and partially decrypted BitLocker devices. activation of legacy devices encrypted in CBC mode requires at least a Linux kernel version 5.3, and for devices using the Elephant diffuser, kernel 5.6. so like, check your kernel version first, that's the vibe check. ๐ŸŒธ

the bitlkDump command should work for all recognized BITLK devices and doesn't require superuser privilege. queen behavior.

for unlocking with the open, a password, a recovery passphrase, or a startup key must be provided. one of those three, or you're not getting in. ๐Ÿšช

additionally, unlocking using the 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 the used cipher and mode). exact numbers, don't improvise. โœจ

other unlocking methods (TPM, SmartCard) are not supported. sorry to the TPM girlies.

๐Ÿ”“ OPEN

open --type bitlk <device> <name>
bitlkOpen <device> <name> (old syntax)

opens the BITLK (a BitLocker-compatible) <device> and sets up a mapping <name>. see cryptsetup-open(8).

๐Ÿ” DUMP

bitlkDump <device>

dumps the header information of a BITLK device. see cryptsetup-bitlkDump(8).

please note that cryptsetup does not use any Windows BitLocker code. please report all problems related to this compatibility extension to the cryptsetup project. ๐Ÿซถ

๐ŸŽ FVAULT2 (APPLE MACOS FILEVAULT2 COMPATIBLE) EXTENSION ๐ŸŽ

cryptsetup supports the mapping of FileVault2 (FileVault2 full-disk encryption) by Apple for the macOS operating system using a native Linux kernel API. yes bestie, your Mac drive, on Linux. it's giving cross-platform icon. ๐Ÿ’…

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. so if you're on a shiny new Mac, that's a no from her. ๐Ÿ˜ญ

header formatting and FVAULT2 header changes are not supported โ€” cryptsetup never changes the FVAULT2 header on-device.

the FVAULT2 extension requires the kernel userspace crypto API to be available (for details, see the TCRYPT section) and a kernel driver for the HFS+ (hfsplus) filesystem. two things. both. ๐Ÿ’–

cryptsetup should recognize the basic configuration for portable drives.

the fvault2Dump command should work for all recognized FVAULT2 devices and doesn't require superuser privilege. โœจ

for unlocking with the open, a password must be provided. other unlocking methods are not supported.

๐Ÿ”“ OPEN

open --type fvault2 <device> <name>
fvault2Open <device> <name> (old syntax)

opens the FVAULT2 (a FileVault2-compatible) <device> (usually the second partition on the device) and sets up a mapping <name>. see cryptsetup-open(8).


๐Ÿ’Ž SED (SELF ENCRYPTING DRIVE) OPAL EXTENSION ๐Ÿ’Ž

cryptsetup supports using native hardware encryption on drives that provide an OPAL interface, both nested with dm-crypt 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). so your tokens still work, you're welcome. ๐ŸŽ€

OPAL support requires at least kernel v6.4. resizing devices is not supported. know that before you try. ๐Ÿ™ˆ

--hw-opal can be specified for OPAL + dm-crypt, and --hw-opal-only can be specified to use OPAL only, without a dm-crypt layer.

opening, closing and enrolling tokens work 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. so you set it up once and she remembers. main character energy. ๐Ÿ‘‘

if no subsystem label is specified, it will be automatically set to HW-OPAL so that it is immediately apparent when a device uses OPAL. cute and self-documenting.

๐Ÿ› ๏ธ FORMAT

luksFormat --type luks2 --hw-opal <device> [<key file>]

additionally specify --hw-opal-only instead of --hw-opal to avoid the dm-crypt layer. other than the usual passphrase, an admin password will have to be specified when formatting the drive's first partition, and will have to be re-supplied when formatting any other partition until a factory reset is performed. yes, remember that password. write it down. you WILL need it again. ๐Ÿ˜ญ

๐Ÿงน ERASE

erase <device>

securely erases a partition or device. requires admin password. additionally specify --hw-opal-factory-reset for a FULL factory reset of the drive, using the drive's PSID (typically printed on the label) instead of the admin password.

PSID must be entered without dashes, spaces or underscores. type it clean, no decoration. ๐Ÿ’…

โš ๏ธ WARNING: a factory reset will cause ALL data on the device to be lost, regardless of the partition it is run on, if any, and regardless of any LUKS2 header backup. โš ๏ธ

๐ŸŽฒ MISCELLANEOUS ACTIONS ๐ŸŽฒ

๐Ÿฉน REPAIR

repair <device>

tries to repair the device metadata if possible. currently supported only for LUKS device type. see cryptsetup-repair(8).

โฑ๏ธ BENCHMARK

benchmark <options>

benchmarks, ciphers and KDF (key derivation function). see cryptsetup-benchmark(8).


๐Ÿค” PLAIN MODE OR LUKS? ๐Ÿค”

unless you understand the cryptographic background well, use LUKS. with plain mode, 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. so like... just use LUKS bestie. it's the safe choice and the safe choice is slay. ๐Ÿ’–


๐Ÿšจ WARNINGS ๐Ÿšจ

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. ๐Ÿ‘‡

  • Backup: 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 back up an encrypted volume. (drives are not immortal and neither are you, back it up ๐Ÿ’€)
  • Character encoding: if you enter a passphrase with special symbols, the passphrase can change depending on character encoding. keyboard settings can also be changed, 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 a 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. (looks the same โ‰  is the same, and that's the trap ๐Ÿ™ˆ)
  • LUKS header: if the header of a LUKS volume gets damaged, all data is permanently lost unless you have a header backup. if a keyslot is damaged, it can only be restored from a header backup or if another active keyslot with a known passphrase is undamaged. 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 the header and keyslot area. (yes it's scary. make the backup. ๐Ÿซถ)
  • Previously used partitions: 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. for a quick removal of filesystem signatures, use wipefs(8) with the --all option. note that it does not remove data; it only invalidates known format signatures. for a full wipe, overwrite the whole partition before creating a container. if you do not know how to do that, the cryptsetup FAQ describes several options. โœจ

๐ŸŽ€ EXAMPLES ๐ŸŽ€

ok so these are the little snack-sized recipes, bestie. copy, paste, thrive ๐Ÿ’…

  1. Example 1: create a LUKS 2 container on the block device /dev/sdX.
sudo cryptsetup --type luks2 luksFormat /dev/sdX
  1. Example 2: add another passphrase to keyslot 5.
sudo cryptsetup luksAddKey --key-slot 5 /dev/sdX
  1. Example 3: make a LUKS header backup and save it to a file.
sudo cryptsetup luksHeaderBackup /dev/sdX --header-backup-file
/var/tmp/NameOfBackupFile
  1. Example 4: open the LUKS container on /dev/sdX and map it to sdX_crypt.
sudo cryptsetup open /dev/sdX sdX_crypt
โš ๏ธ WARNING: the command in example 5 will erase all keyslots. You cannot use your LUKS container afterward anymore unless you have a backup to restore. like. it's gone gone. ๐Ÿ’€
  1. Example 5: erase all keyslots on /dev/sdX.
sudo cryptsetup erase /dev/sdX
  1. Example 6: restore the LUKS header from a backup file.
sudo cryptsetup luksHeaderRestore /dev/sdX --header-backup-file
/var/tmp/NameOfBackupFile

โœจ RETURN CODES โœจ

Cryptsetup returns 0 on success and a non-zero value on error. simple as that, no drama ๐Ÿซถ

The error codes are:

  • 1 โ€” wrong parameters
  • 2 โ€” no permission (bad passphrase)
  • 3 โ€” out of memory
  • 4 โ€” wrong device specified
  • 5 โ€” device already exists or device is busy

๐ŸŒธ NOTES ๐ŸŒธ

๐Ÿ“ Passphrase processing for PLAIN mode

heads up bestie, no iterated hashing or salting is done in plain mode. If hashing is done, it's a single direct hash. Which means... low-entropy passphrases are easy to attack in plain mode. it's giving exposed, and not in the cute way ๐Ÿ˜ญ

From a terminal: the passphrase is read until the first newline, i.e., '\n'. 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.

From stdin: 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 the maximum key file size and can be overwritten using the --keyfile-size option.

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.

๐Ÿ“Œ note that if --key-file=- is used for reading the key from stdin, trailing newlines are not stripped from the input.

If "plain" is used as an 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. ๐Ÿ™ˆ

From a key file: 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.

The --hash argument is being ignored. The --hash option is usable only for stdin input in plain mode.

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 the maximum key file size and can be overwritten using the --keyfile-size option.


๐Ÿ’œ Passphrase processing for LUKS

From a terminal: the passphrase is read until the first newline and then processed by PBKDF2 without the newline character.

From stdin: 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.

From key file: 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.

LUKS uses Password-Based Key Derivation Function (PBKDF) to protect against brute-force attacks and to give some protection to low-entropy passphrases (see cryptsetup FAQ). LUKS1 supports the PBKDF2 algorithm only, while LUKS2 also supports memory-hard Argon2. PBKDFs are configured with costs: how long the iteration should run (CPU cost or iteration count), how much memory is used (memory cost), and how many parallel processes are used (parallel cost). PBKDF2 supports only iteration count. Cryptsetup uses PBKDF benchmarking to calculate optimal costs based on the computer where the new passphrase is being initialized. If needed, these costs can also be overwritten. Note that there are some hardcoded limits, for details see MINIMAL AND MAXIMAL PBKDF COSTS section in --pbkdf option description.

Whenever a passphrase is added to a LUKS header (luksAddKey, luksFormat), the user may specify how much 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 the open command will take longer to complete. For passphrases that have entropy higher than the used key length, higher iteration times will not increase security.

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 to obtain a higher iteration count. This does slow down all later luksOpen operations accordingly.


๐Ÿฆ‹ Incoherent behavior for invalid passphrases/keys

LUKS checks for a valid passphrase when a keyslot is decrypted. she checks. she verifies. she's thorough ๐Ÿ’…

The behavior of plain dm-crypt is different. It will always unlock the device with the passphrase given. If the given passphrase is wrong, the device mapped by plain dm-crypt will use the wrong encryption key, and the data will be unreadable. so like... it opens, but it opens into chaos ๐Ÿ˜ญ


๐ŸŒˆ 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 to get more options.

Cryptsetup processes many operations outside of the kernel, so the configured cryptographic library must also support selected algorithms. Some algorithms may be missing as cryptsetup can be compiled with various cryptographic backends (libraries).


๐Ÿ‘‘ Notes on passphrases

Mathematics can't 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's 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. bestie, write it down, seal it, hide it, whatever it takes ๐ŸŽ€


๐Ÿงš Notes on Random Number Generators

Random Number Generators (RNGs) used in cryptsetup are always the kernel RNGs without any modifications or additions to the data stream produced. no extra seasoning, just the kernel's finest โœจ

There are two types of randomness that cryptsetup/LUKS needs. One type is used for salts, the AF splitter and for wiping deleted keyslots. The second type is used for the volume key.

With recent kernels (Linux kernel 5.6), you do not need to worry about selecting RNG (/dev/random or /dev/urandom). In a low-entropy situation (embedded system), initialization of the kernel RNG can take a very long time, but this happens before cryptsetup can even be started. Use cryptsetup --help to show the compiled-in default random number generator. See urandom(4) for more information.


โญ Authenticated disk encryption (EXPERIMENTAL)

๐Ÿ”ฅ EXPERIMENTAL โ€” read the whole thing before you go touching stuff, bestie.

Normal disk encryption modes are length-preserving (the plaintext sector is the same size as a ciphertext sector) and can provide only confidentiality protection, not cryptographically sound data integrity protection.

Authenticated modes require additional space per-sector for the authentication tag and use Authenticated Encryption with Additional Data (AEAD) algorithms.

If you configure a LUKS2 device with data integrity protection, there will be an underlying dm-integrity device, which provides additional per-sector metadata space and data journal protection to ensure atomicity of data and metadata updates. Because there must be additional space for metadata and journal, the available space for the device will be smaller than for length-preserving modes.

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 luksOpen for integrity-protected devices. If you want to format a LUKS2 device with data integrity protection, use --integrity option (see cryptsetup-luksFormat(8)).

Albeit Linux kernel 5.7 added TRIM support for standalone dm-integrity devices, cryptsetup(8) can't 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 --allow-discards in cryptsetup-open(8)).

Some integrity modes require two independent keys (a key for encryption and authentication). Both these keys are stored in one LUKS keyslot.

Support for authenticated modes is experimental, and only some modes are available now. Note that very few authenticated encryption algorithms are suitable for disk encryption. You also cannot use CRC32 or 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.


๐Ÿ“ Notes on loopback device use

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. Of course, you can always map a file to a loop device manually. See the cryptsetup FAQ for an example.

When device mapping is active, you can see the loop backing file in the status command output. Also see losetup(8).


๐Ÿ’– LUKS2 header locking

The LUKS2 on-disk metadata is updated in several steps, and to achieve a proper atomic update, there is a locking mechanism. For an image in a file, the code uses the flock(2) system call. For a block device, lock is performed over a special file stored in a locking directory (by default /run/cryptsetup). 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.


๐ŸŒธ LUKS on-disk format specification

For the LUKS on-disk metadata specification, see LUKS1 at https://gitlab.com/cryptsetup/cryptsetup/wikis/Specification and LUKS2 at https://gitlab.com/cryptsetup/LUKS2-docs.

โœจ AUTHORS โœจ

Ok so this page has a whole little squad behind it, and we're giving them their flowers ๐Ÿ’

  • Cryptsetup was originally written by Jana Saout <jana@saout.de>. Iconic. The blueprint. The blueprint blueprint.
  • The LUKS extensions and original man page were written by Clemens Fruhwirth <clemens@endorphin.org>. LUKS extensions and the og man page?? main character energy fr fr ๐Ÿ‘‘
  • Man page extensions by Milan Broz <gmazyland@gmail.com>.
  • Man page rewrite and extension by Arno Wagner <arno@wagner.name>.

The way that four whole people are carrying this documentation legacyโ€ฆ ate ๐Ÿ’…


๐Ÿ› REPORTING BUGS ๐Ÿ›

Found a bug, bestie? Don't just suffer in silence, that's not the vibe. Tell the cryptsetup mailing list:

cryptsetup@lists.linux.dev

or drop it in the Issues project section:

https://gitlab.com/cryptsetup/cryptsetup/-/issues/new
PRO TIP (well, actually, just an ask): please attach the output of the failed command with the --debug option added. Not the vibe you wanted, I know, but it makes the whole thing so much easier to actually fix ๐Ÿซถ

๐ŸŒˆ SEE ALSO ๐ŸŒˆ

Because one manpage is never enough, here's the rest of the reading list:


๐Ÿ‘‘ CRYPTSETUP ๐Ÿ‘‘

Part of cryptsetup project <https://gitlab.com/cryptsetup/cryptsetup/>. That's it, that's the whole section, she's short and she knows it ๐Ÿ’–


and that's a wrap on the whole page, bestie โœจ you just read all four parts, which is lowkey a flex ngl. This is cryptsetup 2.8.8, dated 2026-09-07, and it goes out as CRYPTSETUP(8) โ€” so take care of your disks, encrypt responsibly, and remember: no cap, your passphrase is the whole personality of that volume ๐Ÿ’œ๐ŸŒธ๐ŸŽ€

byeeeee, see you in the next manpage ๐Ÿซถ

๐Ÿ“ฆ where this page comes from