so I did a very stupid thing (fortunately not on purpose). I had missing superblocks on a ext4 partition, which was encrypted by luks and sitting on an mdadm raid 5. For some reason I ran mke2fs on it (/dev/md1) and managed to ignore the warning that this is a Luks partition. I stopped after it wrote a few inodes.

Now the system will not detection it as a luks partition anymore and luksOpen, etc. fails, which, I guess, makes sense. Currently testdisk is running a deepsearch but I have little hopes.

Anything that comes to mind? The situation is not absolutely dire, since I do have most of the data backed up. Yet, if I could keep the data added between the backup and now (mostly media, ~500GB), I'd certainly be very happy.

Has anyone any leads on how to continue or should I give up?

Best, Patrick


You can check the LUKS on-disk format and that of ext4. You need the salt, the iterations (which may slightly differ from one create run to another), and one key slot. The key slot data is spread over the first 4MiB.

IIRC ext4 leaves the first one or two sectors untouched (for boot code). Maybe what you need for LUKS is there. If so then you should

  1. backup the first 4 MiB
  2. create a new LUKS volume so that the other metadata (like cipher) is "restored"
  3. copy the bytes you need from the backup
  • Hi, thank you for your answer. That did not seem to work though, I did: dd if=/dev/md1 bs=4MiB count=1 of=luks-header.img, then rebuild the luks+ext4 and did dd if=luks-header.img bs=4MiB count=1 of=/dev/md1 -- same behaviour as before though. Appears back as an unknown volume in disk manager.
    – pAt84
    Nov 18 '17 at 22:35
  • @pAt84 I said "copy the bytes you need from the backup". It obviously does not make any sense to create a LUKS volume and overwrite all of its metadata with damaged metadata. I also did not say anything about creating a new filesystem within the container. This should now have destroyed all the old filesystem structures. In the future you should make sure you understand what and why you do it before you overwrite essential disk data. And if you do not understand it then you should ask before you do something irreversible... Nov 19 '17 at 9:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.