Thursday Night

Paul Betts’s personal website / blog / what-have-you

Fixing software suspend / hibernate with uswsusp in Ubuntu Feisty (and Edgy)

After upgrading to Feisty, my new favorite feature suspend-to-disk (aka hibernate) was broken badly; basically, the resume would never be found, so it’d act as if it had a corrupted swap partition and unmounted disks. A lot of people share my grief, suspend is a notoriously tricky thing to nail down because of bad drivers, companies who won’t cooperate with kernel developers, and the fact that software suspend itself is tricky business.

However, after a ton of investigation, it appears there is another solution to the standard one shipped with Ubuntu in µswsusp, which is a different method of suspending to disk. It turns out after some research, that the kernel method works for some people and µswsusp works better for others. If you’re having trouble with the former, here we go (this is written for Feisty Fawn, but most of the stuff works for Edgy):

How to try uswsusp

Before we set it to be the default, we want to try it out to make sure that it works for your laptop. First, make sure you’re running Feisty Fawn, then from the terminal type:

sudo apt-get install uswsusp
sudo s2disk        ## CAUTION: make sure data is saved for this test!

Making uswsusp the default in Ubuntu

If it worked, hurrah! Now, to make this the default way to hibernate/suspend the computer (including the logout dialog, and GNOME Power Manager) involves some hackery but it’s not too bad, and it’s not likely to cause any problems. Download these two files:

Then run the following command in the Terminal:

sudo cp hal-system-* /usr/lib/hal/scripts/linux/
sudo chmod 755 /usr/lib/hal/scripts/linux/*

Note that for Edgy, the scripts are named differently and are in /usr/share/hal/scripts

Technical details of what that does

When HAL is given the command to shutdown by gnome-panel or by g-p-m, it ends up executing these scripts, which end up going through a list of files trying to find some command to shut the machine down. The first command it usually finds is pmi, which invokes the kernel hibernate code. My file rearranges the priority so that s2disk/s2ram is called instead (and also corrects a dumb bug where it had the wrong path coded in the file). Since most all userspace requests now go through HAL to shut the machine down, this has the convenient effect of fixing hibernate for everything. Yahtzee!

Update: It appears bcm43xx (Broadcom Wireless driver) and uswsusp really don’t get along; use ndiswrapper instead. I also switched to the native ati driver instead of fglrx, but the latter still might work, I haven’t tried it.

Written by Paul Betts

February 11th, 2007 at 10:32 pm

Posted in Linux