LUKS encrypted flash drive: no partition table

1

1

I have 16GB encrypted LUKS flash drive with corrupted partition table. Here is the fdisk output:

fdisk -l /dev/sdf 

Disk /dev/sdf: 16.2 GB, 16236150784 bytes
64 heads, 32 sectors/track, 15484 cylinders, total 31711232 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sdf doesn't contain a valid partition table

Can this be recovered?

user1406146

Posted 2013-09-12T21:12:07.187

Reputation: 45

Are you sure that the whole drive isn't encrypted instead? – Ignacio Vazquez-Abrams – 2013-09-12T21:37:07.303

Answers

4

First, did you encrypt the entire hard drive /dev/sdf or a partition /dev/sdf1? Try cryptsetup luksOpen /dev/sdf test from a root terminal to see if maybe you encrypted the entire volume and not the first partition in it. Which is OK, you'll just have to remember that each time you mount it and ignore the partition warnings. (You probably can't mount it through the Disk Utility GUI - you'll need to use the command line each time.)

If you really overwrote the partition table, you may need to use a tool to recreate. It shouldn't be too hard if you only had 1 partition in it, and a utility such as cfdisk may be able to help. Don't format the partition afterward, obviously.

Something that may be safer than putting a new partition table on it, if you indeed overwrote the partition table, is to get cryptsetup to look at not sector 0 of that volume but the sector that your encrypted volume begins at. I'm sure that it's possible somehow but can't think of a tool that does that (you can do that with "loopback" files easily but I'm not sure if losetup works with a raw device /dev/sdf).

You can probably dd if=/dev/sdf | hexdump -C | less and scroll through until you find the text LUKS - then divide that by 512 to get the beginning block of your LUKS partition.

LawrenceC

Posted 2013-09-12T21:12:07.187

Reputation: 63 487

I tried

if=/dev/sdf | hexdump -C | grep LUKS

but nothing. Probably LUKS header corrupted & I can't recover my encrypted partition in any way.

Thanks for answer. – user1406146 – 2013-09-13T20:59:40.053