Page 1 of 1

Recovering LUKS EXT4 partition - incorrect size

Posted: 03 Aug 2013, 02:17
by veken0m
I'm not exactly sure how this happened but the partition table of one of my LUKS encrypted drives was lost although I saw using a hex viewer that the LUKS header is completely intact. I think it might been when I was installing Manjaro Linux and messed something up while partitioning or installing the boot loader. I'm certain I didn't touch that drive though...

Using test-disk I was able to find this partition and "recover it". The problem is that the size was not detected properly. Test-disk updated the partition table and it now shows up as 8.2 MB rather than ~2.0 TB. With "cryptsetup luksOpen" I am able to unlock the encrypted partition successfully although I am unable to read it's contents. Is it possible to fix the size in some way that would make the data recoverable? The encrypted partition spanned the entire drive. I'm really close to recovering it but I'm not sure what to try next...

Additional info:

Type: MS-DOS (MBR)
Encryption - aes-cbc-essiv:sha256
Partition Type - EXT4
DISK - ~1863GB

Recovered partition = Start 1, End 254, Size 16002 sectors

Re: Recovering LUKS EXT4 partition - incorrect size

Posted: 07 Aug 2013, 03:54
by veken0m
Finally figured it out. Simply had to delete the partition using fdisk and create a new one of the proper length. The tricky part was to get fdisk to let me pick sectors < 2048. Starting it in old DOS-style disk block addressing mode via the "fdisk -c=dos -u=cylinders /dev/sdf" command did the trick.

Now I can successfully decrypt/mount the partition and all the data is intact! Feeling pretty boss right now :D.

Re: Recovering LUKS EXT4 partition - incorrect size

Posted: 07 Aug 2013, 06:13
by Fiona
Thanks for your feedback and providing your solution.
Ill set your topic as solved.

Fiona