Laptops:Power Management
From Lnx101
| Table of contents |
Introduction
Power management is used on laptops to save power, resulting in a cooler laptop and longer battery life. It is also responsible for suspending.
APM vs. ACPI
APM, or Advanced Power Management, is the older of the two power management standards. While not nearly as thorough, it is usually better supported and not quite as complicated as ACPI. To turn APM on, add apm=on to your boot loader. You may also have to load the apm module, depending on your distribution. If you wish to use ACPI, add acpi=on instead. You may also want to install apmd, or the APM Daemon. It provides the functions of stopping/starting certain things on suspend/unsuspend that must be reinitialized. Any such configuration is done in /etc/apm.
ACPI
ACPI, or the Advanced Configuration and Power Interface, is the more recent standard for power management. Some newer laptops only support ACPI, and not APM. ACPI is one of the more notoriously buggy features, due to broken BIOS implementations.
- Requirements
- acpi turned on, as noted above
- ACPI modules loaded, if not done by the system (battery, ac, button)
- Recommended
- acpid (provided by the distribution)
Suspending
The most typical type of suspend is suspend-to-memory (there is also suspend-to-disk). This is where the CPU, hard drive, and screen shut down, but just enough power is used to keep the contents stored in memory. The amount of power a system uses while in this mode is enough to last 1 or 2 days.
To suspend to memory, execute as root:
- #
echo -n "mem" > /sys/power/state
Hibernating
Hibernation, or suspend-to-disk, is where the system writes the contents of memory to the hard disk and then completely turns off. The contents is then restored when the system is turned back on.
To hibernate:
- #
echo -n "disk" /sys/power/state
Throttling
While ACPI throttling can be used to decrease power usage, it does not scale back the CPU voltage like SpeedStep and the equivalents for other CPU's. It's recommended to use one of the following modules, depending on your CPU:
- Intel
- speedstep-centrino
- speedstep-ich (P4 Mobile)
- speedstep-smi
- AMD
- powernow-k6
- powernow-k7
- powernow-k8
Add the appropriate one along with the cpufreq-userspace module to be loaded by default.
Next, you will need a daemon to watch the required processing power and scale the CPU accordingly. Any that are compatabile with the CPUFreq interface will work. These include:
- powernowd
- cpudyn
- cpufreqd
- speedreqd
powernowd is the simplest of them all. Most should be able to find at least one of these in their distribution's repositories. Be sure to add it to start by default.
After starting the deamon, you should see a decrease in CPU clock speed, assuming your CPU isn't under load:
- $
cat /proc/cpuinfo
model name : Intel(R) Pentium(R) 4 Mobile CPU 1.60GHz stepping : 4 cpu MHz : 1196.613
Here it is a 1.6GHz CPU, but is currently running at 1.2GHz.
Buttons
Many laptops have special buttons to adjust volume, pause playback, etc. Go into your Keyboard Preferences and hit the key like any other key you'd use to change the mappings.
ACPI Events
While we have explored how to trigger ACPI events such as suspend, you can also configure what to happen when events occur, such as switching from AC to batter, or closing the laptop screen. For this, you need acpid.
Suspending on Screen Close
Many people would like the computer to suspend when they close the lid of the laptop instead of having to type a command. First go into events directory:
- #
cd /etc/acpi/events
Here we want to add an event for closing the lid. Create this file:
# /etc/acpi/events/lid event=button[ /]lid action=/etc/acpi/actions/lid.sh
Now create the action file, as specified:
- #
cd /etc/acpi/actions
#!/bin/bash #/etc/acpi/actions/lid.sh echo -n "mem" > /sys/power/state
Make it executeable:
- #
chmod u+x lid.sh
That's it! Now when the ACPI event is triggered by closing the lid of the laptop, the script will be executed. You can customize these scripts for any special needs.
The events that are produced correspond to the files in /proc/acpi. For example, there is /proc/acpi/buttons/lid. You can explore the directory to see what other events you can handle.
APM
Suspending
For APM, your laptop will probably follow the settings defined in the BIOS for events such as closing the lid. You can also suspend by typing:
- $
apm -s
/usr/bin/apm will need to be setuid root, or be run as root.

