Re: rescue corrupted luks header?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Kevin Bowen <kevin@...> writes:
> Is there any way to try to recover a corrupted luks header? If not,
> does anyone have any ideas of what my options are as far as getting my
> data back?
> 

Like has been the general sentiment here, you can't recover a corrupted LUKS
header, but you can restore the parts of it that are standard across multiple
LUKS partitions.  Here are commands that will setup a simple file, create a loop
device to it, set it up as a LUKS partition, dump the first part of the LUKS
header that seems to be corrupted on your partition, and then restore this over
your partition header.  I tested out myself on a non-data-critical device by
first writing random data to the header to make it "corrupted".  Probably would
wait until other people check out my commands before actually doing it, I just
started playing with DD and LUKS so there might be a couple idiosyncrasies I'm
unaware of.

//BACKUP CORRUPTED HEADER JUST TO BE SAFE WHERE /dev/sda3 IS YOUR LUKS PARTITION
dd if=/dev/sda3 of=backup.img bs=1 count=592 conv=notrunc
//CREATE EMPTY IMAGE FILE FOR LOOP DEVICE
dd if=/dev/zero of=test.img bs=512 count=4
//SETUP LOOP DEVICE - SHOULD BE /dev/loop0 IF YOU HAVE NO OTHER LOOP DEVICES
losetup -f test.img
//FORMAT LOOP DEVICE
cryptsetup luksFormat /dev/loop0
//COPY THE FIRST 104 BYTES OF CORRECT HEADER TO CORRUPT HEADER
dd if=/dev/loop0 of=/dev/sda3 bs=1 count=104 conv=notrunc
//SEE IF HEADER IS FIXED BY PERFORMING A LUKSDUMP
cryptsetup luksDump /dev/sda3

Hopefully this works for you and doesn't screw things up more.

-Bill


---------------------------------------------------------------------
dm-crypt mailing list - http://www.saout.de/misc/dm-crypt/
To unsubscribe, e-mail: dm-crypt-unsubscribe@xxxxxxxx
For additional commands, e-mail: dm-crypt-help@xxxxxxxx


[Index of Archives]     [Device Mapper Devel]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux