CLASS="sect1" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" >

1.1. Advanced Power Management (APM/ACPI)

Putting your GNU/Linux PC in suspend or hibernate mode.

1.1.1. ACPI

Most modern PCs support the ACPI (Advanced Configuration and Power Interface) standard. The ACPI4Linux project works on implementing full ACPI support in the Linux kernel, including fan control, dock/undock detection.

All ACPI related information (such as processor or board temperature) is available through files in /proc/acpi. For example, this makes it very easy for desktop environments (or for your own programs) to display to temperature information somewhere on your screen.

1.1.1.1. Hibernate to disk

Use hibernate to disk and no longer be afraid of switching off your system. Booting is much faster than having to wait for services and graphics to start up. Actually, most of the time is saved by getting back to your work as you left it before suspending your computer (open files, terminals, browser windows). There is no need to re-open everything!

While hibernating is often considered as a power saving solution for notebook computers, it should also be used for desktop computers, to save AC power. Use it when you go for lunch, when you leave the office in the evening or for holidays...

Hibernating also saves a lot of time when you replace a battery of a notebook. Again, hibernate, install a fresh battery, power up and get back to your work as you left it off.

Technical details

  • Hibernation to disk is implemented by the Suspend 2 for Linux project. It consists of a kernel driver and a user-space program to control the driver. Users just need to run the program (usually called hibernate).

  • It works by copying the whole of used RAM to a swap partition. As a consequence, it requires the swap partition to be at least as big as the amount of RAM.

  • Both the patched kernel and the user-space program are very easy to install through packages.

    • Here are Fedora Core packages for download.

    • At least in the 6.06 release of (K)Ubuntu, hibernating is directly available as an option from the battery icon.

    • Go to your favorite package source for other distributions

1.1.2. Older hardware with APM

1.1.2.1. Linux Compatibility Check

From the Battery Powered Linux Mini-HOWTO " .. for APM to work on any notebook or energy-conscious desktop, the system BIOS ROM in the machine must support the APM standard. Furthermore, for APM to work with the Linux operating system, the system BIOS ROM must support either the 1.0 or 1.1 version of the APM standard, and it must also support 32-bit protected mode connections. A system that supports APM 1.1 is preferred, as it provides more features that the device driver and supporting utilities can take advantage of." You may get information about the APM version with the dmesg command and in the /proc/apm file.

1.1.2.2. Introduction

When you first install Linux, you will probably have to recompile the kernel. The kernel that came with your distribution probably does not have APM enabled.

APM support consists of two parts: kernel support and user-land support.

For kernel support, enable the parameters in the corresponding kernel section. AFAIK not all features work with laptops. AFAIK the feature CONFIG_APM_POWER_OFF works with most laptops.

The utilities for userland support may be found at WorldVisions. APMD is a set of programs that control the Advanced Power Management system found in most modern laptop computers. If you run a 2.2.x kernel and want to experiment, Gabor Kuti <seasons at falcon.sch.bme.hu> has made a kernel patch that allows you to hibernate any Linux system to disk, even if your computers APM BIOS doesn't support it directly.

1.1.2.3. Caveats

If you have another operating system preinstalled or use another operating system at the same disk, make sure there is no "hibernation" or "suspend" tool installed, which could severely interfere with Linux, e.g. it might use disk space which is occupied by Linux or vice versa.

1.1.2.4. Troubleshooting

Sometimes X windows and APM don't work smoothly together, the machine might even hang. A recommendation from Steve Rader: Some Linux systems have their X server hang when doing apm -s. Folks with this affliction might want switch to the console virtual terminal then suspend chvt 1; apm -s as root, or, more appropriately, sudo chvt 1; sudo apm -s. I have these commands in a script, say, my-suspend and then do xapmload --click-command my-suspend .

On some new machines (for instance HP Omnibook 4150 - 366 MHz model) when accessing /proc/apm, you may get a kernel fault general protection fault: f000. Stephen Rothwell explains: "This is your APM BIOS attempting to use a real mode segment while in protected mode, i.e. it is a bug in your BIOS. .. We have seen a few of these recently, except all the others are in the power off code in the BIOS wher we can work around it by returning to real mode before attempting to power off. Here we cannot do this."

1.1.3. Processor frequency scaling

cpufreq is a Linux kernel driver to control the CPU frequency. It is included in all recent kernels and enabled by default by recent distributions. It supports most recent "mobile" processors. Note that only such processors support frequency scaling.

This driver lets user programs control cpu frequency by writing files in /sys/devices/system/cpu/cpu<n>/cpufreq/.

Actually, frequency scaling is usually handled by a governor program, according to system or user specific preferences.

CPUSpeed is the de-facto governor for Linux. It allows to control the cpufreq driver according to user defined criteria: CPU load, board temperature, battery / plugged in... It is released by default in recent distributions.

CPUspeed is usually configured through the /etc/cpuspeed.conf file (Fedora Core 4 example):


VMAJOR=1
VMINOR=1
DRIVER="speedstep-centrino"
OPTS="-i 2
-t /proc/acpi/thermal_zone/THM/temperature 70
-a /proc/acpi/ac_adapter/AC/state
-p 10 25
-m 600000 -M 1600000"

After making changes, you can restart CPUspeed with /etc/init.d/cpuspeed restart (Fedora Core example).

Type /usr/sbin/cpuspeed -h for details and more options.

You can type cat /proc/cpuinfo to consult the current processor speed. That's useful to check that the processor speed is scaled according to your settings.

1.1.4. Useful Resources for Power Management

1.1.5. Restoring your Work after Shutdown

Even if you don't use hibernate or suspend and switch off your system in a standard way, you still have ways of saving time getting back to your work.

Modern graphical environments (KDE or Gnome) restart the applications that were open when you logged out. However, most applications just get back to their initial state and you will probably need to open your files again.

For people who do not want to loose the HTML pages they were browsing, the Mozilla Firefox browser as a nice Bookmark All Tabs... command in the Bookmarks menu. This is very convenient to restore a set of tabs or just to start your browser with all your favorite information sites when you arrive in the morning. Firefox v3 can save the current state of the browser and will restore it upon powerup.

So, unless your computer is really computing something, you have less excuses for keeping it on!