Power Management Guide
About this document...
This document describes the setup of power management features on your laptop.
Although some of the information in this guide can be applied to power
management for servers, it is not the intention of this document to go that
route. Please be careful when applying this on a non-laptop system.
Within this document, we will focus primarily on the laptop mode tools since it
offers a complete set of functionalities. However, we will also refer to other
tools that might offer a more detailed approach on individual settings. In such
cases, you will need to disable the feature from the laptop mode tools so that
both tools do not fight over the same resource control.
The laptop_mode setting is an in-kernel configuration setting that
optimizes I/O, allowing disks to spin down properly (and not be woken up
immediately afterwards for queued operations).
The Laptop Mode Tools is a software package
(app-laptop/laptop-mode-tools) which allows the user to optimize power
saving functions. It allows managing the laptop_mode setting in the Linux
kernel, but has additional features allowing you to tweak other power-related
settings on the system.
Linux Kernel Configuration
Minimum kernel setup
There are different kernel sources in Portage. We recommend using
gentoo-sources, but if you want advanced hibernation support you might
need tuxonice-sources. To enable proper power management features in the
Linux kernel, enable at least the following settings:
Code Listing 2.1: Minimum kernel setup for Power Management
General setup --->
[*] Configure standard kernel features (expert users) --->
Power management and ACPI options --->
[*] Run-time PM core functionality
[*] ACPI (Advanced Configuration and Power Interface) Support --->
<*> AC Adapter
<*> Thermal Zone
[*] Power Management Timer Support
[*] CPU Frequency scaling --->
[*] CPU Frequency scaling
<*> 'performance' governor
<*> 'powersave' governor
<*> 'userspace' governor
<*> 'ondemand' governor
<*> 'conservative' governor
<*> ACPI Processor P-States driver
Don't forget to enable the CPU frequency scaling driver for your CPU, located
right after the ACPI Processor P-States driver mentioned above.
Build and install the new kernel (if necessary) and reboot.
Using Laptop Mode Tools
It comes to no surprise that installation of the Laptop Mode Tools
software is easily done through emerge laptop-mode-tools. However, this
package takes on additional, optional settings through USE flag configuration.
So let's first take a look at the supported USE flags and what they mean to the
Depend on sys-power/acpid so that changes in the system are
captured and power saving features are automatically enabled/disabled.
||your laptop is not too old (~ year 2003 and later)
Depend on sys-apps/apmd so that changes in the system are captured
and power saving features are automatically enabled/disabled.
||your laptop is very old
Depend on net-wireless/bluez, enabling the laptop-mode-tools
to manage bluetooth settings (enabling/disabling the service based on
||your laptop (and kernel) supports bluetooth
Depend on sys-apps/sdparm, enabling the laptop-mode-tools to
manage SCSI (and not SATA) disk parameters.
||your laptop uses SCSI disks
As you can see, there are two USE flags that seem to collide: acpi and
apm. So what's the deal there?
The apm USE flag enables support for Advanced Power
Management, an older (before year 2000) standard for power management
features within a system.
The acpi USE flag enables support for Advanced Configuration and
Power Interface, the successor of APM. All modern laptops support ACPI.
Depending on your system, you will either need acpi or apm set. In
the remainder of this guide, we assume that your laptop is recent enough to use
So, with the USE flags set, let's install laptop-mode-tools.
If you have USE="acpi" set, the installation will pull in acpid. However,
the current stable ACPI daemon (2.0.9) does not support the new ACPI interfaces
within the Linux kernel (using the netlink interface). As such, we recommend
unmasking sys-power/acpid-2.0.12 (or higher). For more information about
unmasking packages, please read
Branches in the Gentoo Handbook.
Code Listing 3.1: Installing laptop-mode-tools
# emerge laptop-mode-tools
Having laptop-mode-tools installed on your system does not automatically
enable the power management features that you might need. To configure the
package, first take a look at /etc/laptop-mode/laptop-mode.conf.
This is the main configuration file for the package and is pretty well described
But it is not the only configuration file to work with. The Laptop Mode Tools
package supports plugins (or modules) which have their own configuration
file(s). These files are located in /etc/laptop-mode/conf.d and are
named after the module they represent (such as
Now, one of the important settings in each configuration file is if the Laptop
Mode Tools package should govern a particular setting or not. This is important
when you want to combine laptop-mode-tools with other services like
cpufreqd. In this example case, you will need to set
Code Listing 3.2: Editing /etc/laptop-mode/conf.d/cpufreq.conf
# nano -w /etc/laptop-mode/conf.d/cpufreq.conf
The next few sections will help you configure laptop-mode-tools to suit
your needs. When you are finished, start the laptop_mode service and make
sure it is started when you boot up your system.
Code Listing 3.3: Starting the laptop_mode service
# /etc/init.d/laptop_mode start
# rc-update add laptop_mode default
How does laptop-mode-tools work
When running the laptop_mode service, the software will check in which
state your system is in. The states are defined as:
Battery, which is active when the system is running on battery power;
the configuration files use the BATT_ prefix for settings related to
AC, which is active when the system is running on AC power;
the configuration files use the AC_ prefix for settings related to
Laptop Mode, which is active when laptop mode is enabled;
the configuration files use the LM_ prefix for settings related to
No Laptop Mode, which is active when laptop mode is disabled;
the configuration files use the NOLM_ prefix for settings related to
The AC/BATT_ and LM/NOLM_ prefixes can be combined (so you can
have a AC_LM_ prefix).
When the laptop_mode service is started, it will switch modes based on
events that occur (and of course based on the configuration settings). For
instance, the setting ENABLE_LAPTOP_MODE_ON_BATTERY=1 will make sure that
the laptop mode tools switch to laptop mode when battery power is used.
If that is the case, then the settings starting with LM_,
LM_BATT_, BATT_LM_ and BATT_ will be used.
To make sure settings to not collide, it is not allowed to have overlapping
settigns. In the next example, the first set (for CPU_MAXFREQ) is valid,
but the second one (for CPU_GOVERNOR) isn't.
Code Listing 3.4: Colliding settings
Configuring CPU frequency management
The support for CPU frequency management in the laptop mode tools allows
switching frequencies. It supports setting the CPU frequency governor, minimum
frequency and maximum frequency. The configuration file used here is
The CPU frequency governor is a kernel-level policy that defines how the
kernel will select the CPU frequency. We already selected the governors we want
to use in the kernel configuration earlier. Let's recap:
performance always picks the highest frequency
powersave always picks the lowest frequency
userspace does not pick anything, but let the user decide (or any
process that the user is running that will decide for the user)
ondemand will scale the CPU frequency up to the highest frequency
when load is available
conservative will scale the CPU frequency up gradually when load is
When switching between AC or battery, or (no) laptop mode, the appropriate
governor (as well as its minimum and maximum frequency) is selected.
Configuring display brightness
With /etc/laptop-mode/conf.d/lcd-brightness.conf, you can have the
laptop mode tools govern the brightness of your LCD screen.
The file currently uses the /proc/acpi/video/VID/LCD/brightness
file to set brightness values. Recent kernels do not provide this anymore -
you will need to adjust this to /sys/class/backlight/acpi_video0/brightness
The values you can use are between 0 and 15, with 0 being the lowest brightness
Configuring other services
An interesting feature of laptop-mode-tools is to support reloading
particular services (like the system logger) after switching its configuration
file. This is handled through
If enabled, the laptop_mode application will switch the configuration
file(s) of the mentioned services with the same file, but suffixed with
-nolm-ac, -lm-ac or -batt. It willl then
signal or reload the appropriate services so they can use the new configuration
The cpufreqd application allows you to manage CPU frequencies in a more
granular approach then what laptop-mode-tools supports. But before we
dive into the installation of cpufreqd, let's first look at the USE flags
Enable support for ACPI, allowing cpufreqd to be notified about
specific events as well as govern power through the ACPI interface
||your laptop is not too old (~ year 2003 and later)
Enable support for APM, allowing cpufreqd to be notified about
specific events as well as govern power through the APM interface
||your laptop is very old
Enable support for the Linux hardware sensors (through
sys-apps/lm_sensors), allowing to switch profiles based on hardware
you want to use advanced events through lm_sensors
Enable support for NForce, allowing cpufreqd to change the NForce FSB
clock and video card frequency
you have an NVidia graphical card based on the NForce chipset
Enable support for NVidia graphical card configuration (through the NVidia
nvclock interface), allowing cpufreqd to change the video card
frequency of NVidia graphical cards
you have an NVidia graphical card
Enable the Power Management Unit plug-in of cpufreqd. This allows the
software to poll the Linux kernel Power Supply interface, getting more
detailed information on battery charge.
your laptop does not support ACPI or APM
The USE flags acpi, apm and pmu overlap, so you should only
have one active. If your laptop is sufficiently recent, acpi is your best
bet. If not, apm offers all that is needed. When even APM isn't
supported, you can try pmu.
With the USE flags configured, it is time to install cpufreqd.
Code Listing 4.1: Installing cpufreqd
# emerge cpufreqd
The cpufreqd application monitors the status of the system through
several plugins. Based on the feedback it receives from those plugins, it will
adjust the policy used to govern the CPU frequency.
cpufreqd can be configured by editing /etc/cpufreqd.conf. It
contains three different sections:
The [General]...[/General] section contains general configuration
The [Profile]...[/Profile] section defines the policies that the
cpufreqd daemon can switch to. The section is very similar to the
information you use when manually setting the CPU frequency policy using
The [Rule]...[/Rule] section is the work-horse of the cpufreqd
daemon, defining when the daemon decides to switch to a different profile.
Let's take a quick look at an example rule.
Code Listing 4.2: Sample cpufreqd rule
name=On Demand High
name=AC Off - High Power
profile=On Demand High
In the above example, cpufreqd will switch the system to the On Demand
High profile (also shown in the above excerpt). This profile by itself uses
the ondemand governor with a minimum frequency of 40% (iow, a CPU of 2Ghz
will have by this policy a minimum frequency of 800Mhz).
As you can see, the cpufreqd application can offer a more granular
approach on CPU frequency scaling. But not only that, you can tweak the CPU
frequency scaling based on various other metrics available. The default
configuration offers a sample rule for when you watch a movie, where you want
maximum performance, unless the CPU temperature is getting too high.
When you have configured cpufreqd, it is time to start it (and make sure
the service is loaded automatically). Make sure that CPU frequency handling by
other tools (like laptop-mode-tools) is disabled!
Code Listing 4.3: Starting cpufreqd
# rc-update add cpufreqd default
# /etc/init.d/cpufreqd start
Articles and Guides
A ThinkWiki article on How to
reduce power consumption (on Linux). This article offers an exhaustive
list of measures one can take. However, it should be noted that the laptop
mode tools implements the majority of these (if properly configured).
The contents of this document, unless otherwise expressly stated, are licensed under the CC-BY-SA-2.5 license. The Gentoo Name and Logo Usage Guidelines apply.