CRYPTSETUP-LUKSADDKEY(8)
π CRYPTSETUP-LUKSADDKEY π
okay bestie, welcome to cryptsetup-luksAddKey(8) β yes it's a Maintenance Command, yes it's part of the cryptsetup family, and yes it's about to be your new obsession. sit down, hydrate, let's go π«Ά
β¨ NAME β¨
cryptsetup-luksAddKey β add a new passphrase π
π SYNOPSIS π
cryptsetup luksAddKey [<options>] <device> [<key file with new key>]
π¦ DESCRIPTION π¦
So basically? This command adds a keyslot protected by a new passphrase. New keyslot, who dis. π₯
An existing passphrase has to be supplied β either interactively, via --key-file, or via a LUKS2 token (plugin). And alternatively to that existing passphrase, you can just pass the volume key directly, via --volume-key-file or --volume-key-keyring.
The new passphrase you're adding? You can specify it interactively, read it from the file given as the positional argument (or also via the --new-keyfile parameter), or via a LUKS2 token.
The --unbound option creates a new unbound LUKS2 keyslot. And here's the vibe check on that: an unbound keyslot stores an independent key that cannot be used for device activation. If you don't pass a new key via the --volume-key-file option, a new random key gets generated. And the existing passphrase for any active keyslot is not required. slay.
Some parameters are only effective if you use them with the LUKS2 format, because LUKS2 supports per-keyslot parameters. For LUKS1? The PBKDF type and hash algorithm are always the same for all keyslots. no exceptions, periodt.
<options> can be:
--key-file, --keyfile-offset, --keyfile-size, --new-keyfile, --new-keyfile-offset, --new-keyfile-size, --key-slot, --new-key-slot, --volume-key-file, --volume-key-keyring, --force-password, --hash, --header, --disable-locks, --iter-time, --pbkdf, --pbkdf-force-iterations, --pbkdf-memory, --pbkdf-parallel, --unbound, --type, --keyslot-cipher, --keyslot-key-size, --key-size, --timeout, --token-id, --token-type, --token-only, --new-token-id, --verify-passphrase, --external-tokens-path.
πΈ OPTIONS πΈ
--batch-mode,-qβ suppresses all the confirmation questions. Use with care bestie, fr fr π
If the --verify-passphrase option is not specified, this option also switches off the passphrase verification.
--debugor--debug-jsonβ run in debug mode with full diagnostic logs. Debug output lines are always prefixed by#.
If --debug-json is used, additional LUKS2 JSON data structures are printed. π
--disable-locksβ disable lock protection for metadata on disk. This option is valid only for LUKS2 and is ignored for other formats.
β οΈ WARNING: Do not use this option unless you run cryptsetup in a restricted environment where locking is impossible to perform (where /run directory cannot be used).
--external-tokens-path <absolute path>β override the system directory path where cryptsetup searches for external token handlers (or token plugins). It must be an absolute path (starting with/character).--force-passwordβ do not use password quality checking for new LUKS passwords.
This option is ignored if cryptsetup is built without password quality checking support.
For more info about password quality check, see the manual page for pwquality.conf(5) and passwdqc.conf(5).
--hash,-h <hash-spec>β the specified hash is used for PBKDF2 and the AF splitter.--header <device or file storing the LUKS header>β use a detached (separated) metadata device or file where the LUKS header is stored. This option allows one to store the ciphertext and LUKS header on different devices.
For commands that change the LUKS header (e.g., luksAddKey), specify the device or file with the LUKS header directly as the LUKS device.
--help,-?β show help text and default parameters. π--iter-time,-i <number of milliseconds>β the number of milliseconds to spend with PBKDF passphrase processing. Specifying0as a parameter selects the compiled-in default.--key-description textβ set the key description in the keyring that will be used for passphrase retrieval.--key-file,-d fileβ read the passphrase from the file.
If the name given is -, then the passphrase will be read from stdin. In this case, reading will not stop at newline characters.
The passphrase supplied via --key-file is always the passphrase for the existing keyslot requested by the command.
If you want to set a new passphrase via key file, you have to use a positional argument or parameter --new-keyfile.
See section NOTES ON PASSPHRASE PROCESSING in cryptsetup(8) for more information.
--keyfile-offset valueβ skipvaluebytes at the beginning of the key file.--keyfile-size,-l valueβ read a maximum ofvaluebytes from the key file. The default is to read the whole file up to the compiled-in maximum that can be queried with--help. Supplying more data than the compiled-in maximum aborts the operation.
This option is useful to cut trailing newlines, for example. If --keyfile-offset is also given, the size count starts after the offset.
--key-size,-s bitsβ provide volume key size in bits. The argument has to be a multiple of8.
This option is required when the parameter --volume-key-file is used to provide current volume key. Also, it is used when a new unbound keyslot is created by specifying --unbound parameter.
--key-slot,-S <0-N>β when used together with the parameter--new-key-slot, this option allows you to specify which keyslot is selected for unlocking the volume key.
This option is ignored if the existing volume key gets unlocked via LUKS2 token (--token-id, --token-type or --token-only parameters) or when volume key is provided directly via --volume-key-file parameter.
To maintain backward compatibility, without --new-key-slot parameter, this option allows you to specify which keyslot is selected for the new key.
The maximum number of keyslots depends on the LUKS version. LUKS1 can have up to 8 keyslots. LUKS2 can have up to 32 keyslots based on keyslot area size and key size, but a valid keyslot ID can always be between 0 and 31 for LUKS2.
--keyslot-cipher <cipher-spec>β this option can be used to set specific cipher encryption for the LUKS2 keyslot area.--keyslot-key-size <bits>β this option can be used to set a specific key size for the LUKS2 keyslot area.--new-keyfile nameβ read the passphrase for a new keyslot from a file.
If the name given is -, then the passphrase will be read from stdin. In this case, reading will not stop at newline characters.
This is an alternative method to positional argument when adding a new passphrase via keyfile.
--new-keyfile-offset valueβ skipvaluebytes at the start when adding a new passphrase from the key file.--new-keyfile-size valueβ read a maximum ofvaluebytes when adding a new passphrase from the key file. The default is to read the whole file up to the compiled-in maximum length that can be queried with--help. Supplying more than the compiled-in maximum aborts the operation. When--new-keyfile-offsetis also given, reading starts after the offset.--new-key-description textβ set the key description in the keyring that will be used for new passphrase retrieval.--new-key-slot <0-N>β this option allows you to specify which keyslot is selected for the new key.
The maximum number of keyslots depends on the LUKS version. LUKS1 can have up to 8 keyslots. LUKS2 can have up to 32 keyslots based on keyslot area size and key size, but a valid keyslot ID can always be between 0 and 31 for LUKS2.
--new-token-id <id>β specify what token to use to get the passphrase for a new keyslot.--pbkdf <PBKDF spec>β set Password-Based Key Derivation Function (PBKDF) algorithm for LUKS keyslot. The PBKDF can be:pbkdf2(for PBKDF2 according to RFC2898),argon2ifor Argon2i orargon2idfor Argon2id (see Argon2https://www.cryptolux.org/index.php/Argon2for more info).
For LUKS1, only PBKDF2 is accepted (no need to use this option). The default PBKDF for LUKS2 is set during compilation time and is available in the cryptsetup --help output.
A PBKDF is used for increasing the dictionary and brute-force attack cost for keyslot passwords. The parameters can be time, memory and parallel cost.
For PBKDF2, only the time cost (number of iterations) applies. For Argon2i/id, there is also memory cost (memory required during the process of key derivation) and parallel cost (number of threads that run in parallel during the key derivation.
Note that increasing memory cost also increases time, so the final parameter values are measured by a benchmark. The benchmark tries to find iteration time (--iter-time) with required memory cost --pbkdf-memory. If it is not possible, the memory cost is decreased as well. The parallel cost --pbkdf-parallel is constant and is checked against available CPU cores.
You can see all PBKDF parameters for a particular LUKS2 keyslot with the cryptsetup-luksDump(8) command.
If you do not want to use benchmark and want to specify all parameters directly, use --pbkdf-force-iterations with --pbkdf-memory and --pbkdf-parallel. This will override the values without benchmarking. Note it can cause extremely long unlocking time or cause out-of-memory conditions with unconditional process termination. Use only in specific cases, for example, if you know that the formatted device will be used on some small embedded system. π
MINIMAL AND MAXIMAL PBKDF COSTS: For PBKDF2, the minimum iteration count is 1000 and the maximum is 4294967295 (maximum for 32-bit unsigned integer). Memory and parallel costs are not supported for PBKDF2. For Argon2i and Argon2id, the minimum iteration count (CPU cost) is 4, and the maximum is 4294967295 (maximum for a 32-bit unsigned integer). Minimum memory cost is 32 KiB and maximum is 4 GiB. If the memory cost parameter is benchmarked (not specified by a parameter), it is always in the range from 64 MiB to 1 GiB. Memory cost above 1GiB (up to the 4GiB maximum) can be setup only by the --pbkdf-memory parameter. The parallel cost minimum is 1 and maximum 4 (if enough CPU cores are available, otherwise it is decreased by the available CPU cores).
β οΈ WARNING: Increasing PBKDF computational costs above the mentioned limits provides negligible additional security improvement. While elevated costs significantly increase brute-force overhead, they offer negligible protection against dictionary attacks. The marginal cost increase for processing an entire dictionary remains fundamentally insufficient.
okay bestie we're not done yet, part 2 is coming, don't go anywhere π§
The hardcoded PBKDF limits are not just cryptsetup being dramatic, bestie β they're engineered trade-offs between cryptographic security and operational usability. LUKS has to stay portable and has to work in a reasonable amount of time on resource-constrained systems, so the numbers can't just be "as big as possible, slay". π
Cryptsetup deliberately restricts the maximum memory cost (4 GiB) and the parallel cost (4) because of architectural limitations (think embedded and legacy systems). It's giving "we would if we could, but the hardware said no". π
And the PBKDF memory cost thing? It mandates actual physical RAM allocation with intensive write operations that have to stay in physical RAM. Any swap usage results in unacceptable performance degradation β like, no cap. Memory management often overcommits allocations beyond available physical memory, expecting most of that allocated memory to just sit there unused. But in such situations, because PBKDF always uses all allocated memory, it frequently causes out-of-memory failures that abort cryptsetup operations. π So yeah, that's the whole tea.
--pbkdf-force-iterationsnumber β Skips the PBKDF benchmark entirely and sets the time cost (iterations) directly. Works only for a LUKS/LUKS2 device. Want the full lore? See the--pbkdfoption. β¨--pbkdf-memorynumber β Sets the memory cost for PBKDF (for Argon2i/id, that number is in kilobytes). Heads up: it's the maximal value β the PBKDF benchmark or your available physical memory can knock it down. Not available for PBKDF2. π«Ά--pbkdf-parallelnumber β Sets the parallel cost for PBKDF (number of threads, up to 4). Again, it's the maximal value β it gets decreased automatically if the CPU online count is lower. Also not available for PBKDF2. π¦--timeout,-tseconds β How many seconds to wait before timing out on passphrase input via terminal. It matters every single time a passphrase is asked. It has no effect if you're using it with--key-file. This one's iconic when the system shouldn't stall because the user didn't type anything β like during boot. Default is a value of0seconds, which means wait forever. β³--token-idβ Specify which token to use when unlocking the existing keyslot to get the volume key. ποΈ--token-onlyβ Use only LUKS2 tokens to unlock the existing volume key. And if you wanna create a new keyslot using the passphrase provided by a token, use the--new-token-idparameter. π--token-typetype β Specify which token type (all type tokens) to use when unlocking the existing keyslot to get the volume key. π--typetype β Specifies the required device type. For more info, read the BASIC ACTIONS section incryptsetup(8). π--unboundβ Creates a new LUKS2 unbound keyslot. π¦--usageβ Shows short option help. That's it, that's the vibe. πΈ--verify-passphrase,-yβ When interactively asking for a passphrase, asks for it twice and complains if both inputs don't match. Ignored on input from file or stdin. π«Ά--version,-Vβ Shows the program version. β--volume-key-filefile,--master-key-filefile (OBSOLETE alias) β Uses a volume key stored in a file. This lets you add a new keyslot without having to know the passphrase to the existing one. It may also be used when no keyslot is active.
WARNING: If you create your own volume key, you need to make sure to do it right. Otherwise, you can end up with a low-entropy or otherwise partially predictable volume key, which will compromise security. π Like, please don't freestyle this one, bestie.
--volume-key-keyring<key description> β Uses a volume key stored in a keyring. This lets you open luks and plain device types without giving a passphrase. π
For LUKS, the key and associated type have to be readable from userspace so the volume key digest may be verified before activation. For devices in reencryption, the option may be used twice to specify both old and new volume keys. π
For PLAIN type, you the user must ensure the key in the keyring is unchanged since activation. Otherwise, reloading the key can cause data corruption after an unexpected key change. π
The <key description> uses keyctl-compatible syntax. This can either be a numeric key ID or a string name in the format %<key type>:<key name>. See also the KEY IDENTIFIERS section of keyctl(1). When no %<key type>: prefix is specified, we assume the key type is user (default type). π
β¨ EXAMPLES β¨
The interactive passphrase prompt is always the default method when not specified otherwise. Periodt.
Add new keyslot using interactive passphrase prompt for both existing and new passphrases:
cryptsetup luksAddKey /dev/device
Add a new keyslot using LUKS2 tokens to unlock the existing keyslot with an interactive passphrase prompt for the new passphrase:
cryptsetup luksAddKey --token-only /dev/device
Add new keyslot using LUKS2 systemd-tpm2 tokens to unlock existing keyslot with interactive passphrase prompt for new passphrase (the systemd-tpm2 token plugin must be available):
cryptsetup luksAddKey --token-type systemd-tpm2 /dev/device
Add new keyslot using interactive passphrase prompt for existing keyslot, reading new passphrase from key_file:
cryptsetup luksAddKey --new-keyfile key_file /dev/device
or
cryptsetup luksAddKey /dev/device key_file
Add new keyslot using volume stored in volume_key_file and LUKS2 token in slot 5 to get new keyslot passphrase (the token in slot 5 must exist and the respective token plugin must be available):
cryptsetup luksAddKey --volume-key-file volume_key_file --new-token-id 5 /dev/device
π REPORTING BUGS π
Found a bug? Tell the cryptsetup mailing list at cryptsetup@lists.linux.dev or drop it in the Issues project section at https://gitlab.com/cryptsetup/cryptsetup/-/issues/new. π«Ά
Please attach the output of the failed command with the --debug option added. It makes everything so much easier, ngl. π
π SEE ALSO π
- Cryptsetup FAQ
https://gitlab.com/cryptsetup/cryptsetup/wikis/FrequentlyAskedQuestionsπ cryptsetup(8),integritysetup(8)andveritysetup(8)π
π CRYPTSETUP π
Part of cryptsetup project https://gitlab.com/cryptsetup/cryptsetup/. π
And that's a wrap, bestie! π This iconic little page is from cryptsetup 2.8.8, dated 2026-09-07, and it lives under the name CRYPTSETUP-LUKSADDKEY(8). Go forth and add those keyslots responsibly. π β¨
π¦ where this page comes from
- arch rolling: cryptsetup 2.8.8-1 Β· GPL-2.0-or-later
- fedora 44: cryptsetup 2.8.8-1.fc44 Β· GPL-2.0-or-later WITH cryptsetup-OpenSSL-exception AND LGPL-2.1-or-later WITH cryptsetup-OpenSSL-exception
- nixpkgs unstable: cryptsetup 2.8.8
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms