LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 06-07-2017, 02:57 AM   #1
spastisky
LQ Newbie
 
Registered: Jun 2017
Posts: 15

Rep: Reputation: Disabled
luks encrypted drive wont boot


Hi all,

I can no longer get ubuntu 14.04 to boot on my hard drive. The drive is encrypted and I want to be able to either boot or access the drive to recover important files.

I have tried running:
cryptsetup luksOpen /dev/sda1 sda1_crypt -v

The response I got was:
keyslot 0 unlocked
Requested offset is beyond real size of device /dev/sda1
Command failed with code:22 Invalid argument.

The response was more or less the same both off a live rescue cd and a live ubuntu cd(where I also tried using the file explorer gui along with the terminal) In the case of the file manager it also returned a non-zero exit status 1.

The live rescue cd returns the following hardware info for my drive:
MBR: FreeDos(eXtended Fdisk) 0xFAB8001
63 sectors
931.51GB/976.76GB
Partition1:
size: 2MB
Type: Linux Native
Bootable: Y
Start: 501760
End: 505855
ID: 83

Any insight would be appreciated.
 
Old 06-07-2017, 03:32 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 20,522

Rep: Reputation: 3885Reputation: 3885Reputation: 3885Reputation: 3885Reputation: 3885Reputation: 3885Reputation: 3885Reputation: 3885Reputation: 3885Reputation: 3885Reputation: 3885
Quote:
Originally Posted by spastisky View Post
The drive is encrypted and I want to be able to either boot or access the drive to recover important files.
Shouldn't you have thought of that before you ran into problems ?.

That partition has almost zero chance of being your encrypted data. Presumably you had another partition for the luks container - testdisk might find it for you.
Have a read of this recent thread - note your offset (if you find it) will be different.
 
Old 06-07-2017, 08:57 AM   #3
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 4,669

Rep: Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161
Well, cryptsetup did find something that looked like a LUKS header in /dev/sda1, but the size of that partition (2MB) is barely sufficient to contain a header for a cipher with a 256-bit key and too small for one with a 512-bit key. By any chance did you use testdisk to recover the partitioning on this drive? Since there is nothing in the LUKS header to indicate the size of the container, testdisk will always assume a 2MB size for a LUKS partition.

What you probably need to do is use fdisk to delete the existing partition and re-create it with the same starting location and a size that extends to the end of the disk.
 
Old 06-07-2017, 05:44 PM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 20,522

Rep: Reputation: 3885Reputation: 3885Reputation: 3885Reputation: 3885Reputation: 3885Reputation: 3885Reputation: 3885Reputation: 3885Reputation: 3885Reputation: 3885Reputation: 3885
I'm guessing that's a boot partition.
What chance the cryptsetup searched for (and found) the header, but as it says, at the wrong offset - say where partition 2 would be ?. I would be inclined to leave the current partition, and look for a different one for LUKS.
 
Old 06-07-2017, 07:18 PM   #5
spastisky
LQ Newbie
 
Registered: Jun 2017
Posts: 15

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rknichols View Post
By any chance did you use testdisk to recover the partitioning on this drive? Since there is nothing in the LUKS header to indicate the size of the container, testdisk will always assume a 2MB size for a LUKS partition.

What you probably need to do is use fdisk to delete the existing partition and re-create it with the same starting location and a size that extends to the end of the disk.
You hit the nail on the head. I did attempt to use testdisk first before realizing that I should be more worried about the encryption issue. So I followed your advice and attempted to use fdisk to delete the partition but as soon as I typed: fdisk /dev/sda1
I received the warning :
Device /dev/sda1 already contains a crypto_LUKS signature. The signature will be removed by a write command.

So I guess my question is is it safe to enter the commands:
d
n
w

To write the new partition or will I destroy the signature and ruin my chances to recover my data?


*Also sorry about duplicate posting. I thought the first post didn't go through.
 
Old 06-07-2017, 07:53 PM   #6
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 4,669

Rep: Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161
Quote:
Originally Posted by spastisky View Post
So I followed your advice and attempted to use fdisk to delete the partition but as soon as I typed: fdisk /dev/sda1
I received the warning :
Device /dev/sda1 already contains a crypto_LUKS signature. The signature will be removed by a write command.

So I guess my question is is it safe to enter the commands:
d
n
w

To write the new partition or will I destroy the signature and ruin my chances to recover my data?
What the heck version of fdisk are you using (output from "fdisk -v")? What is the "rescue CD" you are using? I checked in Ubuntu 15, and that message does not appear in the binaries for either fdisk or gdisk. fdisk should not be touching anything but the partition table, and there is no LUKS signature there. Do not try to use any "intelligent" partitioning tool (like gparted, for example). Some of those will overwrite things they really shouldn't touch and are not safe for making low-level repairs.

Last edited by rknichols; 06-07-2017 at 08:28 PM.
 
Old 06-07-2017, 08:35 PM   #7
spastisky
LQ Newbie
 
Registered: Jun 2017
Posts: 15

Original Poster
Rep: Reputation: Disabled
https://en.altlinux.org/Rescue

Was trying off above but sounds like I should use an ubuntu cd instead.
 
Old 06-07-2017, 08:46 PM   #8
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 4,669

Rep: Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161Reputation: 2161
Quote:
Originally Posted by spastisky View Post
https://en.altlinux.org/Rescue

Was trying off above but sounds like I should use an ubuntu cd instead.
Indeed, use something besides that rescue cd. I'm not familiar with that one. I tried to download it, but the altlinux.org download mirror seems to be on a wonky dialup modem that's going to take a couple of hours to spit out that 405MB file. I do see that very recent fdisk source code does have the ability to wipe signatures from the drive. Perhaps the manpage will tell how to avoid that, but I'd rather use a tool that completely lacks that capability.
 
Old 06-07-2017, 09:34 PM   #9
spastisky
LQ Newbie
 
Registered: Jun 2017
Posts: 15

Original Poster
Rep: Reputation: Disabled
Alright that worked! I'm stoked. Got into my home folder with
1) sudo passwd root
2)su
3) cd to /media/ubuntu/<drivename>/home/.ecryptfs/<home folder name>
4) sudo ecryptfs-recover-private .Private/

Entered my pw and voila. Thanks again for your help! I will pay it forwards.

Last edited by spastisky; 06-07-2017 at 10:04 PM.
 
Old 06-08-2017, 06:24 AM   #10
Laserbeak
Member
 
Registered: Jan 2017
Location: Manhattan, NYC NY
Distribution: Mac OS X, iOS, Solaris
Posts: 508

Rep: Reputation: 143Reputation: 143
Just as an aside, I'd NEVER have an encrypted start-up drive. If you really need the security of an encrypted drive, you can put all that data on a second (or third or fourth...) drive.

Encrypting a startup drive makes fixing a problem almost impossible.
 
Old 06-08-2017, 06:47 AM   #11
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 20,522

Rep: Reputation: 3885Reputation: 3885Reputation: 3885Reputation: 3885Reputation: 3885Reputation: 3885Reputation: 3885Reputation: 3885Reputation: 3885Reputation: 3885Reputation: 3885
Luks plus ecryptfs ?. Who's paranoid here ... ?.
 
Old 06-08-2017, 06:53 PM   #12
spastisky
LQ Newbie
 
Registered: Jun 2017
Posts: 15

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by syg00 View Post
Luks plus ecryptfs ?. Who's paranoid here ... ?.
Canonical
 
Old 06-14-2017, 03:58 AM   #13
EthanStark
LQ Newbie
 
Registered: Jun 2017
Posts: 8

Rep: Reputation: Disabled
I would also recommend using GPT, especially when using UEFI, which I also use myself - on my primary workstation. However, the only limitations between the two formats is that MBR works with disks up to two terabytes, and that MBR only supports up to four primary partitions. Furthermore, the partitioning and boot data is stored in one place when using MBR, and across the disk when using GPT. So GPT is more robust and can better recover the data if some data is corrupted - plus GPT uses cyclic redundancy check (CRC) values in order to check that the data is intact, where it then will attempt to recover the data if it is corrupt.
So you could substitute GPT with MBR when using the tutorial, and then use legacy instead of UEFI - so you don't take any chances. That was what I did when I made my last reinstall. However, my last reinstall was not a reinstall of my primary workstation with important data, because if it had been, I would have used GPT.
When I installed my primary workstation with full disk encryption, where I used GPT, I didn't use UEFI - so I hope some others from the forum can help you with the UEFI stuff then.

Ethan Stark
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
luks encrypted drive wont boot spastisky Linux - Newbie 2 06-07-2017 03:56 PM
[SOLVED] Unlock LUKS encrypted partition with USB drive yenn Slackware 4 02-26-2013 04:39 PM
Cannot write to LUKS encrypted hard drive Nemesissparadise Linux - Software 3 04-04-2011 04:02 PM
Loaded Fedora 9 (twice) in encrypted hard drive, now I can't get past LUKS? GaveUpOnTV Linux - Newbie 3 05-04-2009 02:48 PM
Mounting LUKS encrypted drive from a failed pc: LVM2 error klearview Linux - Software 1 10-31-2008 03:34 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 06:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration