{
    "mode": "man",
    "parameter": "cryptsetup-reencrypt",
    "section": "8",
    "url": "https://www.chedong.com/phpMan.php/man/cryptsetup-reencrypt/8/json",
    "generated": "2026-10-06T15:37:07Z",
    "synopsis": "cryptsetup reencrypt [<options>] <device> or --active-name <name> [<newname>]",
    "sections": {
        "NAME": {
            "content": "cryptsetup-reencrypt - reencrypt LUKS encrypted volumes in-place\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "cryptsetup reencrypt [<options>] <device> or --active-name <name> [<newname>]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Run LUKS device reencryption.\n\nThere are 3 basic modes of operation:\n\n•   device reencryption (reencrypt)\n\n•   device encryption (reencrypt --encrypt/--new/-N)\n\n•   device decryption (reencrypt --decrypt)\n\n<device> or --active-name <name> (LUKS2 only) is mandatory parameter.\n\nCryptsetup reencrypt action can be used to change reencryption parameters which otherwise\nrequire full on-disk data change (re-encryption). The reencrypt action reencrypts data on\nLUKS device in-place.\n\nYou can regenerate volume key (the real key used in on-disk encryption unlocked by\npassphrase), cipher, cipher mode or encryption sector size (LUKS2 only).\n\nReencryption process may be safely interrupted by a user via SIGINT signal (ctrl+c). Same\napplies to SIGTERM signal (i.e. issued by systemd during system shutdown).\n\nFor in-place encryption mode, the reencrypt action additionally takes all options available\nfor luksFormat action for respective LUKS version (see cryptsetup-luksFormat man page for\nmore details). See cryptsetup-luksFormat(8).\n\nNOTE that for encrypt and decrypt mode, the whole device must be treated as unencrypted —\nthere are no guarantees of confidentiality as part of the device contains plaintext.\n",
            "subsections": [
                {
                    "name": "ALWAYS BE SURE YOU HAVE RELIABLE BACKUP BEFORE USING THIS ACTION ON LUKS DEVICE.",
                    "content": "<options> can be [--batch-mode, --block-size, --cipher, --debug, --debug-json, --decrypt,\n--device-size, --disable-locks, --encrypt, --force-offline-reencrypt, --hash, --header,\n--hotzone-size, --iter-time, --init-only, --keep-key, --key-file, --key-size, --key-slot,\n--keyfile-offset, --keyfile-size, --tries, --timeout, --pbkdf, --pbkdf-force-iterations,\n--pbkdf-memory, --pbkdf-parallel, --progress-frequency, --progress-json,\n--reduce-device-size, --resilience, --resilience-hash, --resume-only, --sector-size,\n--use-directio, --use-random, --use-urandom, --use-fsync, --uuid, --verbose,\n--volume-key-file, --write-log].\n"
                }
            ]
        },
        "LUKS2 REENCRYPTION": {
            "content": "With <device> parameter cryptsetup looks up active <device> dm mapping. If no active mapping\nis detected, it starts offline LUKS2 reencryption otherwise online reencryption takes place.\n\nTo resume already initialized or interrupted reencryption, just run the cryptsetup reencrypt\ncommand again to continue the reencryption operation. Reencryption may be resumed with\ndifferent --resilience or --hotzone-size unless implicit datashift resilience mode is used:\neither encrypt mode with --reduce-device-size option or decrypt mode with original LUKS2\nheader exported in --header file.\n\nIf the reencryption process was interrupted abruptly (reencryption process crash, system\ncrash, poweroff) it may require recovery. The recovery is currently run automatically on next\nactivation (action open) when needed or explicitly by user (action repair).\n\nOptional parameter <newname> takes effect only with encrypt option and it activates device\n<newname> immediately after encryption initialization gets finished. That’s useful when\ndevice needs to be ready as soon as possible and mounted (used) before full data area\nencryption is completed.\n",
            "subsections": []
        },
        "LUKS1 REENCRYPTION": {
            "content": "Current working directory must be writable and temporary files created during reencryption\nmust be present. During reencryption process the LUKS1 device is marked unavailable and must\nbe offline (no dm-crypt mapping or mounted filesystem).\n\nWARNING: The LUKS1 reencryption code is not resistant to hardware or kernel failures during\nreencryption (you can lose your data in this case).\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "--block-size value (LUKS1 only)\nUse re-encryption block size of value in MiB.\n\nValues can be between 1 and 64 MiB.\n",
            "subsections": [
                {
                    "name": "--use-directio (LUKS1 only)",
                    "content": "Use direct-io (ODIRECT) for all read/write data operations related to block device\nundergoing reencryption.\n\nUseful if direct-io operations perform better than normal buffered operations (e.g. in\nvirtual environments).\n",
                    "long": "--use-directio"
                },
                {
                    "name": "--use-fsync (LUKS1 only)",
                    "content": "Use fsync call after every written block. This applies for reencryption log files as\nwell.\n",
                    "long": "--use-fsync"
                },
                {
                    "name": "--write-log (LUKS1 only)",
                    "content": "Update log file after every block write. This can slow down reencryption but will\nminimize data loss in the case of system crash.\n",
                    "long": "--write-log"
                },
                {
                    "name": "--type <device-type>",
                    "content": "Specifies required (encryption mode) or expected (other modes) LUKS format. Accepts only\nluks1 or luks2.\n\n--hash, -h <hash-spec>\nLUKS1: Specifies the hash used in the LUKS1 key setup scheme and volume key digest.\n\nNOTE: if this parameter is not specified, default hash algorithm is always used for new\nLUKS1 device header.\n\nLUKS2: Ignored unless new keyslot pbkdf algorithm is set to PBKDF2 (see --pbkdf).\n\n--cipher, -c <cipher-spec>\nLUKS2: Set the cipher specification string for data segment only.\n\nLUKS1: Set the cipher specification string for data segment and keyslots.\n\nNOTE: In encrypt mode, if cipher specification is omitted the default cipher is applied.\nIn reencrypt mode, if no new cipher specification is requested, the existing cipher will\nremain in use. Unless the existing cipher was \"ciphernull\". In that case default cipher\nwould be applied as in encrypt mode.\n\ncryptsetup --help shows the compiled-in defaults.\n\nIf a hash is part of the cipher specification, then it is used as part of the IV\ngeneration. For example, ESSIV needs a hash function, while \"plain64\" does not and hence\nnone is specified.\n\nFor XTS mode you can optionally set a key size of 512 bits with the -s option. Key size\nfor XTS mode is twice that for other modes for the same security level.\n",
                    "long": "--type",
                    "arg": "<device-type>"
                },
                {
                    "name": "--verify-passphrase, -y",
                    "content": "When interactively asking for a passphrase, ask for it twice and complain if both inputs\ndo not match. Ignored on input from file or stdin.\n\n--key-file, -d name\nRead the passphrase from file.\n\nIf the name given is \"-\", then the passphrase will be read from stdin. In this case,\nreading will not stop at newline characters.\n\nWARNING: --key-file option can be used only if there is only one active keyslot, or\nalternatively, also if --key-slot option is specified (then all other keyslots will be\ndisabled in new LUKS device).\n\nIf this option is not used, cryptsetup will ask for all active keyslot passphrases.\n\n--keyfile-offset value\nSkip value bytes at the beginning of the key file.\n\n--keyfile-size, -l value\nRead a maximum of value bytes from the key file. The default is to read the whole file up\nto the compiled-in maximum that can be queried with --help. Supplying more data than the\ncompiled-in maximum aborts the operation.\n\nThis option is useful to cut trailing newlines, for example. If --keyfile-offset is also\ngiven, the size count starts after the offset.\n",
                    "flag": "-y",
                    "long": "--verify-passphrase"
                },
                {
                    "name": "--volume-key-file, --master-key-file (OBSOLETE alias)",
                    "content": "Use (set) new volume key stored in a file.\nWARNING: If you create your own volume key, you need to make sure to do it right.\nOtherwise, you can end up with a low-entropy or otherwise partially predictable volume\nkey which will compromise security.\n\n--use-random, --use-urandom\nDefine which kernel random number generator will be used to create the volume key.\n",
                    "long": "--master-key-file"
                },
                {
                    "name": "--keep-key",
                    "content": "LUKS2: Do not change effective volume key and change other parameters provided it is\nrequested.\n\nLUKS1: Reencrypt only the LUKS1 header and keyslots. Skips data in-place reencryption.\n",
                    "long": "--keep-key"
                },
                {
                    "name": "--key-slot, -S <0-N>",
                    "content": "For LUKS operations that add key material, this option allows you to specify which key\nslot is selected for the new key.\n\nFor reencryption mode it selects specific keyslot (and passphrase) that can be used to\nunlock new volume key. If used all other keyslots get removed after reencryption\noperation is finished.\n\nThe maximum number of key slots depends on the LUKS version. LUKS1 can have up to 8 key\nslots. LUKS2 can have up to 32 key slots based on key slot area size and key size, but a\nvalid key slot ID can always be between 0 and 31 for LUKS2.\n\n--key-size, -s bits\nSets key size in bits. The argument has to be a multiple of 8. The possible key-sizes are\nlimited by the cipher and mode used.\n\nSee /proc/crypto for more information. Note that key-size in /proc/crypto is stated in\nbytes.\n\nLUKS1: If you are increasing key size, there must be enough space in the LUKS header for\nenlarged keyslots (data offset must be large enough) or reencryption cannot be performed.\n\nIf there is not enough space for keyslots with new key size, you can destructively shrink\ndevice with --reduce-device-size option.\n",
                    "flag": "-S",
                    "long": "--key-slot",
                    "arg": "<0-N>"
                },
                {
                    "name": "--offset, -o <number of 512 byte sectors>",
                    "content": "Start offset in the backend device in 512-byte sectors. This option is only relevant for\nthe encrypt mode.\n\nThe --offset option sets the data offset (payload) of data device and must be aligned to\n4096-byte sectors (must be multiple of 8). This option cannot be combined with\n--align-payload option.\n\n--device-size size[units]\nInstead of real device size, use specified value. It means that only specified area (from\nthe start of the device to the specified size) will be reencrypted.\n\nWARNING: This is destructive operation. Data beyond --device-size limit may be lost after\noperation gets finished.\n\nIf no unit suffix is specified, the size is in bytes.\n\nUnit suffix can be S for 512 byte sectors, K/M/G/T (or KiB,MiB,GiB,TiB) for units with\n1024 base or KB/MB/GB/TB for 1000 base (SI scale).\n",
                    "flag": "-o",
                    "long": "--offset"
                },
                {
                    "name": "--pbkdf <PBKDF spec>",
                    "content": "Set Password-Based Key Derivation Function (PBKDF) algorithm for LUKS keyslot. The PBKDF\ncan be: pbkdf2 (for PBKDF2 according to RFC2898), argon2i for Argon2i or argon2id for\nArgon2id (see Argon2 <https://www.cryptolux.org/index.php/Argon2> for more info).\n\nFor LUKS1, only PBKDF2 is accepted (no need to use this option). The default PBKDF for\nLUKS2 is set during compilation time and is available in cryptsetup --help output.\n\nA PBKDF is used for increasing dictionary and brute-force attack cost for keyslot\npasswords. The parameters can be time, memory and parallel cost.\n\nFor PBKDF2, only time cost (number of iterations) applies. For Argon2i/id, there is also\nmemory cost (memory required during the process of key derivation) and parallel cost\n(number of threads that run in parallel during the key derivation.\n\nNote that increasing memory cost also increases time, so the final parameter values are\nmeasured by a benchmark. The benchmark tries to find iteration time (--iter-time) with\nrequired memory cost --pbkdf-memory. If it is not possible, the memory cost is decreased\nas well. The parallel cost --pbkdf-parallel is constant and is checked against available\nCPU cores.\n\nYou can see all PBKDF parameters for particular LUKS2 keyslot with cryptsetup-luksDump(8)\ncommand.\n\nNOTE: If you do not want to use benchmark and want to specify all parameters directly,\nuse --pbkdf-force-iterations with --pbkdf-memory and --pbkdf-parallel. This will override\nthe values without benchmarking. Note it can cause extremely long unlocking time or cause\nout-of-memory conditions with unconditional process termination. Use only in specific\ncases, for example, if you know that the formatted device will be used on some small\nembedded system.\n\nMINIMAL AND MAXIMAL PBKDF COSTS: For PBKDF2, the minimum iteration count is 1000 and\nmaximum is 4294967295 (maximum for 32bit unsigned integer). Memory and parallel costs are\nunused for PBKDF2. For Argon2i and Argon2id, minimum iteration count (CPU cost) is 4 and\nmaximum is 4294967295 (maximum for 32bit unsigned integer). Minimum memory cost is 32 KiB\nand maximum is 4 GiB. (Limited by addressable memory on some CPU platforms.) If the\nmemory cost parameter is benchmarked (not specified by a parameter) it is always in range\nfrom 64 MiB to 1 GiB. The parallel cost minimum is 1 and maximum 4 (if enough CPUs cores\nare available, otherwise it is decreased).\n",
                    "long": "--pbkdf"
                },
                {
                    "name": "--iter-time, -i <number of milliseconds>",
                    "content": "The number of milliseconds to spend with PBKDF passphrase processing for the new LUKS\nheader.\n",
                    "flag": "-i",
                    "long": "--iter-time"
                },
                {
                    "name": "--pbkdf-memory <number>",
                    "content": "Set the memory cost for PBKDF (for Argon2i/id the number represents kilobytes). Note that\nit is maximal value, PBKDF benchmark or available physical memory can decrease it. This\noption is not available for PBKDF2.\n",
                    "long": "--pbkdf-memory",
                    "arg": "<number>"
                },
                {
                    "name": "--pbkdf-parallel <number>",
                    "content": "Set the parallel cost for PBKDF (number of threads, up to 4). Note that it is maximal\nvalue, it is decreased automatically if CPU online count is lower. This option is not\navailable for PBKDF2.\n",
                    "long": "--pbkdf-parallel",
                    "arg": "<number>"
                },
                {
                    "name": "--pbkdf-force-iterations <num>",
                    "content": "Avoid PBKDF benchmark and set time cost (iterations) directly. It can be used for\nLUKS/LUKS2 device only. See --pbkdf option for more info.\n\n--progress-frequency seconds\nPrint separate line every seconds with reencryption progress.\n",
                    "long": "--pbkdf-force-iterations",
                    "arg": "<num>"
                },
                {
                    "name": "--progress-json",
                    "content": "Prints progress data in JSON format suitable mostly for machine processing. It prints\nseparate line every half second (or based on --progress-frequency value). The JSON output\nlooks as follows during progress (except it’s compact single line):\n\n{\n\"device\":\"/dev/sda\"       // backing device or file\n\"devicebytes\":\"8192\",    // bytes of I/O so far\n\"devicesize\":\"44040192\", // total bytes of I/O to go\n\"speed\":\"126877696\",      // calculated speed in bytes per second (based on progress so far)\n\"etams\":\"2520012\"        // estimated time to finish an operation in milliseconds\n\"timems\":\"5561235\"       // total time spent in IO operation in milliseconds\n}\n\nNote on numbers in JSON output: Due to JSON parsers limitations all numbers are\nrepresented in a string format due to need of full 64bit unsigned integers.\n",
                    "long": "--progress-json"
                },
                {
                    "name": "--timeout, -t <number of seconds>",
                    "content": "The number of seconds to wait before timeout on passphrase input via terminal. It is\nrelevant every time a passphrase is asked. It has no effect if used in conjunction with\n--key-file.\n\nThis option is useful when the system should not stall if the user does not input a\npassphrase, e.g. during boot. The default is a value of 0 seconds, which means to wait\nforever.\n",
                    "flag": "-t",
                    "long": "--timeout"
                },
                {
                    "name": "--tries, -T",
                    "content": "How often the input of the passphrase shall be retried. The default is 3 tries.\n",
                    "flag": "-T",
                    "long": "--tries"
                },
                {
                    "name": "--align-payload <number of 512 byte sectors>",
                    "content": "Align payload at a boundary of value 512-byte sectors.\n\nIf not specified, cryptsetup tries to use the topology info provided by the kernel for\nthe underlying device to get the optimal alignment. If not available (or the calculated\nvalue is a multiple of the default) data is by default aligned to a 1MiB boundary (i.e.\n2048 512-byte sectors).\n\nFor a detached LUKS header, this option specifies the offset on the data device. See also\nthe --header option.\n\nWARNING: This option is DEPRECATED and has often unexpected impact to the data offset and\nkeyslot area size (for LUKS2) due to the complex rounding. For fixed data device offset\nuse --offset option instead.\n",
                    "long": "--align-payload"
                },
                {
                    "name": "--uuid <UUID>",
                    "content": "When used in encryption mode use the provided UUID for the new LUKS header instead of\ngenerating a new one.\n\nLUKS1 (only in decryption mode): To find out what UUID to pass look for temporary files\nLUKS-UUID.[|log|org|new] of the interrupted decryption process.\n\nThe UUID must be provided in the standard UUID format, e.g.\n12345678-1234-1234-1234-123456789abc.\n",
                    "long": "--uuid",
                    "arg": "<UUID>"
                },
                {
                    "name": "--header <device or file storing the LUKS header>",
                    "content": "Use a detached (separated) metadata device or file where the LUKS header is stored. This\noption allows one to store ciphertext and LUKS header on different devices.\n\nIf used with --encrypt/--new option, the header file will be created (or overwritten).\nUse with care.\n\nLUKS2: For decryption mode the option may be used to export original LUKS2 header to a\ndetached file. The passed future file must not exist at the time of initializing the\ndecryption operation. This frees space in head of data device so that data can be moved\nat original LUKS2 header location. Later on decryption operation continues as if the\nordinary detached header was passed.\n\nWARNING: Never put exported header file in a filesystem on top of device you are about to\ndecrypt! It would cause a deadlock.\n",
                    "long": "--header",
                    "arg": "LUKS"
                },
                {
                    "name": "--force-offline-reencrypt (LUKS2 only)",
                    "content": "Bypass active device auto-detection and enforce offline reencryption.\n\nThis option is useful especially for reencryption of LUKS2 images put in files\n(auto-detection is not reliable in this scenario).\n\nIt may also help in case active device auto-detection on particular data device does not\nwork or report errors.\n\nWARNING: Use with extreme caution! This may destroy data if the device is activated\nand/or actively used.\n",
                    "long": "--force-offline-reencrypt"
                },
                {
                    "name": "--force-password",
                    "content": "Do not use password quality checking for new LUKS passwords.\n\nThis option is ignored if cryptsetup is built without password quality checking support.\n\nFor more info about password quality check, see the manual page for pwquality.conf(5) and\npasswdqc.conf(5).\n",
                    "long": "--force-password"
                },
                {
                    "name": "--disable-blkid",
                    "content": "Disable use of blkid library for checking and wiping on-disk signatures.\n",
                    "long": "--disable-blkid"
                },
                {
                    "name": "--disable-locks",
                    "content": "Disable lock protection for metadata on disk. This option is valid only for LUKS2 and\nignored for other formats.\n\nNOTE: With locking disabled LUKS2 images in files can be fully (re)encrypted offline\nwithout need for super user privileges provided used block ciphers are available in\ncrypto backend.\n\nWARNING: Do not use this option unless you run cryptsetup in a restricted environment\nwhere locking is impossible to perform (where /run directory cannot be used).\n",
                    "long": "--disable-locks"
                },
                {
                    "name": "--disable-keyring",
                    "content": "Do not load volume key in kernel keyring and store it directly in the dm-crypt target\ninstead. This option is supported only for the LUKS2 type.\n\n--sector-size bytes (LUKS2 only)\nReencrypt device with new encryption sector size enforced.\n\nWARNING: Increasing encryption sector size may break hosted filesystem. Do not run\nreencryption with --force-offline-reencrypt if unsure what block size was filesystem\nformatted with.\n",
                    "long": "--disable-keyring"
                },
                {
                    "name": "--label <LABEL> --subsystem <SUBSYSTEM>",
                    "content": "Set label and subsystem description for LUKS2 device. The label and subsystem are\noptional fields and can be later used in udev scripts for triggering user actions once\nthe device marked by these labels is detected.\n",
                    "long": "--subsystem",
                    "arg": "<SUBSYSTEM>"
                },
                {
                    "name": "--luks2-metadata-size <size>",
                    "content": "This option can be used to enlarge the LUKS2 metadata (JSON) area. The size includes 4096\nbytes for binary metadata (usable JSON area is smaller of the binary area). According to\nLUKS2 specification, only these values are valid: 16, 32, 64, 128, 256, 512, 1024, 2048\nand 4096 kB The <size> can be specified with unit suffix (for example 128k).\n",
                    "long": "--luks2-metadata-size",
                    "arg": "<size>"
                },
                {
                    "name": "--luks2-keyslots-size <size>",
                    "content": "This option can be used to set specific size of the LUKS2 binary keyslot area (key\nmaterial is encrypted there). The value must be aligned to multiple of 4096 bytes with\nmaximum size 128MB. The <size> can be specified with unit suffix (for example 128k).\n",
                    "long": "--luks2-keyslots-size",
                    "arg": "<size>"
                },
                {
                    "name": "--keyslot-cipher <cipher-spec>",
                    "content": "This option can be used to set specific cipher encryption for the LUKS2 keyslot area.\n",
                    "long": "--keyslot-cipher",
                    "arg": "<cipher-spec>"
                },
                {
                    "name": "--keyslot-key-size <bits>",
                    "content": "This option can be used to set specific key size for the LUKS2 keyslot area.\n",
                    "long": "--keyslot-key-size",
                    "arg": "<bits>"
                },
                {
                    "name": "--encrypt, --new, -N",
                    "content": "Initialize (and run) device in-place encryption mode.\n",
                    "flag": "-N",
                    "long": "--new"
                },
                {
                    "name": "--decrypt",
                    "content": "Initialize (and run) device decryption mode.\n",
                    "long": "--decrypt"
                },
                {
                    "name": "--init-only (LUKS2 only)",
                    "content": "Initialize reencryption (any mode) operation in LUKS2 metadata only and exit. If any\nreencrypt operation is already initialized in metadata, the command with --init-only\nparameter fails.\n",
                    "long": "--init-only"
                },
                {
                    "name": "--resume-only (LUKS2 only)",
                    "content": "Resume reencryption (any mode) operation already described in LUKS2 metadata. If no\nreencrypt operation is initialized, the command with --resume-only parameter fails.\nUseful for resuming reencrypt operation without accidentally triggering new reencryption\noperation.\n\n--resilience mode (LUKS2 only)\nReencryption resilience mode can be one of checksum, journal or none.\n\nchecksum: default mode, where individual checksums of ciphertext hotzone sectors are\nstored, so the recovery process can detect which sectors were already reencrypted. It\nrequires that the device sector write is atomic.\n\njournal: the hotzone is journaled in the binary area (so the data are written twice).\n\nnone: performance mode. There is no protection and the only way it’s safe to interrupt\nthe reencryption is similar to old offline reencryption utility.\n\nResilience modes can be changed unless datashift mode is used for operation\ninitialization (encryption with --reduce-device-size option)\n\n--resilience-hash hash (LUKS2 only)\nThe hash algorithm used with \"--resilience checksum\" only. The default hash is sha256.\nWith other resilience modes, the hash parameter is ignored.\n\n--hotzone-size size (LUKS2 only)\nThis option can be used to set an upper limit on the size of reencryption area (hotzone).\nThe size can be specified with unit suffix (for example 50M). Note that actual hotzone\nsize may be less than specified <size> due to other limitations (free space in keyslots\narea or available memory).\n\nWith decryption mode for devices with LUKS2 header placed in head of data device, the\noption specifies how large is the first data segment moved from original data offset\npointer.\n\n--reduce-device-size size\nThis means that last size sectors on the original device will be lost, data will be\neffectively shifted by specified number of sectors.\n\nIt could be useful if you added some space to underlying partition or logical volume (so\nlast size sectors contains no data).\n\nFor units suffix see --device-size parameter description.\n\nWARNING: This is a destructive operation and cannot be reverted. Use with extreme care -\naccidentally overwritten filesystems are usually unrecoverable.\n\nLUKS2: Initialize LUKS2 reencryption with data device size reduction (currently only\nencryption mode is supported).\n\nRecommended minimal size is twice the default LUKS2 header size (--reduce-device-size\n32M) for encryption mode.\n\nLUKS1: Enlarge data offset to specified value by shrinking device size.\n\nYou cannot shrink device more than by 64 MiB (131072 sectors).\n",
                    "long": "--resume-only"
                },
                {
                    "name": "--batch-mode, -q",
                    "content": "Suppresses all confirmation questions. Use with care!\n\nIf the --verify-passphrase option is not specified, this option also switches off the\npassphrase verification.\n",
                    "flag": "-q",
                    "long": "--batch-mode"
                },
                {
                    "name": "--debug or --debug-json",
                    "content": "Run in debug mode with full diagnostic logs. Debug output lines are always prefixed by #.\n\nIf --debug-json is used, additional LUKS2 JSON data structures are printed.\n",
                    "long": "--debug-json"
                },
                {
                    "name": "--version, -V",
                    "content": "Show the program version.\n",
                    "flag": "-V",
                    "long": "--version"
                },
                {
                    "name": "--usage",
                    "content": "Show short option help.\n",
                    "long": "--usage"
                },
                {
                    "name": "--help, -?",
                    "content": "Show help text and default parameters.\n",
                    "flag": "-?",
                    "long": "--help"
                }
            ]
        },
        "EXAMPLES": {
            "content": "NOTE: You may drop --type luks2 option as long as LUKS2 format is default.\n\nLUKS2 ENCRYPTION EXAMPLES\nEncrypt LUKS2 device (in-place). Make sure last 32 MiB on /dev/plaintext is unused (e.g.:\ndoes not contain filesystem data):\n",
            "subsections": [
                {
                    "name": "cryptsetup reencrypt --encrypt --type luks2 --reduce-device-size 32m /dev/plaintext_device",
                    "content": "Encrypt LUKS2 device (in-place) with detached header put in a file:\n"
                },
                {
                    "name": "cryptsetup reencrypt --encrypt --type luks2 --header my_luks2_header /dev/plaintext_device",
                    "content": "Initialize LUKS2 in-place encryption operation only and activate the device (not yet\nencrypted):\n"
                },
                {
                    "name": "cryptsetup reencrypt --encrypt --type luks2 --init-only --reduce-device-size 32m",
                    "content": ""
                },
                {
                    "name": "/dev/plaintext_device my_future_luks_device",
                    "content": "Resume online encryption on device initialized in example above:\n\ncryptsetup reencrypt --resume-only /dev/plaintextdevice or cryptsetup reencrypt"
                },
                {
                    "name": "--active-name my_future_luks_device",
                    "content": "LUKS2 REENCRYPTION EXAMPLES\nReencrypt LUKS2 device (refresh volume key only):\n",
                    "long": "--active-name"
                },
                {
                    "name": "cryptsetup reencrypt /dev/encrypted_device",
                    "content": "LUKS2 DECRYPTION EXAMPLES\nDecrypt LUKS2 device with header put in head of data device (header file does not exist):\n"
                },
                {
                    "name": "cryptsetup reencrypt --decrypt --header /export/header/to/file /dev/encrypted_device",
                    "content": "Decrypt LUKS2 device with detached header (header file exists):\n"
                },
                {
                    "name": "cryptsetup reencrypt --decrypt --header detached-luks2-header /dev/encrypted_device",
                    "content": "Resume interrupted LUKS2 decryption:\n"
                },
                {
                    "name": "cryptsetup reencrypt --resume-only --header luks2-hdr-file /dev/encrypted_device",
                    "content": ""
                }
            ]
        },
        "REPORTING BUGS": {
            "content": "Report bugs at cryptsetup mailing list <cryptsetup@lists.linux.dev> or in Issues project\nsection <https://gitlab.com/cryptsetup/cryptsetup/-/issues/new>.\n\nPlease attach output of the failed command with --debug option added.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "Cryptsetup FAQ <https://gitlab.com/cryptsetup/cryptsetup/wikis/FrequentlyAskedQuestions>\n\ncryptsetup(8), integritysetup(8) and veritysetup(8)\n",
            "subsections": []
        },
        "CRYPTSETUP": {
            "content": "Part of cryptsetup project <https://gitlab.com/cryptsetup/cryptsetup/>.\n\ncryptsetup 2.7.0                             2024-11-14                      CRYPTSETUP-REENCRYPT(8)",
            "subsections": []
        }
    },
    "summary": "cryptsetup-reencrypt - reencrypt LUKS encrypted volumes in-place",
    "flags": [
        {
            "flag": "",
            "long": "--use-directio",
            "arg": null,
            "description": "Use direct-io (ODIRECT) for all read/write data operations related to block device undergoing reencryption. Useful if direct-io operations perform better than normal buffered operations (e.g. in virtual environments)."
        },
        {
            "flag": "",
            "long": "--use-fsync",
            "arg": null,
            "description": "Use fsync call after every written block. This applies for reencryption log files as well."
        },
        {
            "flag": "",
            "long": "--write-log",
            "arg": null,
            "description": "Update log file after every block write. This can slow down reencryption but will minimize data loss in the case of system crash."
        },
        {
            "flag": "",
            "long": "--type",
            "arg": "<device-type>",
            "description": "Specifies required (encryption mode) or expected (other modes) LUKS format. Accepts only luks1 or luks2. --hash, -h <hash-spec> LUKS1: Specifies the hash used in the LUKS1 key setup scheme and volume key digest. NOTE: if this parameter is not specified, default hash algorithm is always used for new LUKS1 device header. LUKS2: Ignored unless new keyslot pbkdf algorithm is set to PBKDF2 (see --pbkdf). --cipher, -c <cipher-spec> LUKS2: Set the cipher specification string for data segment only. LUKS1: Set the cipher specification string for data segment and keyslots. NOTE: 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 \"ciphernull\". In that case default cipher would be applied as in encrypt mode. cryptsetup --help shows 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 -s option. Key size for XTS mode is twice that for other modes for the same security level."
        },
        {
            "flag": "-y",
            "long": "--verify-passphrase",
            "arg": null,
            "description": "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. --key-file, -d name Read the passphrase from file. If the name given is \"-\", then the passphrase will be read from stdin. In this case, reading will not stop at newline characters. 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 will ask for all active keyslot passphrases. --keyfile-offset value Skip value bytes at the beginning of the key file. --keyfile-size, -l value Read a maximum of value 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. This option is useful to cut trailing newlines, for example. If --keyfile-offset is also given, the size count starts after the offset."
        },
        {
            "flag": "",
            "long": "--master-key-file",
            "arg": null,
            "description": "Use (set) new volume key stored in a file. WARNING: 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. --use-random, --use-urandom Define which kernel random number generator will be used to create the volume key."
        },
        {
            "flag": "",
            "long": "--keep-key",
            "arg": null,
            "description": "LUKS2: Do not change effective volume key and change other parameters provided it is requested. LUKS1: Reencrypt only the LUKS1 header and keyslots. Skips data in-place reencryption."
        },
        {
            "flag": "-S",
            "long": "--key-slot",
            "arg": "<0-N>",
            "description": "For LUKS operations that add key material, this option allows you to specify which key slot is selected for the new key. 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. 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. --key-size, -s bits Sets key size in bits. The argument has to be a multiple of 8. The possible key-sizes are limited by the cipher and mode used. See /proc/crypto for more information. Note that key-size in /proc/crypto is stated in bytes. LUKS1: 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."
        },
        {
            "flag": "-o",
            "long": "--offset",
            "arg": null,
            "description": "Start offset in the backend device in 512-byte sectors. This option is only relevant for the encrypt mode. 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. --device-size size[units] 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. WARNING: This is destructive operation. Data beyond --device-size limit may be lost after operation gets finished. 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)."
        },
        {
            "flag": "",
            "long": "--pbkdf",
            "arg": null,
            "description": "Set Password-Based Key Derivation Function (PBKDF) algorithm for LUKS keyslot. The PBKDF can be: pbkdf2 (for PBKDF2 according to RFC2898), argon2i for Argon2i or argon2id for Argon2id (see Argon2 <https://www.cryptolux.org/index.php/Argon2> for more info). 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 cryptsetup --help output. A PBKDF is used for increasing dictionary and brute-force attack cost for keyslot passwords. The parameters can be time, memory and parallel cost. 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. 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 (--iter-time) with required memory cost --pbkdf-memory. If it is not possible, the memory cost is decreased as well. The parallel cost --pbkdf-parallel is constant and is checked against available CPU cores. You can see all PBKDF parameters for particular LUKS2 keyslot with cryptsetup-luksDump(8) command. NOTE: If you do not want to use benchmark and want to specify all parameters directly, use --pbkdf-force-iterations with --pbkdf-memory and --pbkdf-parallel. This will override the values without benchmarking. Note it can cause extremely long unlocking time or cause out-of-memory conditions with unconditional process termination. Use only in specific cases, for example, if you know that 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 maximum is 4294967295 (maximum for 32bit unsigned integer). Memory and parallel costs are unused for PBKDF2. For Argon2i and Argon2id, 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)."
        },
        {
            "flag": "-i",
            "long": "--iter-time",
            "arg": null,
            "description": "The number of milliseconds to spend with PBKDF passphrase processing for the new LUKS header."
        },
        {
            "flag": "",
            "long": "--pbkdf-memory",
            "arg": "<number>",
            "description": "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."
        },
        {
            "flag": "",
            "long": "--pbkdf-parallel",
            "arg": "<number>",
            "description": "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."
        },
        {
            "flag": "",
            "long": "--pbkdf-force-iterations",
            "arg": "<num>",
            "description": "Avoid PBKDF benchmark and set time cost (iterations) directly. It can be used for LUKS/LUKS2 device only. See --pbkdf option for more info. --progress-frequency seconds Print separate line every seconds with reencryption progress."
        },
        {
            "flag": "",
            "long": "--progress-json",
            "arg": null,
            "description": "Prints progress data in JSON format suitable mostly for machine processing. It prints separate line every half second (or based on --progress-frequency value). The JSON output looks as follows during progress (except it’s compact single line): { \"device\":\"/dev/sda\" // backing device or file \"devicebytes\":\"8192\", // bytes of I/O so far \"devicesize\":\"44040192\", // total bytes of I/O to go \"speed\":\"126877696\", // calculated speed in bytes per second (based on progress so far) \"etams\":\"2520012\" // estimated time to finish an operation in milliseconds \"timems\":\"5561235\" // total time spent in IO operation in milliseconds } 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."
        },
        {
            "flag": "-t",
            "long": "--timeout",
            "arg": null,
            "description": "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. 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."
        },
        {
            "flag": "-T",
            "long": "--tries",
            "arg": null,
            "description": "How often the input of the passphrase shall be retried. The default is 3 tries."
        },
        {
            "flag": "",
            "long": "--align-payload",
            "arg": null,
            "description": "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 --header option. WARNING: 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 --offset option instead."
        },
        {
            "flag": "",
            "long": "--uuid",
            "arg": "<UUID>",
            "description": "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."
        },
        {
            "flag": "",
            "long": "--header",
            "arg": "LUKS",
            "description": "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. If used with --encrypt/--new option, the header file will be created (or overwritten). Use with care. LUKS2: 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. WARNING: Never put exported header file in a filesystem on top of device you are about to decrypt! It would cause a deadlock."
        },
        {
            "flag": "",
            "long": "--force-offline-reencrypt",
            "arg": null,
            "description": "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 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."
        },
        {
            "flag": "",
            "long": "--force-password",
            "arg": null,
            "description": "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) and passwdqc.conf(5)."
        },
        {
            "flag": "",
            "long": "--disable-blkid",
            "arg": null,
            "description": "Disable use of blkid library for checking and wiping on-disk signatures."
        },
        {
            "flag": "",
            "long": "--disable-locks",
            "arg": null,
            "description": "Disable lock protection for metadata on disk. This option is valid only for LUKS2 and ignored for other formats. NOTE: 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. WARNING: 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)."
        },
        {
            "flag": "",
            "long": "--disable-keyring",
            "arg": null,
            "description": "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. --sector-size bytes (LUKS2 only) Reencrypt device with new encryption sector size enforced. WARNING: 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."
        },
        {
            "flag": "",
            "long": "--subsystem",
            "arg": "<SUBSYSTEM>",
            "description": "Set label and subsystem description for LUKS2 device. The label and subsystem are optional fields and can be later used in udev scripts for triggering user actions once the device marked by these labels is detected."
        },
        {
            "flag": "",
            "long": "--luks2-metadata-size",
            "arg": "<size>",
            "description": "This option can be used to enlarge the LUKS2 metadata (JSON) area. The size includes 4096 bytes for binary metadata (usable JSON area is smaller of the binary area). According to LUKS2 specification, only these values are valid: 16, 32, 64, 128, 256, 512, 1024, 2048 and 4096 kB The <size> can be specified with unit suffix (for example 128k)."
        },
        {
            "flag": "",
            "long": "--luks2-keyslots-size",
            "arg": "<size>",
            "description": "This option can be used to set specific size of the LUKS2 binary keyslot area (key material is encrypted there). The value must be aligned to multiple of 4096 bytes with maximum size 128MB. The <size> can be specified with unit suffix (for example 128k)."
        },
        {
            "flag": "",
            "long": "--keyslot-cipher",
            "arg": "<cipher-spec>",
            "description": "This option can be used to set specific cipher encryption for the LUKS2 keyslot area."
        },
        {
            "flag": "",
            "long": "--keyslot-key-size",
            "arg": "<bits>",
            "description": "This option can be used to set specific key size for the LUKS2 keyslot area."
        },
        {
            "flag": "-N",
            "long": "--new",
            "arg": null,
            "description": "Initialize (and run) device in-place encryption mode."
        },
        {
            "flag": "",
            "long": "--decrypt",
            "arg": null,
            "description": "Initialize (and run) device decryption mode."
        },
        {
            "flag": "",
            "long": "--init-only",
            "arg": null,
            "description": "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."
        },
        {
            "flag": "",
            "long": "--resume-only",
            "arg": null,
            "description": "Resume reencryption (any mode) operation already described in LUKS2 metadata. If no reencrypt operation is initialized, the command with --resume-only parameter fails. Useful for resuming reencrypt operation without accidentally triggering new reencryption operation. --resilience mode (LUKS2 only) Reencryption resilience mode can be one of checksum, journal or none. checksum: 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 old offline reencryption utility. Resilience modes can be changed unless datashift mode is used for operation initialization (encryption with --reduce-device-size option) --resilience-hash hash (LUKS2 only) The hash algorithm used with \"--resilience checksum\" only. The default hash is sha256. With other resilience modes, the hash parameter is ignored. --hotzone-size size (LUKS2 only) This option can be used to set an upper limit on the size of reencryption area (hotzone). The size can be specified with unit suffix (for example 50M). Note that actual hotzone size may be less than specified <size> due to other limitations (free space in keyslots area or available memory). With decryption mode for devices with LUKS2 header placed in head of data device, the option specifies how large is the first data segment moved from original data offset pointer. --reduce-device-size size This means that last size sectors on the original device will be lost, data will be effectively shifted by specified number of sectors. It could be useful if you added some space to underlying partition or logical volume (so last size sectors contains no data). For units suffix see --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). Recommended minimal size is twice the default LUKS2 header size (--reduce-device-size 32M) for encryption mode. LUKS1: Enlarge data offset to specified value by shrinking device size. You cannot shrink device more than by 64 MiB (131072 sectors)."
        },
        {
            "flag": "-q",
            "long": "--batch-mode",
            "arg": null,
            "description": "Suppresses all confirmation questions. Use with care! If the --verify-passphrase option is not specified, this option also switches off the passphrase verification."
        },
        {
            "flag": "",
            "long": "--debug-json",
            "arg": null,
            "description": "Run in debug mode with full diagnostic logs. Debug output lines are always prefixed by #. If --debug-json is used, additional LUKS2 JSON data structures are printed."
        },
        {
            "flag": "-V",
            "long": "--version",
            "arg": null,
            "description": "Show the program version."
        },
        {
            "flag": "",
            "long": "--usage",
            "arg": null,
            "description": "Show short option help."
        },
        {
            "flag": "-?",
            "long": "--help",
            "arg": null,
            "description": "Show help text and default parameters."
        }
    ],
    "examples": [
        "NOTE: You may drop --type luks2 option as long as LUKS2 format is default.",
        "LUKS2 ENCRYPTION EXAMPLES",
        "Encrypt LUKS2 device (in-place). Make sure last 32 MiB on /dev/plaintext is unused (e.g.:",
        "does not contain filesystem data):",
        "Encrypt LUKS2 device (in-place) with detached header put in a file:",
        "Initialize LUKS2 in-place encryption operation only and activate the device (not yet",
        "encrypted):",
        "Resume online encryption on device initialized in example above:",
        "cryptsetup reencrypt --resume-only /dev/plaintextdevice or cryptsetup reencrypt",
        "LUKS2 REENCRYPTION EXAMPLES",
        "Reencrypt LUKS2 device (refresh volume key only):",
        "LUKS2 DECRYPTION EXAMPLES",
        "Decrypt LUKS2 device with header put in head of data device (header file does not exist):",
        "Decrypt LUKS2 device with detached header (header file exists):",
        "Resume interrupted LUKS2 decryption:"
    ],
    "see_also": [
        {
            "name": "cryptsetup",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/cryptsetup/8/json"
        },
        {
            "name": "integritysetup",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/integritysetup/8/json"
        },
        {
            "name": "veritysetup",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/veritysetup/8/json"
        }
    ]
}