'\" t .\" Title: cryptsetup-reencrypt .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.23 .\" Date: 2025-08-13 .\" Manual: Maintenance Commands .\" Source: cryptsetup 2.8.1 .\" Language: English .\" .TH "CRYPTSETUP\-REENCRYPT" "8" "2025-08-13" "cryptsetup 2.8.1" "Maintenance Commands" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 .nh .ad l .de URL \fI\\$2\fP <\\$1>\\$3 .. .als MTO URL .if \n[.g] \{\ . mso www.tmac . am URL . ad l . . . am MTO . ad l . . . LINKSTYLE blue R < > .\} .SH "NAME" cryptsetup-reencrypt \- reencrypt LUKS encrypted volumes in\-place .SH "SYNOPSIS" .sp \fBcryptsetup \fIreencrypt\fP [] or \-\-active\-name []\fP .SH "DESCRIPTION" .sp Run LUKS device reencryption. .sp There are 3 basic modes of operation: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} device reencryption (\fIreencrypt\fP) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} device encryption (\fIreencrypt\fP \-\-encrypt/\-\-new/\-N) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ . sp -1 . IP \(bu 2.3 .\} device decryption (\fIreencrypt\fP \-\-decrypt) .RE .sp or \-\-active\-name (LUKS2 only) is mandatory parameter. .sp Cryptsetup \fIreencrypt\fP action can be used to change reencryption parameters, which otherwise require full on\-disk data change (re\-encryption). The \fIreencrypt\fP action reencrypts data on the LUKS device in\-place. .sp You can regenerate \fBvolume key\fP (the real key used in on\-disk encryption unlocked by passphrase), \fBcipher\fP, \fBcipher mode\fP or \fBencryption sector size\fP (LUKS2 only). .sp 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. .sp 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). .sp For in\-place encryption mode, the \fIreencrypt\fP action additionally takes all options available for the \fIluksFormat\fP action for the respective LUKS version (see cryptsetup\-luksFormat man page for more details). See \fBcryptsetup\-luksFormat\fP(8). .sp Note that for encrypt and decrypt mode, the whole device must be treated as unencrypted \(em there are no guarantees of confidentiality as part of the device contains plaintext. .sp \fBALWAYS BE SURE YOU HAVE RELIABLE BACKUP BEFORE USING THIS ACTION ON LUKS DEVICE.\fP .sp \fB\fP 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]. .SH "LUKS2 REENCRYPTION" .sp With the parameter, cryptsetup looks up the active dm mapping. If no active mapping is detected, it starts offline LUKS2 reencryption; otherwise, online reencryption occurs. .sp To resume already initialized or interrupted reencryption, just run the cryptsetup \fIreencrypt\fP 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. .sp 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 \fIopen\fP) when needed or explicitly by the user (action \fIrepair\fP). .sp The optional parameter takes effect only with the encrypt option, and it activates device immediately after encryption initialization is finished. That\(cqs useful when the device needs to be ready as soon as possible and mounted (used) before full data area encryption is completed. .SH "LUKS1 REENCRYPTION" .sp 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). .sp \fBWARNING\fP: The LUKS1 reencryption code is not resistant to hardware or kernel failures during reencryption (you can lose your data in this case). .SH "OPTIONS" .sp \fB\-\-align\-payload\fP \fI\fP (DEPRECATED, use \-\-offset) .RS 4 Align payload at a boundary of \fIvalue\fP 512\-byte sectors. .sp 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). .sp For a detached LUKS header, this option specifies the offset on the data device. See also the \-\-header option. .sp 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 \-\-offset option instead. .RE .sp \fB\-\-batch\-mode\fP, \fB\-q\fP .RS 4 Suppresses all confirmation questions. Use with care! .sp If the \-\-verify\-passphrase option is not specified, this option also switches off the passphrase verification. .RE .sp \fB\-\-block\-size\fP \fIvalue\fP (LUKS1 only) .RS 4 Use re\-encryption block size of \fIvalue\fP in MiB. .sp Values can be between 1 and 64 MiB. .RE .sp \fB\-\-cipher\fP, \fB\-c\fP \fI\fP .RS 4 \fBLUKS2\fP: Set the cipher specification string for the data segment only. .sp \fBLUKS1\fP: Set the cipher specification string for the data segment and keyslots. .sp The default cipher is applied if the cipher specification is omitted in encrypt mode. .sp 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. .sp \fIcryptsetup \-\-help\fP shows the compiled\-in defaults. .sp 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. .sp For XTS mode, you can optionally set a key size of 512 bits with the \-s option. Key size for XTS mode is twice that for other modes for the same security level. .RE .sp \fB\-\-debug\fP or \fB\-\-debug\-json\fP .RS 4 Run in debug mode with full diagnostic logs. Debug output lines are always prefixed by \fB#\fP. .sp If \-\-debug\-json is used, additional LUKS2 JSON data structures are printed. .RE .sp \fB\-\-decrypt\fP .RS 4 Initialize (and run) device decryption mode. .RE .sp \fB\-\-device\-size\fP \fIsize[units]\fP .RS 4 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. .sp \fBLUKS2\fP: When used together with \-\-reduce\-device\-size, only the initial \fIsize\fP value (\-\-device\-size parameter) of data is shifted backwards while being encrypted. .sp The sum of \-\-device\-size and \-\-reduce\-device\-size values must not exceed the real device size. .sp \fBWARNING:\fP This is a destructive operation. Data beyond \-\-device\-size limit may be lost after the operation is finished. .sp If no unit suffix is specified, the size is in bytes. .sp Unit suffix can be S for 512 byte sectors, K/M/G/T (or KiB, MiB, GiB, TiB) for units with 1024 base or KB/MB/GB/TB for 1000 base (SI scale). .RE .sp \fB\-\-disable\-blkid\fP .RS 4 Disable use of the blkid library for checking and wiping on\-disk signatures. .RE .sp \fB\-\-disable\-keyring\fP .RS 4 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. .RE .sp \fB\-\-disable\-locks\fP .RS 4 Disable lock protection for metadata on disk. This option is valid only for LUKS2 and is ignored for other formats. .sp 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. .sp \fBWARNING:\fP 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). .RE .sp \fB\-\-encrypt\fP, \fB\-\-new\fP, \fB\-N\fP .RS 4 Initialize (and run) the device in\-place encryption mode. .RE .sp \fB\-\-force\-no\-keyslots\fP (LUKS2 only) .RS 4 Enforce initialization of reencryption operation with additional \-\-volume\-key\-file, \-\-new\-volume\-key\-file, \-\-volume\-key\-keyring or \-\-new\-volume\-key\-keyring parameters. It would result in the deletion of all remaining LUKS2 keyslots containing the volume key. .sp LUKS2 keyslot with the new volume key may be added after the reencryption operation is finished. See \fBcryptsetup\-luksAddKey\fP(8) command. .sp \fBWARNING:\fP 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. .RE .sp \fB\-\-force\-offline\-reencrypt\fP (LUKS2 only) .RS 4 Bypass active device auto\-detection and enforce offline reencryption. .sp This option is useful especially for reencryption of LUKS2 images put in files (auto\-detection is not reliable in this scenario). .sp It may also help in case active device auto\-detection on a particular data device does not work or report errors. .sp \fBWARNING:\fP Use with extreme caution! This may destroy data if the device is activated and/or actively used. .RE .sp \fB\-\-force\-password\fP .RS 4 Do not use password quality checking for new LUKS passwords. .sp This option is ignored if cryptsetup is built without password quality checking support. .sp For more info about password quality check, see the manual page for \fBpwquality.conf\fP(5) and \fBpasswdqc.conf\fP(5). .RE .sp \fB\-\-hash\fP, \fB\-h\fP \fI\fP .RS 4 \fBLUKS1:\fP Specifies the hash used in the LUKS1 key setup scheme and volume key digest. .sp If this parameter is not specified, the default hash algorithm is always used for a new LUKS1 device header. .sp \fBLUKS2:\fP Ignored unless new keyslot pbkdf algorithm is set to PBKDF2 (see \-\-pbkdf). .RE .sp \fB\-\-header\fP \fI\fP .RS 4 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. .sp If used with \-\-encrypt/\-\-new option, the header file will be created (or overwritten). Use with care. .sp \fBLUKS2\fP: 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. .sp \fBWARNING:\fP Never put an exported header file in a filesystem on top of the device you are about to decrypt! It would cause a deadlock. .RE .sp \fB\-\-help\fP, \fB\-?\fP .RS 4 Show help text and default parameters. .RE .sp \fB\-\-hotzone\-size\fP \fIsize\fP (LUKS2 only) .RS 4 This option can be used to set an upper limit on the size of the reencryption area (hotzone). The \fIsize\fP can be specified with a unit suffix (for example, 50M). Note that the actual hotzone size may be less than specified due to other limitations (free space in keyslots area or available memory). .sp With decryption mode for devices with LUKS2 header placed in the head of the data device, the option specifies how large is the first data segment moved from the original data offset pointer. .RE .sp \fB\-\-init\-only\fP (LUKS2 only) .RS 4 Initialize reencryption (any mode) operation in LUKS2 metadata only and exit. If any reencrypt operation is already initialized in metadata, the command with \-\-init\-only parameter fails. .RE .sp \fB\-\-iter\-time\fP, \fB\-i\fP \fI\fP .RS 4 The number of milliseconds to spend with PBKDF passphrase processing for the new LUKS header. .RE .sp \fB\-\-keep\-key\fP .RS 4 \fBLUKS2\fP: Do not change the effective volume key, and change other parameters if requested. .sp \fBLUKS1\fP: Reencrypt only the LUKS1 header and keyslots. Skips data in\-place reencryption. .RE .sp \fB\-\-key\-file\fP, \fB\-d\fP \fIfile\fP .RS 4 Read the passphrase from the file. .sp If the name given is "\-", then the passphrase will be read from stdin. In this case, reading will not stop at newline characters. .sp The \-\-key\-file option can be used only if there is only one active keyslot, or alternatively, also if \-\-key\-slot option is specified (then all other keyslots will be disabled in the new LUKS device). .sp If this option is not used, cryptsetup will ask for all active keyslot passphrases. .RE .sp \fB\-\-keyfile\-offset\fP \fIvalue\fP .RS 4 Skip \fIvalue\fP bytes at the beginning of the key file. .RE .sp \fB\-\-keyfile\-size\fP, \fB\-l\fP \fIvalue\fP .RS 4 Read a maximum of \fIvalue\fP bytes 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. .sp This option is useful to cut trailing newlines, for example. If \-\-keyfile\-offset is also given, the size count starts after the offset. .RE .sp \fB\-\-key\-size\fP, \fB\-s\fP \fIbits\fP .RS 4 \fBLUKS2\fP: Provide current key size in \fIbits\fP. The argument has to be a multiple of 8. Useful when specifying the size of the current volume key when no keyslot is active. .sp \fBLUKS1\fP: See \-\-new\-key\-size. .RE .sp \fB\-\-key\-slot\fP, \fB\-S\fP \fI<0\-N>\fP .RS 4 For LUKS operations that add key material, this option allows you to specify which keyslot is selected for the new key. .sp For reencryption mode, it selects a specific keyslot (and passphrase) that can be used to unlock the new volume key. If used, all other keyslots get removed after the reencryption operation is finished. .sp 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. .RE .sp \fB\-\-keyslot\-cipher\fP \fI\fP .RS 4 This option can be used to set specific cipher encryption for the LUKS2 keyslot area. .RE .sp \fB\-\-keyslot\-key\-size\fP \fI\fP .RS 4 This option can be used to set a specific key size for the LUKS2 keyslot area. .RE .sp \fB\-\-label\fP \fI