Saturday, July 14, 2012

Ubuntu Hibernate

As I get involved with Android development, I have found that I need the ability to hibernate my computer.  By hibernating, I don't have to restart the android emulator every time I begin to develop.  Since I'm developing in very short bursts, less than an hour at a time, skipping the emulator start up process saves me a significant fraction of time.

Unfortunately, hibernating in Ubuntu is notoriously unreliable, and it wasn't working ony my system.  This problem seems to be hardware specific, so I don't know how much this might help someone else, but I'll document what I did nonetheless.

I set up a swap partition whose size was greater than the RAM size.
I updated the uuid of the swap partition in the fstab file "/etc/fstab".
The uuid can be found by running sudo gparted.

I tested the stock hibernate program.
However, when I tried to awake the system from the hibernated state, Ubuntu would start with a check disk error and the system was not preserved.
The command for the hibernate program is sudo pm-hibernate.

I installed uswsusp which somehow magically handles sleep and hibernation.
sudo apt-get install uswsusp

I tested uswsusp, and it restarted with all my open programs well.
sudo s2disk

I replaced the stock hibernate statement with s2disk.
In file "/etc/acpi/hibernate.sh", I replaced pm-hibernate with s2disk.  

I added hibernate back into the menu in the UI.
Create this file /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla
Then add these lines.
[Enable Hibernate]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes
After a system restart, the selection to hibernate was in menu, and it has been working fine ever since.

No comments:

Post a Comment