PDA

View Full Version : [SOLVED] Failed hibernate with encrypted swap



inneedofsomehelp
June 3rd, 2012, 04:56 PM
Hi all,

I have an encrypted home partition, and therefore also swap. I tried to install 'hibernate' the other day, forgetting that this would not work with encrypted swap. The machine went into hibernation and now when I try to restart the machine, it just sits at the loading screen (showing the 5 scrolling dots) endlessly...

I am very new to linux, so am pretty clueless but have followed several posts on here and elsewhere from google to try to fix this. If I edit the boot command to add 'noresume', then I can get back in - but the next time I restart, I have the same problem. I have tried unmounting the swap and re-making it, but the problem persists. I guess there must be a flag somewhere telling the system that it has a saved state - but I can't seem to reset this.

Can anyone give me any clues??

Thanks!

hictio
June 3rd, 2012, 06:22 PM
On what hardware are you running?
I have been using an encrypted $HOME before and all thru Lucid Lynx on laptops (mostly Thinkpads) and I never had any issue going in and back from either suspend or hibernate.

inneedofsomehelp
June 4th, 2012, 11:07 AM
I am on a Lenovo z370 laptop. I have read several places that hibernate with an encrypted swap would require fixing the encryption key. So I get why it didn't work. But now that I have cleared swap, etc I don't know why it still thinks there is a hibernation image to restore. Surely on a successful shutdown, it should clear that?

Toz
June 4th, 2012, 11:42 AM
Try booting once with the noresume kernel parameter to disable the resume cycle and restore the swap space.

inneedofsomehelp
June 4th, 2012, 11:50 AM
Yes, that is what I have done. It is the only way I can boot again.

However, everything I have tried to do to restore the swap has not fixed the root problem, because at the next boot, it requires noresume again.

This is why I am confused - is there a flag somewhere in /boot/ that isn't being cleared?

cortman
June 4th, 2012, 02:32 PM
Hi, this is a known problem. I just got done transferring Paddy Landau (http://ubuntuforums.org/member.php?u=572807)'s excellent tutorial on it to the wiki- page here. (https://help.ubuntu.com/community/EnableHibernateWithEncryptedSwap)

inneedofsomehelp
June 4th, 2012, 04:02 PM
Thanks. Yes, I think I saw the original post on enabling this. However, I was hesitant to implement it until the previous problem was fixed. But if you think this is safe to go ahead, then I will give it a shot..
Is there any downside to doing this? I guess it will always ask for a password at bootup - or is this only if resuming from hibernation?

inneedofsomehelp
June 4th, 2012, 05:23 PM
Right... so this is strange...

I followed the steps in the link. I did not hibernate, but just restarted. It restarted fine. So I thought this must have cleared whatever the previous problem was.

So then I undid all steps (plus those detailed here (http://www.logilab.org/29155)) so that I could get back to the original state (normal, encrypted swap with no hibernate functionality and no password to enter on boot).

Now, when I restart, the same problem is back.

Any ideas??

Thanks for all suggestions so far. I really thought I had fixed it when I managed to restart! :(

cortman
June 4th, 2012, 05:31 PM
Why don't you post in the original tutorial thread with details on what went wrong? The author will be sure to follow up on your problem there. Good luck!

inneedofsomehelp
June 4th, 2012, 05:36 PM
To be honest, since there were no other replies, I assumed it was locked in some way.. so I could reply there.

However, this is unrelated to his post so I don't want to clutter his post with something not caused by his original tutorial. What is best practice here? Post anyway?

cortman
June 4th, 2012, 05:39 PM
The nature of the new wikified tutorial threads is that the original thread (containing the tutorial) becomes the support venue thread for that wiki. It's considered standard practise for people to post questions/problems with a tutorial thread in that thread. Most of the time the author is subscribed to it so he can handle support requests as they come in. Go ahead and post.

inneedofsomehelp
June 4th, 2012, 06:25 PM
Ok. Thanks. I will give it a go!

Paddy Landau
June 4th, 2012, 07:47 PM
Right. First off, please do not install hibernate (apt:hibernate) — in fact, please uninstall it so that you do not accidentally use it!

The correct way to hibernate in Ubuntu from the terminal is with this command:
sudo pm-hibernateNow, let's find out what's happening on your system.


Boot into Recovery Mode. (If you don't know how: Press Shift when you start your computer and keep it held down until you see the purple Grub menu. Use your arrow key to proceed to the "recovery menu" option, normally the second, and press Enter.)
Drop to Root Shell Prompt.
Enter the following two commands:
mount --options remount,rw /
mount --all
Now enter the following five commands and post the results of each here (please enclose your results between
and , or highlight the results and press the # button in the toolbar). Note that the first and third commands use the lowecase letter "l", not the digit "1", after the minus-sign.

ls -lA /home
parted --list
fdisk -l
cat /etc/fstab
swapon --summary

inneedofsomehelp
June 5th, 2012, 12:07 PM
I did have hibernate installed. I have removed it. That is probably what I used to hibernate last time.

Holding shift during boot up doesn't seem to do anything, but the first time I tried it, it booted ok.. and now it looks like the problem has disappeared. I haven't a clue what is going on now, since I had restarted several times previously when it hung.

I cannot reproduce it any more, so I guess there is no point in grabbing the outputs now since it will all look fine..?

So sorry to have spent everyone's time on this. I spent about 6 hours yesterday and about about 4 hours on Sunday going round in circles trying to fix this and testing it. And now, I wake up and it has gone away.. bizarre. I did boot off a USB stick in the mean time, but I can't imagine that would have changed anything...

Thank you so much for your time everyone. If it comes back as quickly as it disappeared, I will be back! :)

Paddy Landau
June 5th, 2012, 12:11 PM
I'm glad it's been resolved. Please mark the thread as solved (https://wiki.ubuntu.com/UnansweredPostsTeam/SolvedThreads).

If it does return, follow the instructions in my post and we'll see what we can do.

notjingo
December 4th, 2012, 11:55 AM
Sorry to reopen this thread if it's closed, but I am also having the exact same problem.

I followed the guide to enable encrypted swap hibernation (https://help.ubuntu.com/community/EnableHibernateWithEncryptedSwap (https://help.ubuntu.com/community/EnableHibernateWithEncryptedSwap)) and everything went well except my system still will not resume from hibernation. It powers off fine but when started up again it just does a full reboot. I am asked for my crypt-swap passphrase during every Ubuntu boot.

Can you give us instructions on how to revert the changes made in the tutorial? Since hibernation is still not working I'd like to undo this.

Alternatively if you can offer any thoughts on why hibernate is still not working with this method that would be great too. I have had hibernate work on this machine in ubuntu 11 and now I am running 12.10.

Thanks for your help!

Paddy Landau
December 4th, 2012, 12:40 PM
I followed the guide to enable encrypted swap hibernation…
If you want it to work, you could try going through the steps again, carefully, in case you missed out something. However, I have not tested it on 12.10, although it should work.


Can you give us instructions on how to revert the changes made in the tutorial?
I presume that you have an encrypted home folder. (If not, you should have set it up as instructed in the Preparation stage (https://help.ubuntu.com/community/EnableHibernateWithEncryptedSwap#Preparation).)

To undo, I need to know whether or not you have an encrypted home folder. To tell whether or not you do, open a terminal and enter the following command, changing notjingo to your actual username:

mount | grep -Fc notjingo/.PrivateIf you see the number 1, you have an encrypted folder. But if you see the number 0, you do not have an encrypted folder. (If you see anything else, please let me know.)

Let me know, and we'll progress from there.

notjingo
December 4th, 2012, 07:39 PM
I followed the tutorial exactly and everything seemed to work except or the actual resume of hibernate, as I detailed in my last post. What info or logs should I inspect to find out why it's not resuming?

Also, my home folder IS encrypted.

Paddy Landau
December 5th, 2012, 12:02 PM
I followed the tutorial exactly and everything seemed to work except or the actual resume of hibernate, as I detailed in my last post. What info or logs should I inspect to find out why it's not resuming?
Unfortunately, I do not know the answer to your question, sorry.

I am wondering if you have accidentally turned off swap, or if you have more than one swap partition.

Open a terminal and enter the following commands. Please post the results here (between
and tags).

sudo parted --list
swapon --summary
sudo cryptsetup status cryptswap1

notjingo
December 5th, 2012, 09:32 PM
From Parted, this is my swap partition:

3 80.0GB 88.6GB 8590MB primary


swapon --summary is now empty, and cryptsetup reports that

/dev/mapper/cryptswap1 is inactive.

Yes it looks like the swap was deactivated after I encrypted it. How can I reactivate it?

Paddy Landau
December 6th, 2012, 11:05 AM
Thank you for your response. I take it that your parted output did not show something like the following:

Model: Linux device-mapper (crypt) (dm)
Disk /dev/mapper/cryptswap1: 4409MB
Sector size (logical/physical): 512B/512B
Partition Table: loop

Number Start End Size File system Flags
1 0.00B 4409MB 4409MB linux-swap(v1)In that case, it seems as though you do not have an encrypted swap partition at all, and the partition that you do have is not in use.

This explains your computer's failure to hibernate.

Questions

Did you install an earlier version of Ubuntu and subsequently upgrade (tell me the versions involved), or was this a fresh installation of 12.10? Did you encrypt your home folder when you originally installed, or did you subsequently encrypt it?

I don't understand how you could have completed the steps in the Preparation stage (https://help.ubuntu.com/community/EnableHibernateWithEncryptedSwap#Preparation) of your hibernation encryption (https://help.ubuntu.com/community/EnableHibernateWithEncryptedSwap), when you do not have an encrypted partition! You must have missed out at least some steps, and you could not have repeated it as requested in my previous post.

What to do now?

The first thing to do is to encrypt your partition. Repeat all the steps 1–13 in the section How to Set Up Hibernation (https://help.ubuntu.com/community/EnableHibernateWithEncryptedSwap#How_to_Set_Up_Hib ernation). Notes:


Step 2 may return an error. Ignore the error.
Regarding /dev/sdXN, in your case N will be 3. I don't know X because you did not post the full output of sudo parted --list.
You should have already completed steps 8–11 and 13 in your previous attempts. Double-check them.
Let me know if you get an error on any step, excluding step 2.

Test

Now repeat the first-time use test (https://help.ubuntu.com/community/EnableHibernateWithEncryptedSwap#New_Swap_First_Ti me_Use) and then test your hibernation (https://help.ubuntu.com/community/EnableHibernateWithEncryptedSwap#How_to_Hibernate) .

If either of them fails:


Post the contents of your file /etc/fstab.
Post the full results of:
sudo parted --list
swapon --status
sudo cryptsetup status cryptswap1

notjingo
December 6th, 2012, 11:27 AM
I had the swap partition successfully working (non encrypted) before I went through your tutorial. I was able to encrypt it and in fact I DO have the encrypted swap partition though it stopped working (in terms of swap) after I followed your tutorial.

Here is the entry from blkid:

/dev/sda3: UUID="26f14559-00a2-4993-ab59-e57b6e315579" TYPE="crypto_LUKS"


In terms of the Ubuntu install, it was a fresh 12.10, with an encrypted HOME folder.

Anyway, I tried to go through your tutorial again, and after entering


sudo mkswap /dev/mapper/cryptswap1

I get the error:


/dev/mapper/cryptswap1: Device or resource busy

I'm assuming this is because the cryptswap1 already exists...

At this point here is the result of "sudo cryptsetup status cryptswap1"



/dev/mapper/cryptswap1 is active and is in use.
type: LUKS1
cipher: aes-cbc-essiv:sha256
keysize: 256 bits
device: /dev/sda3
offset: 4096 sectors
size: 16773120 sectors
mode: read/write


I checked all the other steps in the tutorial and everything looks fine, I have all the right entries in the files. BTW Ubuntu registers my system as having 7.7gigs of RAM, so I have made the swap partition 8 gigs.

I am about to test and see if hibernate works. Will post the results in a couple minutes.

notjingo
December 6th, 2012, 11:35 AM
I just used
pm-hibernate to hibernate and I got the same result...

The computer shuts off fine, but then instead of resuming from hibernate, it just reboots completely. During Ubuntu startup, it asks me for the cryptswap password, which I enter, and then it says

cryptsetup: cryptswap1 set up successful
like in the screenshot from the tutorial, but alas it didn't resume.

Before I used the hibernate command I made sure to register the changes with

sudo update-initramfs -u -k all

Any ideas? If there's no way to fix this, I can live without hibernate, but I would like to get it to stop asking for the password every time I boot.

Will using the "/etc/luks-keys/" option in the crypttab entry get rid of the password prompt while keeping the swap encrypted?

Paddy Landau
December 6th, 2012, 12:21 PM
Thanks for your responses. I think we are a little closer, especially as your swap partition has mysteriously started working now!



Now that your swap partition is working, try hibernating again. Does it work?


If not, I wonder if 12.10 uses a different mechanism from 12.04. I have not tested this on 12.10, so perhaps I need to do so. But I won't have time until the weekend.

If you want to undo your hibernation, follow these steps. Warning: I have not tested this process, but I would be surprised if it failed to work.



sudo swapoff --all
sudo cryptsetup luksClose /dev/mapper/cryptswap1
Open your Disks utility (from the Dash). Find your hard drive (on the left) and click your swap partition, /dev/sda3, on the right.
Click Format Volume. Type: Swap Space. Name: (anything you want). Encrypt underlying device. Format.
Undo steps 8–11 and 13 in How to Set Up Hibernation (https://help.ubuntu.com/community/EnableHibernateWithEncryptedSwap#How_to_Set_Up_Hib ernation), then repeat step 12.
Reboot.


You should no longer have hibernation available in your menu.

Now, enter the command:

sudo swapon --allReboot again.

Check whether or not you have a swap:

swapon --statusIf you still do not have swap, post the contents of your file /etc/fstab here.