CRYPTSETUP-REENCRYPT(8)
β¨ NAME β¨
cryptsetup-reencrypt - reencrypt LUKS encrypted volumes in-place π
π¦ SYNOPSIS π¦
cryptsetup reencrypt [<options>] <device> or --active-name <name>
[<new_name>]
π DESCRIPTION π
okay so bestie, listen up: this is the reencrypt action. It runs LUKS device reencryption. There are 3 basic modes of operation:
- device reencryption (
reencrypt) - device encryption (
reencrypt --encrypt/--new/-N) - device decryption (
reencrypt --decrypt)
<device> or --active-name <name> (LUKS2 only) is mandatory parameter. No skipping this, fr fr.
The cryptsetup reencrypt action can be used to change reencryption parameters, which otherwise require full on-disk data change (re-encryption). The reencrypt action reencrypts data on the LUKS device in-place.
You can regenerate volume key (the real key used in on-disk encryption unlocked by passphrase), cipher, cipher mode or encryption sector size (LUKS2 only). β¨
If you need to use both luksChangeKey and reencrypt (e.g., to recover from a leak), you need to use them in that order to avoid leaking the new volume key. Do not flip the order.
The reencryption process may be safely interrupted by a user via SIGINT signal (ctrl+c). The same applies to the SIGTERM signal (i.e., issued by systemd during system shutdown). So if you panic and hit ctrl+c, it's chill β but read the rest.
For in-place encryption mode, the reencrypt action additionally takes all options available for the luksFormat action for the respective LUKS version (see cryptsetup-luksFormat man page for more details). See cryptsetup-luksFormat(8).
Note that for encrypt and decrypt mode, the whole device must be treated as unencrypted β there are no guarantees of confidentiality as part of the device contains plaintext. Periodt.
ALWAYS BE SURE YOU HAVE RELIABLE BACKUP BEFORE USING THIS ACTION ON LUKS DEVICE.
<options> can be [--batch-mode, --block-size, --cipher, --debug, --debug-json, --decrypt, --device-size, --disable-locks, --encrypt, --force-offline-reencrypt, --hash, --header, --hotzone-size, --iter-time, --init-only, --keep-key, --key-file, --key-size, --key-slot, --keyfile-offset, --keyfile-size, --tries, --timeout, --pbkdf, --pbkdf-force-iterations, --pbkdf-memory, --pbkdf-parallel, --progress-frequency, --progress-json, --reduce-device-size, --resilience, --resilience-hash, --resume-only, --sector-size, --use-directio, --use-random, --use-urandom, --use-fsync, --uuid, --verbose, --volume-key-file, --write-log].
π₯ LUKS2 REENCRYPTION π₯
With the <device> parameter, cryptsetup looks up the active <device> dm mapping. If no active mapping is detected, it starts offline LUKS2 reencryption; otherwise, online reencryption occurs.
To resume already initialized or interrupted reencryption, just run the cryptsetup reencrypt command again to continue the reencryption operation. Reencryption may be resumed with different --resilience or --hotzone-size unless implicit datashift resilience mode is used: either encrypt mode with --reduce-device-size option or decrypt mode with original LUKS2 header exported in --header file.
If the reencryption process was interrupted abruptly (reencryption process crash, system crash, or power off), it may require recovery. The recovery is run automatically on next activation (action open) when needed or explicitly by the user (action repair).
The optional parameter <new_name> takes effect only with the encrypt option, and it activates device <new_name> immediately after encryption initialization is finished. Thatβs useful when the device needs to be ready as soon as possible and mounted (used) before full data area encryption is completed. Main character energy for your mount point.
π LUKS1 REENCRYPTION π
The current working directory must be writable, and temporary files created during reencryption must be present. During reencryption, the LUKS1 device is marked unavailable and must be offline (no dm-crypt mapping or mounted filesystem).
WARNING: The LUKS1 reencryption code is not resistant to hardware or kernel failures during reencryption (you can lose your data in this case).
π OPTIONS π
--align-payload <number of 512 byte sectors>(DEPRECATED, use--offset) β Align payload at a boundary of value 512-byte sectors.- If not specified, cryptsetup tries to use the topology info provided by the kernel for the underlying device to get the optimal alignment. If not available (or the calculated value is a multiple of the default), data is by default aligned to a 1MiB boundary (i.e., 2048 512-byte sectors).
- For a detached LUKS header, this option specifies the offset on the data device. See also the
--headeroption. - This option is DEPRECATED and has an unexpected impact on the data offset and keyslot area size (for LUKS2) due to the complex rounding. For fixed data device offset, use
--offsetoption instead.
--batch-mode,-qβ Suppresses all confirmation questions. Use with care!- If the
--verify-passphraseoption is not specified, this option also switches off the passphrase verification.
- If the
--block-size value(LUKS1 only) β Use re-encryption block size ofvaluein MiB.- Values can be between 1 and 64 MiB.
--cipher,-c <cipher-spec>β LUKS2: Set the cipher specification string for the data segment only.- LUKS1: Set the cipher specification string for the data segment and keyslots.
- The default cipher is applied if the cipher specification is omitted in encrypt mode.
- In reencrypt mode, if no new cipher specification is requested, the existing cipher will remain. The only exception is if the cipher is
"cipher_null", then the default cipher is used. cryptsetup --helpshows the compiled-in defaults.- If a hash is part of the cipher specification, then it is used as part of the IV generation. For example, ESSIV needs a hash function, while
"plain64"does not and hence none is specified. - For XTS mode, you can optionally set a key size of 512 bits with the
-soption. Key size for XTS mode is twice that for other modes for the same security level.
--debugor--debug-jsonβ Run in debug mode with full diagnostic logs. Debug output lines are always prefixed by#.- If
--debug-jsonis used, additional LUKS2 JSON data structures are printed.
- If
--decryptβ Initialize (and run) device decryption mode.--device-size size[units]β Instead of the real device size, use the specified value. It means that only the specified area (from the start of the device to the specified size) will be reencrypted.- LUKS2: When used together with
--reduce-device-size, only the initial size value (--device-sizeparameter) of data is shifted backwards while being encrypted. - The sum of
--device-sizeand--reduce-device-sizevalues must not exceed the real device size. - WARNING: This is a destructive operation. Data beyond
--device-sizelimit may be lost after the operation is finished. - If no unit suffix is specified, the size is in bytes.
- Unit suffix can be
Sfor 512 byte sectors,K/M/G/T(orKiB,MiB,GiB,TiB) for units with 1024 base orKB/MB/GB/TBfor 1000 base (SI scale).
- LUKS2: When used together with
--disable-blkidβ Disable use of the blkid library for checking and wiping on-disk signatures.--disable-keyringβ Do not load the volume key in the kernel keyring; store it directly in the dm-crypt target instead. This option is supported only for the LUKS2 type.--disable-locksβ Disable lock protection for metadata on disk. This option is valid only for LUKS2 and is ignored for other formats.- With locking disabled, LUKS2 images in files can be fully (re)encrypted offline without the need for superuser privileges provided that the used block ciphers are available in the crypto backend.
- WARNING: Do not use this option unless you run cryptsetup in a restricted environment where locking is impossible to perform (where
/rundirectory cannot be used).
--encrypt,--new,-Nβ Initialize (and run) the device in-place encryption mode.--force-no-keyslots(LUKS2 only) β Enforce initialization of reencryption operation with additional--volume-key-file,--new-volume-key-file,--volume-key-keyringor--new-volume-key-keyringparameters. It would result in the deletion of all remaining LUKS2 keyslots containing the volume key.- LUKS2 keyslot with the new volume key may be added after the reencryption operation is finished. See
cryptsetup-luksAddKey(8)command. - WARNING: Use with extreme caution! If you lose the volume key stored in a file or in a kernel keyring before adding the LUKS2 keyslot containing the new volume key, the device will become unusable, and all data will be lost.
- LUKS2 keyslot with the new volume key may be added after the reencryption operation is finished. See
--force-offline-reencrypt(LUKS2 only) β Bypass active device auto-detection and enforce offline reencryption.- This option is useful especially for reencryption of LUKS2 images put in files (auto-detection is not reliable in this scenario).
- It may also help in case active device auto-detection on a particular data device does not work or report errors.
- WARNING: Use with extreme caution! This may destroy data if the device is activated and/or actively used.
--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)andpasswdqc.conf(5).
--hash,-h <hash-spec>β LUKS1: Specifies the hash used in the LUKS1 key setup scheme and volume key digest.- If this parameter is not specified, the default hash algorithm is always used for a new LUKS1 device header.
- LUKS2: Ignored unless new keyslot pbkdf algorithm is set to PBKDF2 (see
--pbkdf).
--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.- If used with
--encrypt/--newoption, the header file will be created (or overwritten). Use with care. - LUKS2: For decryption mode, the option may be used to export the original LUKS2 header to a detached file. The passed future file must not exist at the time of initializing the decryption operation. This frees space in the head of the data device so that data can be moved at the original LUKS2 header location. Later on, the decryption operation continues as if the ordinary detached header was passed.
- If used with
β οΈ WARNING, bestie, read this twice: NEVER put an exported header file in a filesystem on top of the device you're about to decrypt! It would cause a deadlock. ππ like, actual deadlock. don't do it. that's the whole warning. periodt.
--help,-?β shows you the help text and all the default parameters. when in doubt, ask the manpage's little sibling π«Ά--hotzone-sizesize (LUKS2 only) β sets an upper limit on how big the reencryption area (aka the hotzone) can get. you can slap a unit suffix on it like50Mπ . heads up though: the actual hotzone size can come out smaller than the <size> you asked for, because other limitations get in the way (free space in the keyslots area, or just how much memory is available).
and with decryption mode for devices that have the LUKS2 header chilling at the head of the data device, this option tells you how large the first data segment is that gets moved away from the original data offset pointer. π
--init-only(LUKS2 only) β initializes a reencryption operation (any mode) in the LUKS2 metadata only, then dips out. βοΈ but if a reencrypt operation is already initialized in the metadata, running the command with--init-onlywill fail.--iter-time,-i<number of milliseconds> β how many milliseconds to spend doing PBKDF passphrase processing for the shiny new LUKS header. β±οΈβ¨--keep-keyβ the "don't touch the good stuff" option:- LUKS2: do not change the effective volume key, but go ahead and change other parameters if you requested them. π«Ά
- LUKS1: reencrypts only the LUKS1 header and keyslots. it skips the data in-place reencryption entirely. πββοΈ
--key-file,-dfile β reads the passphrase from the file. π- if the name you give is
-, the passphrase gets read fromstdininstead. and in that case, reading will not stop at newline characters. - this option can only be used if there's just one active keyslot β or alternatively, also if the
--key-slotoption is specified (in which case all the other keyslots get disabled in the new LUKS device). π - if you don't use this option at all, cryptsetup will just ask you for all the active keyslot passphrases. π
- if the name you give is
--keyfile-offsetvalue β skips value bytes at the very beginning of the key file. π―--keyfile-size,-lvalue β reads a maximum of value bytes from the key file. the default is to read the whole file up to the compiled-in maximum, which you can peek at with--help. supplying more data than that compiled-in maximum aborts the operation. π
super useful for cutting trailing newlines, for example. and if --keyfile-offset is also given, the size count starts after the offset. πΈ
--key-size,-sbits β- LUKS2: provides the current key size in bits. the argument has to be a multiple of
8. handy when you're specifying the size of the current volume key and there's no keyslot active. π§ - LUKS1: see
--new-key-size. π
- LUKS2: provides the current key size in bits. the argument has to be a multiple of
--key-slot,-S<0-N> β for LUKS operations that add key material, this lets you pick which keyslot gets selected for the new key. π- for reencryption mode, it selects a specific keyslot (and passphrase) that can be used to unlock the new volume key. if you use it, all other keyslots get removed once the reencryption operation is finished. bye besties π
- the maximum number of keyslots depends on the LUKS version. LUKS1 can have up to
8keyslots. LUKS2 can have up to32keyslots based on keyslot area size and key size β but a valid keyslot ID can always be between0and31for LUKS2. π’
--keyslot-cipher<cipher-spec> β lets you set a specific cipher encryption for the LUKS2 keyslot area. π--keyslot-key-size<bits> β lets you set a specific key size for the LUKS2 keyslot area. π--label<label>,--subsystem<subsystem> β sets the label and subsystem description for a LUKS2 device. these are basically the same vibe as filesystem labels. π·οΈ both the label and subsystem are optional fields, and they can be used later inudevscripts to trigger user actions once the device marked by these labels gets detected. πβ¨--luks2-keyslots-sizesize β lets you set a specific size for the LUKS2 binary keyslot area (this is where the key material gets encrypted π«£). the value must be aligned to a multiple of4096bytes, with a maximum size of128MB. the <size> can take a unit suffix (for example,128k). π--luks2-metadata-sizesize β lets you enlarge the LUKS2 metadata (JSON) area. the size includes4096bytes for binary metadata (and yeah, the usable JSON area is smaller than the binary area). according to the LUKS2 specification, only these values are valid:16,32,64,128,256,512,1024,2048and4096kB. the <size> can take a unit suffix (for example,128k). π--new-key-sizebits β sets the new key size in bits. the argument has to be a multiple of8. the possible key sizes are limited by the new cipher and mode used in reencryption. π₯
check /proc/crypto for more info. note that the key size in /proc/crypto is stated in bytes. (don't get got by the unit switch-up π)
- LUKS1: if you're increasing the key size, there has to be enough space in the LUKS header for the enlarged keyslots (the data offset must be large enough), or the reencryption simply cannot be performed. π
- if there's not enough space for keyslots with the new key size, you can destructively shrink the device with the
--reduce-device-sizeoption. π¬
--new-volume-key-filefile β use (set) the new volume key stored in a file. π this option must be paired with the--new-key-sizeparameter when you're initializing the reencryption operation.
β οΈ WARNING: if you create your own volume key, you need to make sure you do it right. otherwise you can end up with a low-entropy or otherwise partially predictable volume key, which will compromise security. π
--new-volume-key-keyring<key description> β use (set) the new volume key stored in a keyring. πβ¨
the size of the key stored in a keyring must be compatible with the new cipher used in the reencryption operation. check /proc/crypto for more info. note that the key size in /proc/crypto is stated in bytes.
the <key description> uses keyctl-compatible syntax. it 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 (the default type). π«Ά
β οΈ WARNING: if you create your own volume key, you need to make sure you do it right. otherwise you can end up with a low-entropy or otherwise partially predictable volume key, which will compromise security. π
--offset,-o<number of 512 byte sectors> β the start offset in the backend device, measured in 512-byte sectors. this option is only relevant for the encrypt mode. π
it sets the data offset (payload) of the data device, and it must be aligned to 4096-byte sectors (so it must be a multiple of 8). this option cannot be combined with the --align-payload option. π«
--pbkdf<PBKDF spec> β sets the Password-Based Key Derivation Function (PBKDF) algorithm for the LUKS keyslot. the PBKDF can be:pbkdf2(for PBKDF2 according to RFC2898),argon2ifor Argon2i, orargon2idfor Argon2id (see Argon2 athttps://www.cryptolux.org/index.php/Argon2for more info). π§ͺβ¨
for LUKS1, only PBKDF2 is accepted (no need to use this option at all). the default PBKDF for LUKS2 is set during compilation time and is available in the cryptsetup --help output. π
a PBKDF exists to crank up 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's also memory cost (the memory required during the process of key derivation) and parallel cost (the number of threads that run in parallel during the key derivation). π§΅
note that bumping up the memory cost also bumps up the time, so the final parameter values get measured by a benchmark. the benchmark tries to find the iteration time (--iter-time) with the required memory cost --pbkdf-memory. if that's not possible, the memory cost gets decreased as well. the parallel cost --pbkdf-parallel is constant and gets checked against the available CPU cores. π₯οΈ
you can see all the PBKDF parameters for a particular LUKS2 keyslot with the cryptsetup-luksDump(8) command. π
if you don't want the benchmark and want to specify all parameters directly, use --pbkdf-force-iterations together with --pbkdf-memory and --pbkdf-parallel. this overrides the values without benchmarking. note it can cause extremely long unlocking time, or cause out-of-memory conditions with unconditional process termination. π use it only in specific cases β for example, if you know 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 a 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 the maximum is 4 GiB. if the memory cost parameter gets benchmarked (not specified by a parameter), it's always in the range from 64 MiB to 1 GiB. memory cost above 1GiB (up to the 4GiB maximum) can be set up only by the --pbkdf-memory parameter. the parallel cost minimum is 1 and the maximum is 4 (if enough CPU cores are available β otherwise it gets 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. π
the hardcoded PBKDF limits represent engineered trade-offs between cryptographic security and operational usability. LUKS maintains portability and must be used within a reasonable time on resource-constrained systems. π§
cryptsetup deliberately restricts the maximum memory cost (4 GiB) and parallel cost (4) parameters due to architectural limitations (like embedded and legacy systems). π
okay bestie we're still in the option list and it is <em>long</em>, but every single one of these is a real thing that does a real thing, so lock in π«Ά
...and the --pbkdf tea continues: PBKDF memory cost means actual physical RAM has to be allocated, with intensive write operations that have to stay in physical RAM. Any swap usage = unacceptable performance degradation, no cap. Memory management loves to overcommit allocations beyond available physical memory, assuming most of that memory will just sit there unused. But PBKDF always uses <em>all</em> of it, so in those situations it frequently causes out-of-memory failures that abort cryptsetup operations. π
--pbkdf-force-iterationsnumber β Skip the PBKDF benchmark entirely and set the time cost (iterations) directly. Works only for a LUKS/LUKS2 device. Peep the--pbkdfoption for more info.--pbkdf-memorynumber β Sets the memory cost for PBKDF (for Argon2i/id, the number is in kilobytes). Important: this is the <em>maximal</em> value β the PBKDF benchmark or your available physical memory can lower it. Not available for PBKDF2.--pbkdf-parallelnumber β Sets the parallel cost for PBKDF (number of threads, up to 4). Also a <em>maximal</em> value β it gets decreased automatically if the CPU online count is lower. Not available for PBKDF2.--progress-frequencyseconds β Prints a separate line every seconds with reencryption progress. lil heartbeat check π--progress-jsonβ Prints progress data in JSON format, mostly for machine processing. It prints a separate line every half second (or based on the--progress-frequencyvalue). During progress the JSON output looks like this (except it's actually a compact single line):
{
"device":"/dev/sda", // backing device or file
"device_bytes":"8192", // bytes of I/O so far
"device_size":"44040192", // total bytes of I/O to go
"speed":"126877696", // calculated speed in bytes per second (based on progress so far)
"eta_ms":"2520012", // estimated time to finish an operation in milliseconds
"time_ms":"5561235" // total time spent in IO operation in milliseconds
}
Note on numbers in JSON output: due to JSON parser limitations, all numbers are represented in a string format, because they need full 64-bit unsigned integers. β¨
--reduce-device-sizesize β This means the last size sectors on the original device will be lost, and data will effectively be shifted by that specified number of sectors.
It could be useful if you added some space to the underlying partition or logical volume (so those last size sectors contain no data).
For units suffix, see the --device-size parameter description.
WARNING: This is a destructive operation and cannot be reverted. Use with extreme care β accidentally overwritten filesystems are usually unrecoverable. π
LUKS2: Initialize LUKS2 reencryption with data device size reduction (currently, only encryption mode is supported). The last size sectors on the original plaintext device get used for temporarily storing the original first data segment. The former first data segment is replaced with the LUKS2 header (half the size value), and the plaintext data is shifted backwards (again half the size value) while being encrypted.
The recommended minimum size is twice the default LUKS2 header size (--reduce-device-size 32M) for encryption mode.
The sum of the --device-size and --reduce-device-size values must not exceed the real device size.
LUKS1: Enlarge the data offset to the specified value by shrinking the device size.
You cannot shrink the device by more than 64 MiB (131072 sectors).
--resiliencemode (LUKS2 only) β Reencryption resilience mode can be one ofchecksum,journalornone. Vibe check on how safe an interrupt is πchecksum: the default mode, where individual checksums of ciphertext hotzone sectors are stored, so the recovery process can detect which sectors were already reencrypted. It requires that the device sector write is atomic.journal: the hotzone is journaled in the binary area (so the data are written twice).none: performance mode. There is no protection, and the only way it's safe to interrupt the reencryption is similar to an old offline reencryption utility.
Resilience modes can be changed unless datashift mode is used for operation initialization (encryption with the --reduce-device-size option).
--resilience-hashhash (LUKS2 only) β The hash algorithm is used with"--resilience checksum"only. The default hash issha256. With other resilience modes, the hash parameter is ignored.--resume-only(LUKS2 only) β Resume reencryption (any mode) operation that is already described in LUKS2 metadata. If no reencrypt operation is initialized, the command with the--resume-onlyparameter fails. Useful for resuming the reencrypt operation without accidentally triggering a new reencryption operation. no surprise plot twists here bestie π--sector-sizebytes (LUKS2 only) β Reencrypt the device with a new encryption sector size enforced.
WARNING: Increasing the encryption sector size may break the hosted filesystem. Do not run reencryption with --force-offline-reencrypt if unsure what block size the filesystem was formatted with.
Note that using a sector size larger than the underlying storage device's physical sector size may result in data corruption during unexpected power failures. A power failure during write operations may result in only partial completion of the encryption sector write, leaving encrypted data in an inconsistent state that cannot be properly decrypted. π
--timeout,-tseconds β The number of seconds to wait before a timeout on passphrase input via terminal. It's relevant every time a passphrase is asked. It has no effect if used in conjunction with--key-file.
This option is useful when the system should not stall if the user does not input a passphrase, e.g., during boot. The default is a value of 0 seconds, which means to wait forever. forever is a long time, girl
--token-idβ LUKS2 reencryption initialization: Specify what keyslots (associated with the selected token) to use for LUKS2 reencryption. If the reencryption operation changes the effective volume key, only keyslots associated with the token and unlocked successfully will be available after the reencryption operation is finished.
LUKS2 reencryption resume: Specify what token to use and allow the token PIN prompt to take precedence over the interactive keyslot passphrase prompt. If omitted, all available tokens (not protected by PIN) will be checked before proceeding further with the passphrase prompt.
--token-onlyβ LUKS2 reencryption initialization: Specify that all keyslots associated with any token will be used for LUKS2 reencryption. If the reencryption operation changes the effective volume key, only keyslots associated with any token will be available after the reencryption operation is finished.
LUKS2 reencryption resume: Do not proceed further with the action if the token-based keyslot unlock failed. Without the option, the action asks for a passphrase to proceed further.
It allows LUKS2 tokens protected by PIN to take precedence over the interactive keyslot passphrase prompt.
--token-typetype β LUKS2 reencryption initialization: Specify what keyslots (associated with the selected token type) to use for LUKS2 reencryption. If the reencryption operation changes the effective volume key, only keyslots associated with the token type and unlocked successfully will be available after the reencryption operation is finished.
LUKS2 reencryption resume: Restrict tokens eligible for operation to a specific token type. Mostly useful when no --token-id is specified.
It allows LUKS2 type tokens protected by PIN to take precedence over the interactive keyslot passphrase prompt.
--tries,-Tβ How often the input of the passphrase shall be retried. The default is3tries. three strikes, babe--typetype β Specifies the required (encryption mode) or expected (other modes) LUKS format. Accepts onlyluks1orluks2.--usageβ Show short option help. the lil tl;dr β¨--use-directio(LUKS1 only) β Use direct-io (O_DIRECT) for all read/write data operations related to the block device undergoing reencryption.
Useful if direct-io operations perform better than normal buffered operations (e.g., in virtual environments).
--use-fsync(LUKS1 only) β Use thefsynccall after every written block. This applies to reencryption log files as well.--use-random,--use-urandomβ Define which kernel random number generator will be used to create the volume key. π²--uuidUUID β When used in encryption mode, use the provided UUID for the new LUKS header instead of generating a new one.
LUKS1 (only in decryption mode): To find out what UUID to pass, look for temporary files LUKS-UUID.[|log|org|new] of the interrupted decryption process.
The UUID must be provided in the standard UUID format, e.g., 12345678-1234-1234-1234-123456789abc.
--verify-passphrase,-yβ When interactively asking for a passphrase, ask for it twice and complain if both inputs do not match. Ignored on input from file or stdin. yes queen, confirm your password, we don't do typos here π--version,-Vβ Show the program version.--volume-key-filefile,--master-key-filefile (OBSOLETE alias) β LUKS2: Provides the current volume key stored in a file. It can be used to reencrypt the device with no active keyslot together with--new-volume-key-fileor--new-volume-key-keyringoptions.
LUKS1: See --new-volume-key-file.
--write-log(LUKS1 only) β Update the log file after every block is written. This can slow down reencryption, but it will minimize data loss in the case of a system crash. slow and steady keeps your data safe fr fr
β¨ EXAMPLES β¨
Okay bestie, this is the fun part β real commands you can actually copy-paste. π
Just so you know: you can totally drop the --type luks2 option as long as LUKS2 format is the default. So like, it's giving optional, iykyk.
πΈ LUKS2 ENCRYPTION EXAMPLES πΈ
Encrypt LUKS2 device (in-place)
Make sure the last 32 MiB on /dev/plaintext is unused (like, e.g., it does not contain filesystem data), bestie:
cryptsetup reencrypt --encrypt --type luks2 --reduce-device-size 32m
/dev/plaintext_device
Encrypt LUKS2 device (in-place), partial
Only the initial 1 GiB of original /dev/plaintext data is encrypted while being shifted backwards. Make sure the last 32 MiB (tail) on the data device is unused (e.g., does not contain any data), fr fr:
cryptsetup reencrypt --encrypt --type luks2 --device-size 1g
--reduce-device-size 32m /dev/plaintext_device
Encrypt LUKS2 device (in-place) with detached header
Put that header in a file, main character energy:
cryptsetup reencrypt --encrypt --type luks2 --header my_luks2_header
/dev/plaintext_device
Initialize LUKS2 in-place encryption only and activate the device
Not yet encrypted, just vibing:
cryptsetup reencrypt --encrypt --type luks2 --init-only
--reduce-device-size 32m /dev/plaintext_device my_future_luks_device
Resume online encryption on the device initialized in the example above
Pick your fighter, they do the same thing:
cryptsetup reencrypt --resume-only /dev/plaintext_device
or
cryptsetup reencrypt --active-name my_future_luks_device
π¦ LUKS2 REENCRYPTION EXAMPLES π¦
Reencrypt LUKS2 device (refresh volume key only)
The classic. Just a lil refresh:
cryptsetup reencrypt /dev/encrypted_device
Reencrypt using a token
Reencrypt LUKS2 device using keyslot(s) associated with the token 3. All other keyslots will be removed after the reencryption finishes. π
cryptsetup reencrypt --token-id 3 /dev/encrypted_device
Reencrypt using a token type
Reencrypt LUKS2 device using keyslots associated with all 'systemd-tpm2' tokens. All other keyslots will be removed after the reencryption finishes. Again, π for those other keyslots.
cryptsetup reencrypt --token-type systemd-tpm2 /dev/encrypted_device
π LUKS2 DECRYPTION EXAMPLES π
Decrypt LUKS2 device with header in the head of the data device
Header file does not exist:
cryptsetup reencrypt --decrypt --header /export/header/to/file
/dev/encrypted_device
Decrypt LUKS2 device with detached header
Header file exists:
cryptsetup reencrypt --decrypt --header detached-luks2-header
/dev/encrypted_device
Resume interrupted LUKS2 decryption
We love a comeback story:
cryptsetup reencrypt --resume-only --header luks2-hdr-file
/dev/encrypted_device
π REPORTING BUGS π
Found a bug? Not you being the QA bestie we all needed. π
Report bugs at the cryptsetup mailing list <cryptsetup@lists.linux.dev> or in the Issues project section <https://gitlab.com/cryptsetup/cryptsetup/-/issues/new>.
Please attach the output of the failed command with --debug option added. No cap, this makes it SO much easier to help you. π«Ά
π SEE ALSO π
Go read more, it's giving scholar:
- 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 on the whole page, bestie!! π This manual page is from cryptsetup 2.8.8, dated 2026-09-07, and it lives at CRYPTSETUP-REENCRYPT(8). Go forth and reencrypt 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