Recovery
What to do when you lose access to a vault.
TL;DR
Recovery is only possible if you set up a backup keyslot in advance. LUKSbox cannot recover a vault from the disk alone - that's the whole point of encryption.
If you set things up right, recovery is straightforward:
- Lost YubiKey, have a backup passphrase: unlock with the passphrase, enroll a new device, optionally revoke the lost slot.
- Forgot passphrase, have a working YubiKey: unlock with the device, enroll a new passphrase, revoke the old slot.
- Lost both: you cannot recover. There is no master backdoor.
Setting up for recoverability (do this BEFORE you need it)
For any vault you'd be sad to lose:
# 1. Create with FIDO2 (slot 0)
luksbox create my.lbx --kind fido2
# 2. Add a backup passphrase (unlock with the FIDO2 device)
luksbox enroll my.lbx --fido2 --kind passphrase
# 3. Enroll a SECOND FIDO2 device (kept in a safe deposit box, etc.):
# unlock with the backup passphrase, register the second device.
# `luksbox list-fido2-devices` shows the path to pass here.
luksbox enroll my.lbx --kind fido2 --fido2-device /dev/hidraw4
# Optional: write the backup passphrase on paper, store separately
Now the vault has 3 keyslots. Loss of any 2 still leaves the third.
--fido2 tells a command to unlock with a FIDO2 keyslot; --kind
picks the kind of the new slot enroll adds (passphrase by
default). luksbox enroll my.lbx --fido2 therefore adds a passphrase
slot, not a FIDO2 one.
Lost device
# Unlock with the backup passphrase and enroll a replacement device
luksbox enroll my.lbx --kind fido2
# Find the lost device's slot index
luksbox info my.lbx
# Revoke the lost slot (won't actually erase what an attacker who has
# the device might have already extracted - see rotate-mvk below if
# you're worried about that)
luksbox revoke my.lbx --slot 0
# If you suspect the lost device was actually stolen + the attacker
# might have your backup passphrase too, rotate the MVK so any
# previously-extracted keys become useless:
luksbox rotate-mvk my.lbx
Revoking removes the keyslot from the vault, but an older copy of the header (a backup, a cloud sync history) still has it. Two things protect you:
rotate-mvk(above) makes every older header useless against the current contents.- On a header format v3 vault (the default since 0.6.0), run
revokewith--anchor <file>: the anchor records the change, and every later open with--anchorrefuses an older header put back over the vault (header rollback detected), so the revoked keyslot cannot quietly return. On a header v2 vault the anchor cannot see this;luksbox upgrade-headermoves it to v3.
Forgotten passphrase
# Unlock with the FIDO2 device and enroll a new passphrase
luksbox enroll my.lbx --fido2 --kind passphrase
# Revoke the old passphrase slot
luksbox info my.lbx # find slot index
luksbox revoke my.lbx --fido2 --slot <N>
Lost the .kyber seed file (hybrid-PQ vault)
The .kyber seed is required to derive the PQ shared secret. Without
it, the hybrid-PQ slot is dead - no recovery possible from the slot
alone.
If you have a non-hybrid keyslot in the same vault (passphrase or
plain FIDO2), unlock with it and add a new hybrid-PQ slot with a fresh
seed. The luksbox enroll command can't add passphrase or FIDO2
hybrid-PQ slots, so use the wizard (or the GUI's Add passphrase +
ML-KEM keyslot button):
luksbox wizard
# Open my.lbx with the non-hybrid slot, then
# Manage keyslots -> "Add a passphrase + ML-KEM-768 keyslot"
# and save the new .kyber seed on separate storage.
Then revoke the dead hybrid slot (luksbox info my.lbx shows its
index):
luksbox revoke my.lbx --slot <N>
If the hybrid-PQ slot was your only keyslot: vault is unrecoverable.
Corrupted header
If the inline header is damaged but you have a detached header backup,
pass it with --header to any command that unlocks the vault:
luksbox ls my.lbx --header /media/usb/my.hdr.backup
If you have an inline-mode vault and a previously-saved
header-backup, restore it directly:
luksbox header-restore my.lbx /media/usb/my.hdrbak
# (add --no-verify only if the on-disk header is too damaged to unlock)
The backup's keyslots come back with it: a keyslot revoked after the
backup was taken works again, and one enrolled after it is gone.
Revoke and enroll again as needed. On a header format v3 vault,
header-restore saves the verified backup as a new header generation,
so later opens with --anchor accept it; pass --anchor to
header-restore too, so the anchor records it. With --no-verify the
backup is written as it is, and if it is older than the last keyslot
change the anchor recorded, opens with --anchor fail with
header rollback detected.
Always-on advice: keep at least one header-backup (and a .hdr
copy if you use detached mode) on separate storage, and take a new
one after every keyslot change. Headers are 8 KiB - trivial to back
up. See the
forensics page for the full damaged-header
walkthrough.
Power loss or unplugged drive
A crash, a power cut or an unplugged drive in the middle of a save
needs no action in most cases. LUKSbox keeps crash-recovery copies of
the header and of the encrypted file tree next to the vault
(.header-bak and .meta-bak, see
Moving or copying a vault) and
opens the vault from the last good copy on its own. What was written
after the last save is lost: a mounted vault saves every 30 seconds,
or after every write with luksbox mount --sync.
Since 0.6.1, overwriting part of an existing file is copy-on-write: the new contents go to a fresh place in the vault, and the old contents stay readable until the next save. A power loss while a file is being overwritten keeps the last saved contents of that file. The one exception is a vault that has reached its maximum size with no free space left inside it, where an overwrite goes in place.
With older versions, a power loss during an overwrite could leave
parts of that file unreadable (AEAD failure when you read it). See
the next section to find and salvage them.
Corrupted chunk (one or more files refuse to read)
mount and ls work, but reading a specific file fails with
AEAD failure. The damage is local to that file's chunks.
# Locate the bad chunks (read-only)
luksbox check my.lbx
# Salvage what is still readable from the affected file
luksbox extract my.lbx /the/affected/file recovered.bin --tolerate-errors
The output file is the same byte length as the original, with 4 KiB zero ranges in place of each unrecoverable chunk. See the forensics page for the full chunk-corruption flow.
Vault refuses to open: tolerant recovery mode (v0.2.2+)
When Vfs::open fails with metadata blob deserialization failed
or per-inode AEAD errors on the chunk-list chain (the symptom of
the v0.2.1 durability bug
that v0.2.2 fixed), the vault carries inodes whose chunk pointers
no longer decrypt. Default open refuses the whole vault rather
than silently expose bytes-from-a-previous-flush as file
content. Recovery mode opt-in installs the broken inodes as
0-byte placeholders so you can mount read-only and copy out
every healthy file.
CLI / scripts
LUKSBOX_TOLERATE_BAD_CHUNK_LISTS=1 luksbox mount my.lbx /tmp/v
# Vault mounts read-only; broken files appear as 0-byte
# placeholders; healthy files read as normal.
cp -r /tmp/v ~/recovered/
luksbox umount /tmp/v
The LUKSBOX_DEBUG_OPEN=1 env var prints which parse step trips
during open (metadata head bytes, LBM magic match, postcard
error, per-inode v4_on_disk_to_in_memory result), useful for
narrowing down a damaged vault before trying tolerant mode.
Wizard (TUI)
When the wizard hits a MetadataDeserialize open failure, it
prompts "Try opening in recovery mode?" (default yes). On
confirm it re-authenticates with the tolerant flag set, then
prints the list of broken inode IDs / sizes / paths to stderr
before handing you the read-only mount.
GUI
The Open form has a "Recovery mode (read-only, skips broken files)" checkbox. Ticking it before unlock applies the toleration flag for that session. On a successful recovery-mode open with tolerated inodes, a modal lists every broken file's path + original size + AEAD-failure reason so you know what to re-source. Dismiss the modal to use the vault read-only; flush is refused while the recovery report is active.
What recovery mode guarantees
- The broken inodes are not persisted as 0-byte over the
original on-disk metadata. The new
Error::ReadOnlyMountrefuses every subsequent flush, so brute-force recovery against the originalchunks_externalpointers (via deep forensics, an older.meta-bak.tmp.*snapshot, etc.) remains possible later. - Healthy files decrypt and read normally. Only inodes whose chunk-list chain failed AEAD are placeholdered.
- Mount stays usable for
cp/ drag-and-drop into a fresh destination. Treat the mounted vault as a one-shot escape hatch: once you've copied out everything readable, unmount and start the broken-vault forensics workflow on the original.lbx.
Rollback detected
An open with --anchor fails when the vault is older than what the
anchor last saw:
ROLLBACK DETECTED: the file tree is older, for example an older copy of the.lbxput in place of the current one.header rollback detected(header format v3 vaults): the keyslot table is older, for example a header saved before arevoke.
If you did not restore anything yourself, treat it as tampering:
someone replaced the vault, or its header, with an older copy. Find
the current copy (another device, your backups) before you write
anything to this one. If you restored an older backup on purpose, use
the anchor saved with that backup. To put back a header backup on
purpose, use luksbox header-restore
rather than copying it over the vault: it saves the backup as a new
header generation, which the anchor accepts (see
Corrupted header).
Corrupted anchor
The .anchor sidecar is rollback-detection metadata, not unlock
material. The anchor is only checked when you pass --anchor <file>
(every command that unlocks the vault accepts it since 0.6.0, enroll,
revoke and header-restore included), so a vault whose anchor is
missing or corrupted still opens without that flag:
luksbox ls my.lbx # no --anchor: no rollback check
Skipping --anchor also skips rollback detection, so do it only if
you trust the vault hasn't been rolled back (e.g. you control the
storage). Anchors are created together with the vault
(luksbox create --anchor <file>); there is no command to rebuild
one for an existing vault.
Things LUKSbox cannot help with
- A vault file that's been overwritten with random data: encryption doesn't reconstruct lost ciphertext.
- A vault with all keyslots wiped: nothing to derive a key from.
- A passphrase you simply forgot, with no other keyslot: forever unrecoverable. Use a password manager OR write it on paper and store the paper securely. (Argon2id at 4 g/s would take 10^14 years to brute-force a 5-word EFF passphrase.)