Cryptsetup-reencrypt can be used to change reencryption parameters which otherwise require full on-disk data change (re-encryption).
You can regenerate volume key (the real key used in on-disk encryption unclocked by passphrase), cipher, cipher mode.
Cryptsetup-reencrypt reencrypts data on LUKS device in-place. During reencryption process the LUKS device is marked unavailable.
WARNING: The cryptsetup-reencrypt program is not resistant to hardware or kernel failures during reencryption (you can lose your data in this case).
ALWAYS BE SURE YOU HAVE RELIABLE BACKUP BEFORE USING THIS TOOL.
The reencryption can be temporarily suspended (by TERM signal or by
using ctrl+c) but you need to retain temporary files named LUKS-<uuid>.[log|org|new].
LUKS device is unavailable until reencryption is finished though.
Current working directory must be writable and temporary files created during reencryption must be present.
For more info about LUKS see cryptsetup(8).
cryptsetup-reencrypt <device>
<options> can be [--batch-mode, --block-size, --cipher | --keep-key, --debug, --device-size, --hash, --header, --iter-time | --pbkdf-force-iterations, --key-file, --key-size, --key-slot, --keyfile-offset, --keyfile-size, --master-key-file, --tries, --pbkdf, --pbkdf-memory, --pbkdf-parallel, --progress-frequency, --use-directio, --use-random | --use-urandom, --use-fsync, --uuid, --verbose, --write-log]
To encrypt data on (not yet encrypted) device, use --new with combination with --reduce-device-size or with --header option for detached header.
To remove encryption from device, use --decrypt.
For detailed description of encryption and key file options see cryptsetup(8) man page.
Values can be between 1 and 64 MiB.
WARNING: This is destructive operation and cannot be reverted.
It means that only specified area (from the start of the device to the specified size) will be reencrypted.
If no unit suffix is specified, the size is in bytes.
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).
WARNING: This is destructive operation.
NOTE: if this parameter is not specified, default hash algorithm is always used for new LUKS1 device header.
NOTE: with LUKS2 format this option is only relevant when new keyslot pbkdf algorithm is set to PBKDF2 (see --pbkdf).
WARNING: There is no check whether the ciphertext device specified actually belongs to the header given. If used with --new option, the header file will created (or overwritten). Use with care.
This option can be combined only with --hash, --iter-time, --pbkdf-force-iterations, --pbkdf (LUKS2 only), --pbkdf-memory (Argon2i/id and LUKS2 only) and --pbkdf-parallel (Argon2i/id and LUKS2 only) options.
WARNING: --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).
If this option is not used, cryptsetup-reencrypt will ask for all active keyslot passphrases.
The possible key-sizes are limited by the cipher and mode used.
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.
If there is not enough space for keyslots with new key size, you can destructively shrink device with --reduce-device-size option.
WARNING: All other keyslots will be disabled if this option is used.
This option must be used together with --reduce-device-size.
WARNING: This is destructive operation and cannot be reverted.
For LUKS1, only pbkdf2 is accepted (no need to use this option).
This means that last sectors on the original device will be lost, ciphertext data will be effectively shifted by specified number of sectors.
It can be useful if you e.g. added some space to underlying partition (so last sectors contains no data).
For units suffix see --device-size parameter description.
You cannot shrink device more than by 64 MiB (131072 sectors).
WARNING: This is destructive operation and cannot be reverted. Use with extreme care - shrunk filesystems are usually unrecoverable.
Specify LUKS version when performing in-place encryption. If the parameter is omitted default value (LUKS1) is used. Type may be one of: luks (default), luks1 or luks2.
Useful if direct-io operations perform better than normal buffered operations (e.g. in virtual environments).
To find out what <uuid> to pass look for temporary files LUKS-<uuid>.[|log|org|new] of the interrupted decryption process.
Error codes are: 1 wrong parameters, 2 no permission, 3 out of memory, 4 wrong device specified, 5 device already exists or device is busy.
First, be sure you have space added to disk.
Or alternatively shrink filesystem in advance.
Here we need 4096 512-bytes sectors (enough for 2x128 bit key).
fdisk -u /dev/sdb # move sdb1 partition end + 4096 sectors (or use resize2fs or tool for your filesystem and shrink it)
cryptsetup-reencrypt /dev/sdb1 --new --reduce-device-size 4096S
cryptsetup-reencrypt /dev/sdb1 --decrypt
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.