PowerManagement

Revision 10 as of 2008-07-07 08:22:46

Clear message

Three tasks involved

  1. Handling of hardware events
  2. Power state switching
  3. Letting disks idle

Though power management will deal with these, their objective does not solely lie in power management.

Power management packages

Foremost there is the apm and acpi support in the linux kernel.

They make those kind of "hard" events like the end of battery power or the pressing of the suspend or other (laptop) buttons available to our software world.

Then there are event manager daemons apmd and acpid

They provide means to execute commands on these external events. They run the scripts they find in their config directory tree under /etc/acpi, or /etc/apm respectively.

The package acpi-support provides a set of such scripts under /etc/acpi that deal with handling special acpi buttons on laptops.

The package pm-utils provides the pm-action, pm-hibernate, pm-suspend and pm-suspend-hybrid commands. They allow to trigger hard power management events by software. The pm-tools also provide script directories to hook-in other software when switching power (saving) states.

The gnome-power-manager is a program with a graphical user interface that subscribes itself to power events and acts on them. It shows you the battery status on laptops and dims down the screen if on battery for example. It will also shutdown or hibernate the computer after some idle time or before the battery runs out, if a user is logged in.

Disk idleing

A separate task is allowing harddisks to idle, so they can be parked and spun-down for long enough periods of time. This is done by a package that is a little bit misleadingly called laptop-mode-tools but not "disk-idle". Disk idleing has to deal with things like reading ahead and postponing disk activity. The program got its name from a kernel feature that is called laptop_mode and allows Linux to chunk up writes to filesystems and not write in between. But to really let a disk idle one has to manage other parts of the system that are relevant to letting disks idle also, like drive parameters, mount options, filesystem settings, cache sizes, sync logging programs etc. "laptop_mode" will do all that.

Disk idleing is commonly needed, thus laptop-mode enabled, when laptops operate on batteries to extend the battery times. But for example in vehicles with external power supply disk idleing may be needed even on AC. Not necessarily to leave the disk spun down, but to leave the heads parked for shock protection.

Disk spin-down and head parking should not be activated without controlled disk idleing. The regular uncoordinated logging or journaling activity may spin up the disks back up almost immediately after spinning down and lead to excessive load cycling.

Power (saving) states

The Common power (saving) states are awake, standby, suspend and hibernate.

During the awake state all components of the computer are running.

During standby the CPU keeps running your programs but some components like the monitor and harddisks may be turned off. When you touch the mouse or keyboard or a harddisk is accessed by software they quickly wake up again.

In both the awake and the standby state the speed of modern CPUs may be throttled down,though. For example if not in use.

During suspend however the CPU is always stopped. In modern PCs even all other components except the RAM memory can be turned off. The RAM will hold the state.

During hibernation the state is written to harddisk and the whole computer is turned off.

How to get disks idleing correctly (without excessive load cycling)

Unfortunately, disk-idleing has been mangled into event handling and power state switching in Ubuntu in the past. And does not deliver idle disks but break disk idleing (laptop-mode) features and leaves undefined (factory default) apm settings in place.

To correct disk-idleing in Ubuntu 8.04 you need to adjust the following:

  • Enable CONTROL_HD_POWERMGMT=1 in /etc/laptop-mode/laptop-mode.conf
    • wiki:244832 missing hdparm -B setting during boot

  • Even though you may not ENABLE_LAPTOP_MODE_ON_BATTERY or _ON_AC in laptop-mode.conf, you still need to ENABLE_LAPTOP_MODE=true in /etc/default/acpi-support (another package's conffile).
    • wiki:244838 laptop-mode needs to be activated in two places

  • Comment the four $HDPARM blocks in /etc/acpi/power.sh and change the two $LAPTOP_MODE start/stop lines to "$LAPTOP_MODE auto"
    • wiki:244836 /etc/acpi/power.sh overrides user settingsBR wiki:244831 /etc/acpi/power.sh overrides user scriptsBR wiki:244844 Adapt laptop-mode-tools invocation to ubuntu's acpi-support / pm-tools packages

  • Remove /usr/lib/pm-utils/power.d/laptop-tools or create bogus /etc/pm/power.d/laptop-tools script.
    • wiki:239419 pm-utils has laptop-tools script which conflicts with laptop-mode-tools

  • Still no hdparm setting after resume.
    • wiki:244833 missing hdparm -B setting during resumeBR wiki:244839 /etc/acpi/start.d and resume.d scripts are not run.BR wiki:244844 Adapt laptop-mode-tools invocation to ubuntu's acpi-support / pm-tools packages also:BR wiki:238555 pm-utils doesn't reload hdparm.conf after a suspend