Skip to content

Troubleshooting

The failures the lab met for real, plus the documented ones a real machine adds. Transcripts are named per entry; messages are quoted verbatim, because with this tool the message (or its absence) is the diagnosis.

"No key available with this passphrase."

$ cryptsetup open --test-passphrase --key-file pass-wrong.txt vault.img
No key available with this passphrase.
(exit code 2)

Three causes, in the order the lab met them. The passphrase is wrong — a typo, the wrong vault's passphrase, caps lock's eternal campaign. The key file's bytes are not what you think — the newline trap of chapter 7: an extra \n makes a different key, and wc -c finds it. The slot is gone — killed or changed earlier; the header backup you took afterwards remembers what the current header has forgotten (chapter 8). Test with --test-passphrase first; it is the only variant that always explains itself, which brings us to —

The command fails silently, exit 2

luksAddKey with a wrong unlocking passphrase prints nothing and exits 2 (t03), where --test-passphrase with the same wrong key speaks plainly. This is a mannerism, not a malfunction: several cryptsetup operations report failure only through the exit code when the failing step is the initial unlock. When any slot operation fails, re-run the unlock half alone as a test-passphrase check and let it tell you why.

"Device … is not a valid LUKS device."

$ cryptsetup luksDump vault-copy.img
Device vault-copy.img is not a valid LUKS device.

Either the device never was LUKS — the wrong disk, or a partition where the LUKS header is on its parent — or the header is destroyed (t05's second wound). isLuks and a hex look at the first bytes (a live LUKS device begins with the magic LUKS) separate the two. If it was yours and the header is gone, the only road back is luksHeaderRestore from a backup taken in better days. Without one, chapter 15 has the whole of the bad news, and it is short.

"No usable keyslot is available."

The header is intact and readable, and every slot in it is dead — the state after cryptsetup erase (t12), or after the last slot was killed by hand. This is not a failure to be repaired; it is the wipe working as designed. Data recovery services cannot help, by the same mathematics as chapter 8.

"Cannot initialize device-mapper. Is dm_mod kernel module loaded?"

The lab's own boundary (t08), and yours if you meet it: the machine cannot create mappings — a container or sandbox without device-mapper, a kernel without the module, or a rescue environment that has not loaded it (modprobe dm_mod is the first try on a real system). Its sibling, Cannot use device <name>, name is invalid or still in use, also appears on healthy machines when a mapping with that name is already open — check ls /dev/mapper before blaming the kernel.

"Key slot 32 is invalid, please select between 0 and 31."

You asked LUKS1 for a ninth slot, or LUKS2 for a thirty-third (t09). The message is the specification: LUKS1 slots are 0–7, LUKS2 slots are 0–31, and no flag enlarges either.

"keyslot operation could fail as it requires more than available memory"

A warning, not yet a failure: Argon2 wants its ~100 MB (chapter 4) and the machine is crowded — the lab's shared sandbox printed it on most slot operations and succeeded anyway. If the operation does fail on a small machine, the honest levers are freeing memory or choosing PBKDF2 for that slot (luksConvertKey --pbkdf pbkdf2, chapter 12), knowing the guessing-resistance you are spending (chapter 11).

Boot asks for the wrong disk, or not at all

Documented territory (chapter 9): a UUID in crypttab that does not match luksUUID's answer, a nofail swallowing the prompt you expected, or an fstab line mounting a name that was never opened. The vault itself is untouched by all three — open it by hand (chapter 5) and fix the paperwork at leisure. And if a restored header rejects a passphrase you are sure of, suspect the calendar before your memory: the backup restores the slots of its day, and a passphrase added or changed since then is not in it.