Recently, I had to write an article on Linux green computing. During the writing of that article I was sent on yet another quest to get some form of hibernate and or suspend working on a Linux laptop. This quest had me digging through nearly every configuration file and every package I could find in an attempt to get an off-brand laptop (Everex Zonbook) running Mandriva Spring 2008 to either suspend or hibernate. I was surprised at what I discovered and the results I came up with.

Let’s first chat about what I discovered. No I didn’t uncover the meaning of life, a cure for cancer, or proof that Linux will drastically lower TCO. What I did discover is that suspend and hibernate are two very different beasts and that suspend is still quite elusive in Linux while hibernate is not so challenging. How are they different? There are two different types of suspend: Suspend to RAM (suspend) and Suspend to Disk (hibernate.) Suspend to RAM is when you save the laptop state to RAM so that it can be quickly brought back. Suspend does continue to consume a small bit of power, so if your laptop is not plugged into a power source, eventually the suspend state could drain the battery.

Suspend to Disk (Hibernate) takes the saved state and stores it in your Linux swap partition. This method isn’t an “instant off/instant on” state, but it offers a few bonuses over Suspend. One bonus is that it uses zero power. Hibernate effectively shuts down your machine and, upon waking, brings the machine back to the exact state it was in when it was placed into hibernation. And because the state is saved to the hard disk, it is a bit safer than suspend. On the con side of the fence, hibernate does take far more time to put to sleep and wake up (although not as much time as it would to shutdown/boot.)

The good news and the bad news: The good news is that Linux can do hibernate fairly well. AND there are even GUIs to help you configure hibernate. The bad news is that Linux is a ways away from any sort of reliable suspend.

Let’s look at one application that allows you to safely hibernate your Linux laptop: klaptop_acip_helper. This command is part of the kdeutils_klaptop package and is run by simply entering the command klaptop_acpi_helper –hibernate. When you run this, the current state is saved, placed in your swap file, and then the laptop is placed in hibernation. To bring the laptop back up, you simply hit the power button.

Of course having to hibernate a laptop from the command line isn’t much good to the average user. To make this easier you can configure a lot of options in the Klaptop system tray applet. In this applet you can configure everything from Power Control, battery options, warning events, and button events. One of the handiest configurations is the button events. Here, you can configure your laptop to go into hibernate upon closing the lid.

Of course there are configurations that must be taken care of that can not be done via the applet. If you look in the file /etc/suspend.conf you will see the following:

snapshot device = /dev/snapshot

resume device =

#image size = 350000000

#suspend loglevel = 2

#compute checksum = y

#compress = y

#encrypt = y

#early writeout = y

splash = y

There are two things you need to do. First you need to replace

with the actual path to your swap file. In my case it was /dev/sda5. The second thing do to is to uncomment compress = y.

Once you have taken care of these edits, save the file, and close the file.

Now close the lid on your laptop. After it is closed for a moment, open it back up and you should see some text indicating how much of the state has been saved. Once the state reaches 100% the laptop will power off. When you reboot the machine it will seem as if it is just going through the boot process. But shortly after you press the power button the progress bar will zip through the process and you will find yourself back where you were when you shut the lid.

Is this a perfect solution? No. But it does at least offer a means to save your battery life and give you a laptop-feature in Linux that all Windows laptop users enjoy.

I hope some day to see the Suspend to RAM function actually work. This would remove one of the biggest hurdles for Linux adoption in the laptop market. Give this application a try and report back here so we know the various laptop models it supports.