man > cryptsetup(8)

πŸ“› NAME

cryptsetup β€” manage plain dm-crypt and LUKS encrypted volumes

πŸš€ Quick Reference

Use CaseCommandDescription
πŸ“¦ Create LUKS2 containercryptsetup --type luks2 luksFormat /dev/sdXInitialize a LUKS2 partition with passphrase
πŸ”“ Open LUKS containercryptsetup open /dev/sdX sdX_cryptMap LUKS device to /dev/mapper/sdX_crypt
πŸ”’ Close mappingcryptsetup close sdX_cryptRemove mapping and wipe key from kernel
βž• Add passphrasecryptsetup luksAddKey /dev/sdXAdd a new passphrase to a key slot
βž– Remove passphrasecryptsetup luksRemoveKey /dev/sdXRemove a passphrase (interactive or via file)
πŸ”„ Change passphrasecryptsetup luksChangeKey /dev/sdXChange an existing passphrase
πŸ“Š Statuscryptsetup status sdX_cryptShow mapping status and cipher info
πŸ“ Resizecryptsetup resize sdX_cryptResize active mapping to underlying device size
πŸ“„ Dump headercryptsetup luksDump /dev/sdXDisplay LUKS header information
πŸ’Ύ Backup headercryptsetup luksHeaderBackup /dev/sdX --header-backup-file fileSave binary backup of header and keyslots
πŸ“₯ Restore headercryptsetup luksHeaderRestore /dev/sdX --header-backup-file fileRestore header from backup file
πŸ—‘οΈ Erase keyslotscryptsetup erase /dev/sdXWipe all keyslots, making container permanently inaccessible
⏸️ Suspendcryptsetup luksSuspend sdX_cryptSuspend device, wipe key, block I/O
▢️ Resumecryptsetup luksResume sdX_cryptResume suspended device
⚑ Benchmarkcryptsetup benchmarkBenchmark ciphers and KDF (memory‑only)

πŸ“‹ SYNOPSIS

cryptsetup <options> <action> <action args>

πŸ“– DESCRIPTION

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.

In addition, cryptsetup provides limited support for the use of loop-AES volumes, TrueCrypt, VeraCrypt and BitLocker compatible volumes.

πŸ” PLAIN DM-CRYPT OR LUKS?

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.

⚠️ 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.

πŸ”§ BASIC ACTIONS

The following are valid actions for all supported device types.

πŸ”“ PLAIN MODE

Plain dm-crypt encrypts the device sector-by-sector with a single, non-salted hash of the passphrase. No checks, no metadata. Mapped devices usually reside in /dev/mapper/<name>.

πŸ” LUKS EXTENSION

LUKS, the Linux Unified Key Setup, is a standard for disk encryption. It adds a standardized header, key-slot area, and bulk data area. LUKS2 is a new format with additional extensions. Each passphrase is associated with one of up to 8 key-slots (LUKS1) or 32 (LUKS2).

πŸ”— loop-AES EXTENSION

πŸ” TCRYPT (TrueCrypt-compatible and VeraCrypt) EXTENSION

Supports mapping TrueCrypt, tcplay or VeraCrypt encrypted partitions. Header formatting not supported. Requires kernel userspace crypto API. Options for open: [--key-file, --tcrypt-hidden, --tcrypt-system, --tcrypt-backup, --readonly, --test-passphrase, --allow-discards, --disable-veracrypt, --veracrypt-pim, --veracrypt-query-pim, --header, --cipher, --hash].

πŸͺŸ BITLK (Windows BitLocker-compatible) EXTENSION (EXPERIMENTAL)

Supports mapping BitLocker encrypted partitions. Header formatting not supported. Requires kernel userspace crypto API. For unlocking need password, recovery passphrase, startup key, or master key (FVEK).

πŸ› οΈ MISCELLANEOUS

βš™οΈ OPTIONS

πŸ’‘ EXAMPLE

  1. Create LUKS2 container on block device /dev/sdX:
    sudo cryptsetup --type luks2 luksFormat /dev/sdX
  2. Add an additional passphrase to key slot 5:
    sudo cryptsetup luksAddKey --key-slot 5 /dev/sdX
  3. Create LUKS header backup and save it to file:
    sudo cryptsetup luksHeaderBackup /dev/sdX --header-backup-file /var/tmp/NameOfBackupFile
  4. Open LUKS container on /dev/sdX and map it to sdX_crypt:
    sudo cryptsetup open /dev/sdX sdX_crypt
  5. WARNING: The command in example 5 will erase all key slots. You cannot use your luks container afterwards anymore unless you have a backup to restore.
    sudo cryptsetup erase /dev/sdX
  6. Restore LUKS header from backup file:
    sudo cryptsetup luksHeaderRestore /dev/sdX --header-backup-file /var/tmp/NameOfBackupFile

πŸšͺ Exit Codes

Cryptsetup returns 0 on success and a non-zero value on error.

πŸ“ NOTES ON PASSPHRASE PROCESSING FOR PLAIN MODE

No iterated hashing or salting in plain mode. Direct hash only.

πŸ“ NOTES ON PASSPHRASE PROCESSING FOR LUKS

Uses PBKDF2 to protect against dictionary attacks.

⚠️ INCOHERENT BEHAVIOR FOR INVALID PASSPHRASES/KEYS

LUKS checks for valid passphrase; plain dm-crypt decrypts always, leaving data encrypted if wrong key given.

πŸ”¬ NOTES ON SUPPORTED CIPHERS, MODES, HASHES AND KEY SIZES

Depends on kernel support. See /proc/crypto. For libgcrypt backend, all gcrypt algorithms available.

πŸ”‘ NOTES ON PASSPHRASES

Keep passphrases safe. Use LUKS for multiple passphrases as fallback.

🎲 NOTES ON RANDOM NUMBER GENERATORS

Always kernel RNGs. /dev/urandom used for salts, AF splitter, and wiping. Master key can use /dev/random or /dev/urandom via --use-random/--use-urandom. Low-entropy systems may have issues.

πŸ”’ AUTHENTICATED DISK ENCRYPTION (EXPERIMENTAL)

Requires Linux kernel 4.12+ with dm-integrity and AEAD algorithms. Provides confidentiality and integrity. Uses dm-integrity for per-sector metadata and journal. Available space reduced. Use --integrity option in luksFormat. Does not support discards. All modes experimental.

πŸ’Ώ NOTES ON LOOPBACK DEVICE USE

If device argument is a file, cryptsetup allocates a loopback device. Requires kernel 2.6.25+ with autoclear flag. See losetup(8).

πŸ”’ LUKS2 header locking

LUKS2 uses locking mechanism for atomic updates. For file images uses flock(2); for block devices uses lock file in /run/lock/cryptsetup. Only LUKS2 uses locks.

πŸ—‘οΈ DEPRECATED ACTIONS

reload removed; use dmsetup(8). luksDelKey replaced with luksKillSlot.

πŸ› REPORTING BUGS

Report bugs on cryptsetup mailing list at dm-crypt AT saout.de or in 'Issues' section on LUKS website. Attach output with --debug.

πŸ‘€ AUTHORS

cryptsetup originally written by Jana Saout <jana AT saout.de>. LUKS extensions and original man page by Clemens Fruhwirth <clemens@endorphin.org>. Man page extensions by Milan Broz <gmazyland AT gmail.com>. Man page rewrite and extension by Arno Wagner <arno AT wagner.name>.

©️ COPYRIGHT

Copyright Β© 2004 Jana Saout, Copyright Β© 2004-2006 Clemens Fruhwirth, Copyright Β© 2012-2014 Arno Wagner, Copyright Β© 2009-2021 Red Hat, Inc., Copyright Β© 2009-2021 Milan Broz. This is free software; see source for copying conditions. NO WARRANTY.

πŸ“š SEE ALSO

cryptsetup(8)
πŸ“› NAME πŸš€ Quick Reference πŸ“‹ SYNOPSIS πŸ“– DESCRIPTION
πŸ” PLAIN DM-CRYPT OR LUKS?
⚠️ WARNINGS πŸ”§ BASIC ACTIONS πŸ”“ PLAIN MODE πŸ” LUKS EXTENSION πŸ”— loop-AES EXTENSION πŸ” TCRYPT (TrueCrypt-compatible and VeraCrypt) EXTENSION πŸͺŸ BITLK (Windows BitLocker-compatible) EXTENSION (EXPERIMENTAL) πŸ› οΈ MISCELLANEOUS βš™οΈ OPTIONS πŸ’‘ EXAMPLE πŸšͺ Exit Codes πŸ“ NOTES ON PASSPHRASE PROCESSING FOR PLAIN MODE πŸ“ NOTES ON PASSPHRASE PROCESSING FOR LUKS ⚠️ INCOHERENT BEHAVIOR FOR INVALID PASSPHRASES/KEYS πŸ”¬ NOTES ON SUPPORTED CIPHERS, MODES, HASHES AND KEY SIZES πŸ”‘ NOTES ON PASSPHRASES 🎲 NOTES ON RANDOM NUMBER GENERATORS πŸ”’ AUTHENTICATED DISK ENCRYPTION (EXPERIMENTAL) πŸ’Ώ NOTES ON LOOPBACK DEVICE USE πŸ”’ LUKS2 header locking πŸ—‘οΈ DEPRECATED ACTIONS πŸ› REPORTING BUGS πŸ‘€ AUTHORS ©️ COPYRIGHT πŸ“š SEE ALSO

Generated by phpman v4.9.26-1-g511901d · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-08-02 00:08 @216.73.217.9
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format

^_top_^