{
    "mode": "man",
    "parameter": "cryptsetup-repair",
    "section": "8",
    "url": "https://www.chedong.com/phpMan.php/man/cryptsetup-repair/8/json",
    "generated": "2026-10-07T13:26:37Z",
    "synopsis": "cryptsetup repair [<options>] <device>",
    "sections": {
        "NAME": {
            "content": "cryptsetup-repair - repair the device metadata\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "cryptsetup repair [<options>] <device>\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Tries to repair the device metadata if possible. Currently supported only for LUKS device\ntype.\n\nThis command is useful to fix some known benign LUKS metadata header corruptions. Only basic\ncorruptions of unused keyslot are fixable. This command will only change the LUKS header, not\nany key-slot data. You may enforce LUKS version by adding --type option.\n\nIt also repairs (upgrades) LUKS2 reencryption metadata by adding a metadata digest that\nprotects it against malicious changes.\n\nIf LUKS2 reencryption was interrupted in the middle of writing reencryption segment the\nrepair command can be used to perform reencryption recovery so that reencryption can continue\nlater. Repairing reencryption requires verification of reencryption keyslot so passphrase or\nkeyfile is needed.\n\n<options> can be [--timeout, --verify-passphrase, --disable-locks, --type, --header,\n--key-file, --keyfile-size, --keyfile-offset, --key-slot].\n\nWARNING: Always create a binary backup of the original header before calling this command.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "--type <device-type>",
                    "content": "Specifies required device type, for more info read BASIC ACTIONS section in\ncryptsetup(8).\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\nSee section NOTES ON PASSPHRASE PROCESSING in cryptsetup(8) for more information.\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": "--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\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",
                    "flag": "-S",
                    "long": "--key-slot",
                    "arg": "<0-N>"
                },
                {
                    "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": "--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\nFor commands that change the LUKS header (e.g. luksAddKey), specify the device or file\nwith the LUKS header directly as the LUKS device.\n",
                    "long": "--header",
                    "arg": "LUKS"
                },
                {
                    "name": "--disable-locks",
                    "content": "Disable lock protection for metadata on disk. This option is valid only for LUKS2 and\nignored for other formats.\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": "--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"
                }
            ]
        },
        "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-REPAIR(8)",
            "subsections": []
        }
    },
    "summary": "cryptsetup-repair - repair the device metadata",
    "flags": [
        {
            "flag": "",
            "long": "--type",
            "arg": "<device-type>",
            "description": "Specifies required device type, for more info read BASIC ACTIONS section in cryptsetup(8)."
        },
        {
            "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. See section NOTES ON PASSPHRASE PROCESSING in cryptsetup(8) for more information. --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": "-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. 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."
        },
        {
            "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": "",
            "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. For commands that change the LUKS header (e.g. luksAddKey), specify the device or file with the LUKS header directly as the LUKS device."
        },
        {
            "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. 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": "-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": [],
    "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"
        }
    ]
}