'\" t .\" Title: cryptsetup-reencrypt .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.20 .\" Date: 2024-01-05 .\" Manual: Maintenance Commands .\" Source: cryptsetup 2.6.1 .\" Language: English .\" .TH "CRYPTSETUP\-REENCRYPT" "8" "2024-01-05" "cryptsetup 2.6.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 LUKS device in\-place. .sp You can regenerate \fBvolume key\fP (the real key used in on\-disk encryption unclocked by passphrase), \fBcipher\fP, \fBcipher mode\fP or \fBencryption sector size\fP (LUKS2 only). .sp Reencryption process may be safely interrupted by a user via SIGINT signal (ctrl+c). Same applies to 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 \fIluksFormat\fP action for respective LUKS version (see cryptsetup\-luksFormat man page for more details). See \fBcryptsetup\-luksFormat\fP(8). .sp \fBNOTE\fP that for encrypt and decrypt mode, the whole device must be treated as unencrypted \(em there are no quarantees 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 parameter cryptsetup looks up active dm mapping. If no active mapping is detected, it starts offline LUKS2 reencryption otherwise online reencryption takes place. .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, poweroff) it may require recovery. The recovery is currently run automatically on next activation (action \fIopen\fP) when needed or explicitly by user (action \fIrepair\fP). .sp Optional parameter takes effect only with encrypt option and it activates device immediately after encryption initialization gets finished. That\(cqs useful when device needs to be ready as soon as possible and mounted (used) before full data area encryption is completed. .SH "LUKS1 REENCRYPTION" .sp Current working directory must be writable and temporary files created during reencryption must be present. During reencryption process 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\-\-block\-size\fP \fIvalue\fP \fB(LUKS1 only)\fP .RS 4 Use re\-encryption block size of \fIvalue\fP in MiB. .sp Values can be between 1 and 64 MiB. .RE .sp \fB\-\-use\-directio (LUKS1 only)\fP .RS 4 Use direct\-io (O_DIRECT) for all read/write data operations related to block device undergoing reencryption. .sp Useful if direct\-io operations perform better than normal buffered operations (e.g. in virtual environments). .RE .sp \fB\-\-use\-fsync (LUKS1 only)\fP .RS 4 Use fsync call after every written block. This applies for reencryption log files as well. .RE .sp \fB\-\-write\-log (LUKS1 only)\fP .RS 4 Update log file after every block write. This can slow down reencryption but will minimize data loss in the case of system crash. .RE .sp \fB\-\-type \fP .RS 4 Specifies required (encryption mode) or expected (other modes) LUKS format. Accepts only \fIluks1\fP or \fIluks2\fP. .RE .sp \fB\-\-hash, \-h\fP \fI\fP .RS 4 \fBLUKS1:\fP Specifies the hash used in the LUKS1 key setup scheme and volume key digest. .sp \fBNOTE\fP: if this parameter is not specified, default hash algorithm is always used for new LUKS1 device header. .sp \fBLUKS2:\fP Ignored unless new keyslot pbkdf algorithm is set to PBKDF2 (see \-\-pbkdf). .RE .sp \fB\-\-cipher, \-c\fP \fI\fP .RS 4 \fBLUKS2\fP: Set the cipher specification string for data segment only. .sp \fBLUKS1\fP: Set the cipher specification string for data segment and keyslots. .sp \fBNOTE\fP: In encrypt mode, if cipher specification is omitted the default cipher is applied. In reencrypt mode, if no new cipher specification is requested, the existing cipher will remain in use. Unless the existing cipher was "cipher_null". In that case default cipher would be applied as in encrypt mode. .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\-\-verify\-passphrase, \-y\fP .RS 4 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. .RE .sp \fB\-\-key\-file, \-d\fP \fIname\fP .RS 4 Read the passphrase from 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 \fBWARNING:\fP \-\-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 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, \-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\-\-volume\-key\-file, \-\-master\-key\-file (OBSOLETE alias)\fP .RS 4 Use (set) new volume key stored in a file. .br \fBWARNING:\fP 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. .RE .sp \fB\-\-use\-random\fP, \fB\-\-use\-urandom\fP .RS 4 Define which kernel random number generator will be used to create the volume key. .RE .sp \fB\-\-keep\-key\fP .RS 4 \fBLUKS2\fP: Do not change effective volume key and change other parameters provided it is requested. .sp \fBLUKS1\fP: Reencrypt only the LUKS1 header and keyslots. Skips data in\-place reencryption. .RE .sp \fB\-\-key\-slot, \-S <0\-N>\fP .RS 4 For LUKS operations that add key material, this option allows you to specify which key slot is selected for the new key. .sp For reencryption mode it selects specific keyslot (and passphrase) that can be used to unlock new volume key. If used all other keyslots get removed after reencryption operation is finished. .sp The maximum number of key slots depends on the LUKS version. LUKS1 can have up to 8 key slots. LUKS2 can have up to 32 key slots based on key slot area size and key size, but a valid key slot ID can always be between 0 and 31 for LUKS2. .RE .sp \fB\-\-key\-size, \-s\fP \fIbits\fP .RS 4 Sets key size in \fIbits\fP. The argument has to be a multiple of 8. The possible key\-sizes are limited by the cipher and mode used. .sp See /proc/crypto for more information. Note that key\-size in /proc/crypto is stated in bytes. .sp \fBLUKS1\fP: If you are increasing key size, there must be enough space in the LUKS header for enlarged keyslots (data offset must be large enough) or reencryption cannot be performed. .sp If there is not enough space for keyslots with new key size, you can destructively shrink device with \-\-reduce\-device\-size option. .RE .sp \fB\-\-offset, \-o \fP .RS 4 Start offset in the backend device in 512\-byte sectors. This option is only relevant for the encrypt mode. .sp The \-\-offset option sets the data offset (payload) of data device and must be aligned to 4096\-byte sectors (must be multiple of 8). This option cannot be combined with \-\-align\-payload option. .RE .sp \fB\-\-device\-size\fP \fIsize[units]\fP .RS 4 Instead of real device size, use specified value. It means that only specified area (from the start of the device to the specified size) will be reencrypted. .sp \fBWARNING:\fP This is destructive operation. Data beyond \-\-device\-size limit may be lost after operation gets 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\-\-pbkdf \fP .RS 4 Set Password\-Based Key Derivation Function (PBKDF) algorithm for LUKS keyslot. The PBKDF can be: \fIpbkdf2\fP (for PBKDF2 according to RFC2898), \fIargon2i\fP for Argon2i or \fIargon2id\fP for Argon2id (see .URL "https://www.cryptolux.org/index.php/Argon2" "Argon2" "" for more info). .sp 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 \fIcryptsetup \-\-help\fP output. .sp A PBKDF is used for increasing dictionary and brute\-force attack cost for keyslot passwords. The parameters can be time, memory and parallel cost. .sp For PBKDF2, only 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. .sp 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 (\fI\-\-iter\-time\fP) with required memory cost \fI\-\-pbkdf\-memory\fP. If it is not possible, the memory cost is decreased as well. The parallel cost \fI\-\-pbkdf\-parallel\fP is constant and is checked against available CPU cores. .sp You can see all PBKDF parameters for particular LUKS2 keyslot with \fBcryptsetup\-luksDump\fP(8) command. .sp \fBNOTE:\fP If you do not want to use benchmark and want to specify all parameters directly, use \fI\-\-pbkdf\-force\-iterations\fP with \fI\-\-pbkdf\-memory\fP and \fI\-\-pbkdf\-parallel\fP. This will override the values without benchmarking. Note it can cause extremely long unlocking time. Use only in specific cases, for example, if you know that the formatted device will be used on some small embedded system. .sp \fBMINIMAL AND MAXIMAL PBKDF COSTS:\fP For \fBPBKDF2\fP, the minimum iteration count is 1000 and maximum is 4294967295 (maximum for 32bit unsigned integer). Memory and parallel costs are unused for PBKDF2. For \fBArgon2i\fP and \fBArgon2id\fP, minimum iteration count (CPU cost) is 4 and maximum is 4294967295 (maximum for 32bit unsigned integer). Minimum memory cost is 32 KiB and maximum is 4 GiB. (Limited by addressable memory on some CPU platforms.) If the memory cost parameter is benchmarked (not specified by a parameter) it is always in range from 64 MiB to 1 GiB. The parallel cost minimum is 1 and maximum 4 (if enough CPUs cores are available, otherwise it is decreased). .RE .sp \fB\-\-iter\-time, \-i \fP .RS 4 The number of milliseconds to spend with PBKDF passphrase processing for the new LUKS header. .RE .sp \fB\-\-pbkdf\-memory \fP .RS 4 Set the memory cost for PBKDF (for Argon2i/id the number represents kilobytes). Note that it is maximal value, PBKDF benchmark or available physical memory can decrease it. This option is not available for PBKDF2. .RE .sp \fB\-\-pbkdf\-parallel \fP .RS 4 Set the parallel cost for PBKDF (number of threads, up to 4). Note that it is maximal value, it is decreased automatically if CPU online count is lower. This option is not available for PBKDF2. .RE .sp \fB\-\-pbkdf\-force\-iterations \fP .RS 4 Avoid PBKDF benchmark and set time cost (iterations) directly. It can be used for LUKS/LUKS2 device only. See \fI\-\-pbkdf\fP option for more info. .RE .sp \fB\-\-progress\-frequency\fP \fIseconds\fP .RS 4 Print separate line every \fIseconds\fP with reencryption progress. .RE .sp \fB\-\-progress\-json\fP .RS 4 Prints progress data in JSON format suitable mostly for machine processing. It prints separate line every half second (or based on \fI\-\-progress\-frequency\fP value). The JSON output looks as follows during progress (except it\(cqs compact single line): .sp .if n .RS 4 .nf .fam C { "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 } .fam .fi .if n .RE .sp Note on numbers in JSON output: Due to JSON parsers limitations all numbers are represented in a string format due to need of full 64bit unsigned integers. .RE .sp \fB\-\-timeout, \-t \fP .RS 4 The number of seconds to wait before timeout on passphrase input via terminal. It is relevant every time a passphrase is asked. It has no effect if used in conjunction with \-\-key\-file. .sp 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. .RE .sp \fB\-\-tries, \-T\fP .RS 4 How often the input of the passphrase shall be retried. The default is 3 tries. .RE .sp \fB\-\-align\-payload \fP .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 \fBWARNING:\fP This option is DEPRECATED and has often unexpected impact to the data offset and keyslot area size (for LUKS2) due to the complex rounding. For fixed data device offset use \fI\-\-offset\fP option instead. .RE .sp \fB\-\-uuid \fP .RS 4 When used in encryption mode use the provided \fIUUID\fP for the new LUKS header instead of generating a new one. .sp \fBLUKS1 (only in decryption mode)\fP: To find out what \fIUUID\fP to pass look for temporary files LUKS\-\fIUUID\fP.[|log|org|new] of the interrupted decryption process. .sp The \fIUUID\fP must be provided in the standard UUID format, e.g. 12345678\-1234\-1234\-1234\-123456789abc. .RE .sp \fB\-\-header \fP .RS 4 Use a detached (separated) metadata device or file where the LUKS header is stored. This option allows one to store 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 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 head of data device so that data can be moved at original LUKS2 header location. Later on decryption operation continues as if the ordinary detached header was passed. .sp \fBWARNING:\fP Never put exported header file in a filesystem on top of device you are about to decrypt! It would cause a deadlock. .RE .sp \fB\-\-force\-offline\-reencrypt (LUKS2 only)\fP .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 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(5)\fP and \fBpasswdqc.conf(5)\fP. .RE .sp \fB\-\-disable\-locks\fP .RS 4 Disable lock protection for metadata on disk. This option is valid only for LUKS2 and ignored for other formats. .sp \fBNOTE:\fP With locking disabled LUKS2 images in files can be fully (re)encrypted offline without need for super user privileges provided used block ciphers are available in 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\-\-disable\-keyring\fP .RS 4 Do not load volume key in kernel keyring and store it directly in the dm\-crypt target instead. This option is supported only for the LUKS2 type. .RE .sp \fB\-\-sector\-size\fP \fIbytes\fP \fB(LUKS2 only)\fP .RS 4 Reencrypt device with new encryption sector size enforced. .sp \fBWARNING:\fP Increasing encryption sector size may break hosted filesystem. Do not run reencryption with \-\-force\-offline\-reencrypt if unsure what block size was filesystem formatted with. .RE .sp \fB\-\-label