I wanted to install Debian Linux after a weird journey with Gentoo Linux. My partition layout is this:
Boot Partition (512 MiB, mount at /boot)
Swap Partition (4 GiB)
Root Partition (~80 GiB, mount at /)
Home Partition (~170 GiB, mount at /home, LUKS encrypted)
While trying to preserve the home partition, I think I clicked 'Configure encrypted partitions' on the Debian installer and then set a password for it (the same that it had before).
Now, I can unlock it like before, but after it is unlocked, no utility recognizes the filesystem (ext4) and the file command reports it as being data:
# file -s -L /dev/mapper/home
/dev/mapper/home: data
file on the encrypted partition returns the following:
# file -s /dev/nvme0n1p4
/dev/nvme0n1p4: LUKS encrypted file, ver 2, header size 16384, ID 3, algo sha256, salt 0x590d84c0e8397ad0..., UUID: c5ff37db-11f7-4ccf-8869-c4bc22648202, crc 0x345f75d85c9f444a..., at 0x1000 {"keyslots":{"0":{"type":"luks2","key_size":64,"af":{"type":"luks1","stripes":4000,"hash":"sha256"},"area":{"type":"raw","offse
(This is the complete output, it cuts at offset for some reason)
My guess is that I re-encrypted the already encrypted partition. Also, I noticed that the UUID changed.
Can anyone help me recover it? Thanks in advance.
If you need more logs, I will happily provide them to you.
Given that the UUID changed, you almost certainly made a new LUKS container, overwriting the old one. That's bad, because the LUKS header is the only source of the actual encryption key that was used, and making a new one will overwrite both the main header as well as its backup copy immediately. Your password/keyfile/whatever is merely used to decrypt the part of the header that has the actual encryption key, and that's gone in that case.
Unless you have access to a header backup from before that, there's a fairly strong chance it's irrecoverable. I'd suggest going through any archives you might have to see if you have such a backup - most of the instructions on the Gentoo wiki encourage making one, so you might have made one through the power of copying & pasting instructions. Should be a file of around 16MB.
Sadly, I don't have a backup of the header. But I know the password that was used to decrypt the partition. Anyway, from the things you said, I can conclude that it might be irrecoverable.
Right, well testdisk has worked wonders in the past for me. It might worth a try especially if this is a spinning rust drive. It has helped me recover broken partitions and lost files so if you know where you’re looking you just might have a chance. I’m no expert but it seems like one of your last options with all the info provided. Best of luck!