Monday 27 July 2009

Saving Power with Suspend/Hibernate in Linux

Leave a commentLinux is a fantastic operating system with lots of ways to help make your computing Laptop Battery space a bit greener. On of those methods is the often troubled suspend/hibernate. On laptops this is a very tricky, often frustrating system to get working. In this article I will give you some pointers.

Understanding suspend/hibernate

Before you attempt to do any debugging, it's best to understand what suspend and hibernate do and how they effect Linux. I will begin by saying that both suspend and hibernate are iffy at best with Linux. One of the reasons why this is so is, due to the nature of both battery systems, they are very much dependent upon hardware configurations which can run the gamut. Because of this battery , some laptops will suspend or hibernate with Linux and some will not. Why is this? Image this: For either to work, the suspend or hibernate system has to take a snapshot of your running state, freeze it, and store it to either RAM or disk. Once you are ready to bring your laptop back to life, the suspend system must be able to reach the image acer BTP-60A1 Battery and restore it. Add to this the numerous systems that are effected by this system (X Windows, wireless networking, etc) and the task becomes even more complex.

Here is the gist of each. Suspend, also known as ACPI State S3, is also known as Suspend to RAM. This state is the trickest to get working with Linuz (In fact there are few laptops that will actually suspend with Linux.) because the image must be stored to RAM which is yet another variable in the equation. Suspend does use a very small amount of power because it has to keep the image on RAM in a retreivable state. Hibernate, also known as ACPI State S4, does the same thing as Suspend only it stores the image on the swap partition of the laptop hard drive. This is easier to handle because the swap partition is a much more standardized variable in the equation. Hibernate uses no power because the image is stored on a non-volitale state (on the actually hard drive.)

Of course the above doesn't even take into account other hardware variables such as button configuration, display, etc. But the end results should be the same: Save your laptop Acer BTP-58A1 Battery in a state that can be stored with little to no power usage.

Is suspend/hibernate working?

One of the first things you will need to do is find out if your installation of Linux works with your hardware. The first thing to do battery is to find out of Suspend to RAM is supported by running the following command: cat /sys/power/state. After running this command you should see something like mem or mem disk returned. Seeing mem means your hardware supports Suspend to RAM. Seeing disk means your hardware supports Suspend to disk. Seeing mem disk means your hardware supports both. If you see any of these returned by the command you are in luck. But don't rejoice just yet. You might find your hardware is supported but anytime you close that lid with the laptop unplugged you might come back, after a while, to find your battery dead. And even though your hardware does support both, Suspend to RAM is flaky at best and it continues to use power (which we want to avoid). So, since suspend (Suspend to RAM) Acer TravelMate 220 Battery is a more difficult state to achieve (and continues to use power) let's focus on hibernate Suspend to Disk.)

Hibernate

There are numerous packages that claim to be able to aid the quest to suspend a laptop. The only one that I have battery actually been able to sucessfully get to work consistently is klaptop_acpi_helper. This is part of the kdeutils-klaptop package. Of course th is means you would need to be running the KDE desktop environment. This tool has command line utilities but also works in conjuntion with the KPowersave panel applet. You can install this tool by selecting the Install & Remove Software entry of the Start menu. You will have to enter the root or sudo user password in order to access the installation tool. Once this is installed Acer BTP-43D1 Battery you can then test the laptop from a command window (I find this the best way to test because you'll get instant debugging information).


Open up a command tool (konsole is fine) and then issue the command klaptop_acpi_helper --hibernate and your laptop should start the process of hibernation. Now, understand, the process of hibernation isn't as instant as suspend because it has to save the state to disk. Once the laptop finishes the hibernation you should have a blank screen and see no indication that power is being consumed. Once the hibernation is sucessful you can then bring the laptop back to life. To do this hit the power Acer Laptop Battery button and the process of hibernation will reverse. Again, this is not nearly as quick as suspend so it will take some time before your laptop is back up and running.


Now that you know this system works you can then configure KPowersave to do the same thing. What you need to do is right click the KPowersave battery icon in the system tray (it will look like a power plug) and select Configure KPowersave. Within this configuration application you will want to click on the General Settings tab and then click on the Button Events tab. There is an entry here for Lid Close Button. Set that to Suspend To Disk and click OK. Now when you close the lid of your laptop it will go into hibernation.


Your laptop is now ready to consume less power!


Final Thoughts

It would be nice if hardware vendors were a bit more forthcoming with the specs of their machines so that Linux developers could readily fix the bugs surrounding such Apple M6091 Battery critical issues as power management. But this is not currently the case. So instead Linux developers are stuck with having to reverse engineer much of the technology. I have always felt that suspend/hibernate was an achilles heel for Linux. Fortunately it has reached a state where that achilles is not so afflicted.


No comments:

Post a Comment