LUKS Headers, Keyslots and Volume-Key Recovery
LUKS keeps the volume key of a dm-crypt data area behind one or more keyslots. Reaching it needs header metadata, intact keyslot material, a credential that opens a slot and a data area that still uses that key — so a header backup is valuable, but only for the volume state it was taken from.
- Access needs coherent metadata, an intact keyslot, a credential that opens it, and a data area still using that volume key.
- LUKS2 stores its metadata twice, but the binary keyslot area has no second copy; metadata redundancy is not a keyslot backup.
- An old header backup with a then-valid passphrase can still work, unless re-encryption or a key or layout change followed.
- Restore, repair and re-encryption change the source; preserve current header and keyslot bytes first and test backups on separate copies.
- A successful unlock proves the key path, not the files; damaged or overwritten ciphertext still decrypts to damaged data.
A separate volume key
LUKS is a key-management format above dm-crypt. The passphrase or key file is not the sector key: with the salt and parameters from the header it goes through a key-derivation function, the derived key decrypts a keyslot’s binary area, and the result counts as the volume key only if it matches the digest in the metadata (LUKS2 specification, “Keyslot Content Retrieval”). A passphrase change therefore rewrites keyslot material and leaves the volume key and data area alone. A volume-key change is a different event: cryptsetup-luksDump(8) notes that the key cannot be changed without re-encryption, and that the volume key alone decrypts the data without a passphrase or even the header.
LUKS1 and LUKS2 differ
- LUKS1. One binary header at the start of the device, eight keyslots in fixed positions behind it, PBKDF2 only. The cryptsetup FAQ notes that the salts sit in the first sector, so overwriting it — an accidental format, for example — typically makes a LUKS1 volume permanently inaccessible without a header backup (items 6.8, 6.9).
- LUKS2, the default in current cryptsetup (cryptsetup(8)). A small binary header plus a JSON area describing keyslots, digests, data segments, tokens and configuration. Binary header and JSON are stored twice, as primary and secondary copies; keyslots are no longer at fixed positions. The binary keyslot area is allocated on demand and, as the specification states, deliberately has no redundancy.
So the two LUKS2 metadata copies are not a backup of the keyslot bytes, and not of any data. Damage can leave the metadata recoverable from the second copy while the keyslot it describes is gone; the FAQ says only that a quick-formatted LUKS2 volume may still be recoverable without a backup. Keyslots are fragile by design: the anti-forensic splitting that makes them erasable means a few changed bits can make one unrecoverable (FAQ 6.8), and cryptsetup-repair(8) states that a corrupted keyslot can only come back from a header backup.
Which combinations can still reach the data
Intake is more useful when it records which of the four kinds of material exist — header metadata, keyslot bytes, a credential or token path, and a data area that matches them — and where and when each copy came from, than when it starts from “the password does not work”.
Scroll horizontally to see the full table →
| Situation | What it can give | What it does not settle |
|---|---|---|
| Header and keyslots intact; credential for one enrolled slot | The volume key and a decrypted view | Whether data area and filesystem are undamaged |
| Metadata readable; slot for the known credential damaged | Access only through another intact slot with its own credential or token | The damaged slot: repair does not rebuild keyslot material |
| Keyslot intact; no credential or working token path | Nothing by itself: the slot is encrypted under a key derived from the credential | Which other credentials were ever enrolled |
| Live slots changed or overwritten; older backup and a passphrase valid when it was taken | The volume key, if the data area still uses it | Compatibility after re-encryption, key change or layout change |
| LUKS2: one metadata copy damaged, the other intact | Usable metadata, if the keyslot area also survived | The keyslot bytes, which have no second copy |
| Header lost; volume key preserved separately | Decryption without passphrase or header, given the right cipher settings and offset | The state of the data area |
| Key path intact; parts of the data area unreadable or overwritten | Unlock works; surviving sectors decrypt | Files that touch the damaged ranges |
| No LUKS header visible on the data device | Ciphertext, possibly with a detached header elsewhere | Whether a header was destroyed, moved or never stored there |
Keyslots, credentials and tokens
LUKS1 has eight keyslots; LUKS2 allows more (the reference implementation caps them at 32). Each can hold a different passphrase or key file for the same volume key, so losing one passphrase does not lose the volume if another enrolled slot and its credential survive. The reverse also holds: an intact slot without the passphrase, key file or token path that opens it does not yield the volume key, and even with it the slot needs coherent metadata — salt, KDF parameters, area offset, digest.
LUKS2 tokens are JSON objects assigned to keyslots that the specification describes as saying how to get a passphrase; their content is implementation-specific, and a token is not necessarily the secret. cryptsetup’s keyring token only names a kernel-keyring entry where the passphrase must already be loaded (cryptsetup-token(8)), and a passphrase held in a running system’s keyring is not an on-disk token. Hardware-backed unlock is a separate integration: systemd-cryptenroll, for instance, enrolls TPM2, FIDO2 and PKCS#11 devices into LUKS2 volumes only, and whether such a path still works depends on the device, its state and the integration version. Intake should ask how the volume was actually unlocked rather than assume a password was the only path.
Metadata copies and sequence IDs
Each LUKS2 binary header carries a sequence ID, a checksum over the binary header and JSON area, a UUID and its own device offset. The specification states that the sequence ID increases with every update, that the copy with the higher value is used automatically when the two differ, and that updates keep at least one copy valid if a write is interrupted.
Use these fields after identity and meaning are confirmed: the copy belongs to this device (UUID, header offset, a data segment that fits it) and the tool reads that version correctly. Even then, the highest sequence ID shows which copy was written last — not that it is the state the owner needs, nor that the keyslot area or ciphertext survived. The specification adds that checksums and redundancy guard against random corruption only. Choosing between generations in general is covered in Storage Metadata Generations.
Detached headers and the data offset
The header can be stored on another device or in a file, and the specification notes that the encrypted device then contains no visible or detectable metadata. Missing LUKS magic on a data device is therefore not proof that a header was destroyed. The data offset matters as much: with a detached header it is set separately (cryptsetup-luksFormat(8)), a header restore requires matching data offset and key size, and cryptsetup-open(8) warns that nothing checks whether the ciphertext device belongs to the header given. Keep the link between specific bytes and their source — device or file, offset, partition layout, acquisition — rather than a matching filename or UUID, which clones share.
What an old header backup can do
cryptsetup-luksHeaderBackup(8) writes the header and keyslot area to a separate file and states that the backup plus a passphrase valid at the time allow decryption even if that passphrase was later changed or removed. An old backup may thus hold a keyslot state the live header no longer has. That holds only while the data area still uses the same volume key and layout. cryptsetup-reencrypt(8) can regenerate the volume key or keep it while changing other parameters, and recreating a header produces a new volume key even with the same passphrase (FAQ 6.6). After re-encryption, a key change, a recreated header or a layout change, an older backup cannot be assumed to match; an interrupted LUKS2 re-encryption leaves segments in different stages that a pre-operation backup knows nothing about.
The same property makes backups sensitive. Keeping one undoes the removal of an old passphrase, and the man page states that the device can then no longer be wiped just by overwriting header and keyslots. A preserved volume key is stronger still. Keep backups, volume keys and credentials apart from each other and from case notes, under controlled access; record what each belongs to, but never paste dumps, keys or passphrases into tickets or reports.
Operations that change the source
A header backup reads the device and writes a separate file. The other operations change the source:
- Header restore replaces all keyslots, so only the backup’s passphrases work afterward (cryptsetup-luksHeaderRestore(8)) — slot states that were still useful are lost.
- Repair handles some known benign header corruptions and unused-slot damage, changes the header but not keyslot data, and can recover an interrupted LUKS2 re-encryption; its man page asks for a binary header backup first.
- Adding or removing keyslots rewrites metadata and keyslot areas; removal overwrites the slot’s binary area.
- Re-encryption rewrites the data area in place.
Opening is not automatically neutral either. Recovery of an interrupted re-encryption runs automatically on the next activation (cryptsetup-reencrypt(8); FAQ 10.8), activation with persistent options writes flags into the metadata, and a read-only option describes the mapping, not the header. Check the behaviour of the specific version and state in its documentation, and otherwise assume it can write.
So: first preserve the current readable header and keyslot bytes — with the rest of the device where its condition allows, see What a Disk Image Preserves — and note any re-encryption state. Then test a candidate backup against a separate copy through the supported detached-header mechanism, not by restoring it onto the source. The FAQ gives the same advice: back up the current header before restoring an uncertain one, and test a header file without restoring it (item 6.2).
Unlocking is not the end
Encryption adds a layer, not a fixed sequence. Partition tables, geometry and the LUKS metadata can be examined before any unlock; filesystem structures only in the correct decrypted representation — right key, cipher settings and offset over the right ciphertext. That does not require in-place decryption; a mapping over a copy or an export serves. Where a decrypted view exists only temporarily, such as an unlocked running system with no other known credential, preserving it may come first (see Live Systems, Snapshots and Consistent Recovery Copies).
A successful unlock confirms the key path, not the data: with lost or overwritten sectors it still succeeds, while files across those ranges stay damaged. Validate that it is the right volume, that filesystem metadata and the required files are present and consistent, and which files the known missing ranges affect (How to Validate Recovered Data).
Treat a LUKS header backup as key material tied to one volume state: preserve the current header first, test older backups on a separate copy, and judge the result by the files, not by the unlock.
Technical references: LUKS2 On-Disk Format Specification — metadata copies, keyslot area, sequence ID, tokens · cryptsetup-luksHeaderBackup(8) — old passphrase plus backup; wiping · cryptsetup-luksHeaderRestore(8) — replaces all keyslots; offset must match · cryptsetup-reencrypt(8) — in place, volume key, recovery on open · cryptsetup FAQ — LUKS1 header damage, testing backups. Other cryptsetup pages are cited inline. Man pages checked October 2026 in their cryptsetup 2.9.0-git versions, the specification in version 1.1.4 (June 2025); other releases and distribution integrations can behave differently.
Related: Encryption Key Hierarchies and Recovery Metadata · Locked Out of an Encrypted Volume · ext4 Superblocks, Inodes, Extents and Journal · File-System Recovery vs. File Carving · Encryption and Ransomware Recovery Tools