I just accidentally overwrote the LUKS metadata of my volume with a new LVM header. I have copy of the original LUKS header but can't find it. Just in case, I made a dd image of the first 10MB of the now corrupt volume on a thumb drive.
My question is: is it still possible to recover the LUKS header? In particular, if I run 'cryptsetup luksFormat' with the same passphrase, key length, etc., will I see the old data? Is there any salting involved and can I specify the salt, too?
I guess if sizeof(lvm2 header) < position_of_salt_in_LUKS_header, I might be able to fix things. Could someone please point me to the relevant headers?
Did I totally bite it, or is there any slim chance…?
Best Answer
LUKS2 has a backup header, but LUKS1 (which you are probably using, as LUKS2 is quite new and few distros support it yet) does not.
If you didn't backup the header yourself, you are screwed. Go to your backups.
If you did backup the header, then restore the first 2MB of the block device, as this is the LUKS1 header length, and you might have a chance.
As Sven noted in a comment, you can also use
cryptsetup luksHeaderRestore
, which effectively does the same thing.