Monday, October 23, 2017

partitioning - Unallocated space instead of LUKS partition with gparted



I have unplugged a USB with valuable data with a mounted LUKS partition which destroyed the partition table.



Running testdisk does not recognized the partition: it claim it as unallocated space instead of a LUKS partition. From parted:



Number  Start   End     Size    Type     File system  Flags
1 1049kB 3222MB 3221MB primary boot
2 3222MB 3224MB 2097kB primary



There should be a third LUKS type partition



Number  Start   End     Size    Type     File system  Flags
1 1049kB 3222MB 3221MB primary boot
2 3222MB 3224MB 2097kB primary
3 3224MB 16.0GB 12.8GB primary



I tried adding a new partition with testdisk for this apparent unallocated space but didn't found the crypt_LUKS type in the list:



>List of partition type 
[...]
1e hid. FAT16 LBA 87 HPFS FT mirror-V/S set f0 Linux/PA-RISC boot
20 Willowsoft OFS1 8e Linux LVM f1 Storage Dimensions
[...]


Hence my first question:




1. Is Linux LVM the right type for a LUKS encrypted partition? Which method should be used to force to recognize the unallocated space as a LUKS partition



Choosing Linux LVM does not allow to run cryptsetup luksOpen (I get Device /dev/sdb1 is not a valid LUKS device.)



2. Which other method would you use in order to recover my LUKS partition recognized as unallocated space ?



Linux doesn't care about partition types. Just give it any type which is not a Windows type; Linux LVM works well, or 0xDA (Non-FS Data). To check whether a device, for example, /dev/sdc3 is a LUKS container:



sudo cryptsetup isLuks /dev/sdc3 && echo LUKS container || echo Not a LUKS container



The best way is to recreate the partition as it was and, if necessary, restore the LUKS header from backup. Backup the first 2 MiB of the partition first.


No comments:

Post a Comment

11.10 - Can't boot from USB after installing Ubuntu

I bought a Samsung series 5 notebook and a very strange thing happened: I installed Ubuntu 11.10 from a usb pen drive but when I restarted (...