suspend and hibernate on Ubuntu Gutsy
For those who are confused, this is a nerdy article about how to fix laptop hibernation on linux, specifically in the Ubuntu distribution. Just recently, i upgraded my laptop from the “Feisty” version (7.4) to “Gutsy” (7.10, referring to 2007.10), and i noticed that the hibernation feature stopped working. There are plenty of beginner articles out there to read, so i’ll assume that people who have found this in a search are intermediate to advanced Linux users.
First, a bit of background…i got the computer last year and immediately installed ubuntu on it, but only suspend would work and not hibernate. After some blind messing around with random config files, i got hibernate to work but suspend stopped working. I decided to leave it in this state, which worked all the way up until last week. As a baseline, i know for sure that there exists linux software that will properly suspend and hibernate my hardware.
The current problem is that neither hibernate nor suspend work. After some digging, i’ve discovered that there are multiple ways to have your computer suspend and hibernate. One seems to be through ACPI calls, which i think use the /proc or /sys filesystems. The other way is to use software like s2disk / s2ram. In Gutsy, it seems that the ubuntu developers have removed s2ram, but i managed to make my system hibernate again by using s2disk.
One thing that has definitely helped me along is the “hibernate” package. hibernate can use any of the possible methods to accomplish its job, but it also provides a framework on top of those tools to shutdown some programs, remove modules that need removing, or other things. for instance, on my computer i need to have my wireless driver (ipw3945) removed before suspending. hibernate accomplishes this for me.
At one point, i was able to hibernate by using “hibernate-disk” on the command line, but my Gnome button for hibernation was not using that. To change this, i had to figure out how the gnome power button decides what to do. I eventually found that it uses the “hal” system (Hardware Abstraction Layer). You can change how hal hibernates and suspends by going to the directory /usr/lib/hal/scripts/linux, where you’ll find files like hal-system-power-hibernate-linux and hal-system-power-suspend-linux. If you have the “hibernate” package installed on your system, then you should go down to the end of the hal-system-power-hibernate-linux file where it says #Other distros just need to have *any* tools installed and make sure that among the choices following that, the hibernate choice comes first. Mine looks like this:
if [ -x "/usr/sbin/hibernate" ] ; then
# Suspend2 tools installed
/usr/sbin/hibernate –force
RET=$?
elif [ -x "/usr/sbin/pm-hibernate" ] ; then
/usr/sbin/pm-hibernate $QUIRKS
RET=$?
elif [ -x "/usr/bin/powersave" ] ; then
$POWERSAVED_SUSPEND2DISK
RET=$?
and there’s a whole bunch more stuff before and after it…the important part is that the hibernate choice comes before the others.
I like mine this way because hibernate seems the easiest to configure. All of its config files are in /etc/hibernate. In disk.conf i have the line TryMethod ususpend-disk.conf, and then in ususpend-disk.conf i have the line USuspendMethod disk. These lines tell it to use the s2disk program to hibernate.
Ok, so now i’ve done a bunch of changes, and i still can’t get my suspend to ram working. I installed the debian package for uswsusp (version 0.7-1) to replace the ubuntu one because the debian one still has the s2ram command. It seems that i can suspend properly, so that my blue power light turns to a pulsing orange light, but when i try to resume then i just get a black screen. There are supposed to be a bunch of options to try, which will reset your video card upon resume, but these options don’t seem to be working for me right now. Some of them are listed in /etc/default/acpi-support, but i’ve now turned off SAVE_VBE_STATE and POST_VIDEO in that file so that i can choose all the settings in one place in /etc/hibernate. having the same configuration options in two different places can make things tricky.
Now, i’m reading through the opensuse s2ram page, which seems to have a lot of helpful information and plenty of new ideas to try. I first found out that my machine appears to be in the s2ram “whitelist” of working machines by typing sudo s2ram -n. i got this as a result:
Machine matched entry 258:
sys_vendor = 'TOSHIBA'
sys_product = 'Satellite A100'
sys_version = ''
bios_version = ''
Fixes: 0x3 S3_BIOS S3_MODE
This machine can be identified by:
sys_vendor = "TOSHIBA"
sys_product = "Satellite A100"
sys_version = "PSAA8C-TA202C"
bios_version = "2.10 "
Since my machine is in the whitelist, it should theoretically work just by typing sudo s2ram on a command line. I tried this, but i got the same result as before: it suspends properly, but does not resume. My next step was to follow the instructions in ACPI Suspend debugging. The idea is to strip things down to a minimal system and test piece by piece, so that other unknown factors cannot interfere. I did this by passing my kernel the option init=/bin/bash so that all i’m running is a shell and nothing else. I told the machine to suspend by doing echo mem > /sys/power/state, and it suspends. After i wake it up again, i have a black screen. I test the machine by running find / but nothing happens, indicating that my machine is fully dead and that it’s not just a video problem.
Ok, now that i’ve spent an hour running through all possible solutions and they all didn’t work, i decided on a whim to try a different kernel and it worked. I was using the ubuntu kernel package for version 2.6.22-14-generic and it would never suspend to ram, and once i switched back to the slightly older 2.6.20-16-generic then everything worked just fine, or at least they did after i did update-initramfs -k `uname -r` -u to get it to update the initrd for my older kernel to use my updated uswsusp utils. What a hastle. Hopefully something i learned here will help someone else too.
Ride hard, ride free
December 27th, 2007 at 00:32 am
can you explain how to install the older kernel?
thanks
December 27th, 2007 at 13:48 pm
you can find all the available kernels to install by using “aptitude search”. You could do “aptitude search linux-image”, which would list them all. all of the kernel packages have names like this: linux-image-2.6.20-16-generic
on my system right now, i have linux-image-2.6.20-16-generic and linux-image-2.6.22-14-generic installed, and it’s set up to use the 2.6.22 version. you can tell what version you are currently using by typing “uname -a”.
to install a new one that you don’t currently have, you should do “sudo aptitude update” first, then after it’s done you can do “sudo aptitude install linux-image-2.6.22-14-generic” or you could use the name of a different version in there.
the other way to do this is to use the graphical program for package management, but i’m more familiar with the command-line method.
March 29th, 2008 at 09:19 am
I’m having the exact same symptoms as you and have been through most of the same troubleshooting procedures — I simply gave up once I stumbled across the massive array of s2ram workaround options.
Sadly my machine is not in the s2ram whitelist, but yours is the first bit of web lore I’ve stumbled across that offers me a next step — I’ll try downgrading my kernel and see what happens. Thanks so much for posting your experiences!