Section: Maintenance Commands (8)
Updated: December 2013
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 you data in this case).
ALWAYS BE SURE YOU HAVE RELIABLE BACKUP BEFORE USING THIS TOOL.
THIS TOOL IS EXPERIMENTAL.
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 by writable and temporary files created during reencryption must be present.
<options> can be [--block-size, --cipher, --hash, --iter-time, --use-random | --use-urandom, --key-file, --key-slot, --keyfile-offset, --keyfile-size, --tries, --use-directio, --use-fsync, --write-log]
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.
NOTE: if this parameter is not specified, default hash algorithm is always used for new device header.
WARNING: --key-file option can be used only if there 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.
WARNING: All other keyslots will be disabled if this option is used.
This option can be combined only with --hash or --iter-time options.
Values can be between 1 and 64 MiB.
It means that only specified area (from the start of the device to the specified size) will be reencrypted.
WARNING: This is destructive operation.
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.
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.
WARNING: This is destructive operation and cannot be reverted. Use with extreme care - shrinked filesystems are usually unrecoverable.
You cannot shrink device more than by 64 MiB (131072 sectors).
This option must be used together with --reduce-device-size.
WARNING: This is destructive operation and cannot be reverted.
Useful if direct-io operations perform better than normal buffered operations (e.g. in virtual environments).
Cryptsetup-reencrypt returns 0 on success and a non-zero value on error.
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
Report bugs, including ones in the documentation, on the cryptsetup mailing list at <[email protected]> or in the 'Issues' section on LUKS website. Please attach the output of the failed command with the --debug option added.
Cryptsetup-reencrypt was written by Milan Broz <[email protected]>.
Copyright © 2012-2014 Milan Broz
Copyright © 2012-2013 Red Hat, Inc.
The project website at http://code.google.com/p/cryptsetup/
Tutoriais de Tecnologia Web