Fixing encrypted disc hibernation in Ubuntu with uswsusp [en]

Update: 2016-01-10

I haven’t been using uswsusp for quite some time, there have been a lot of problems with booting from hibernation. They problems have varied from failing to load the image to crashes soon after resuming from hibernation. These problems have been so frequent and persistent that I have stopped using uswsusp.

Ever used Ubuntu and thought “why can’t I hibernate by default” well after all the trouble I went through to get it working, you could say: I have a few ideas why.
I started with installing uswsusp and configuring it the way mentioned in this tutorial: https://wiki.debian.org/Hibernation/Hibernate_Without_Swap_Partition
After this I found out that loading a swap file from a partition which is encrypted with LVM is not gonna happen, don’t try this it’s a waste of time.

So after those two hours of my life I decided to setup a dedicated partition as swap to hibernate to. Since I used an LVM encrypted volume you can imagine I want to encrypt my hibernation file as well. Luckily uswsusp already has this feature and on Ubuntu its enabled by default. So I created an partition using gparted on once again followed the mentioned tutorial but now instead of writing /swap I wrote /dev/sda3. Everything was going fine until I tried to hibernate on which the s2disk command replied “No such device”.

Which was strange I requested the total size of my swap and the system replied: 32 gigabyte, which is exactly as expected since I have the /swap and the /dev/sda3 swap locations while having a total system memory of 16 gigabyte. I wont bore you with how I derived this information but: The uswsusp version ubuntu uses requires you to point to /dev/disk/by-uuid/your-uuid-here mount point instead of the usual /dev/sdX etc…

After changing all the mount points to uuid mount points it was time to test the s2disk command again. I was surprised to see it say “writing to disk”. I knew I probably wasn’t their yet! And after rebooting of course it completely skipped the swap file and rebooted fresh into Ubuntu. Luckily the tutorial had a quick tip for this, adding a resume parameter to a grub configuration file did the trick.

Even after all this disaster struck again and their I was at the password prompt of uswsusp but my keyboard wouldn’t respond! With some trial and error I found that switching with alt+F1 I could type my password in vty 0 and then return to vty 6 where my desktop was running. So all is well and their I finally had my hibernation operational in Ubuntu, but wait what is this?!
uswsusp adventure corrupt swapAfter rebooting everything immediately locked up and the system became unresponsive. Okay why is this and how can we fix this? After some fiddling with the /etc/uswsusp.conf I found out the only 2 lines had to be changed: change

compress = y
early writeout = y

to

compress = n
early writeout = n

. Now save the changes and reboot.

I didn’t believe it myself at first but after almost a full day of work I could finally hibernate in Ubuntu.

Geef een reactie

Het e-mailadres wordt niet gepubliceerd. Verplichte velden zijn gemarkeerd met *

*