Battery Powered Linux Mini-HOWTO

David Lechnyr

Revision History
Revision 2.22003-05-27Revised by: drl
Minor corrections and updates including document structure
Revision 2.02002-10-08Revised by: drl
Major updates and conversion to DocBook SGML
Revision 1.01997-12-21Revised by: hm
Initial draft by Hanno Muller

This document describes how to optimize and configure power management on a ready-configured Linux system for use on battery-powered laptops. This will be helpful for everyone who runs Linux on a portable computer system. APM and ACPI methods of power management will be discussed, along with general power saving tips and techniques. There is also some discussion about the different types of batteries available.

Table of Contents
1. Introduction
1.1. Copyright Information
1.2. Disclaimer
1.3. About this document
2. Power Management
2.1. Advanced Power Management (APM)
2.2. Advanced Configuration and Power Interface (ACPI)
2.3. APM vs. ACPI: Which one?
3. Power Management Techniques
3.1. hdparm Tuning
3.2. syslog Tuning
3.3. XF86Config Tuning
3.4. Swapfile Tuning
3.5. /tmp Tuning
3.6. Miscellaneous Tuning
3.7. Power Saving Myths
4. Types of Batteries
4.1. Nickel Cadmium (Ni-Cd)
4.2. Nickel Metal Hydride (Ni-MH)
4.3. Lithium Ion (Li-ion)
4.4. Smart Batteries
4.5. General Battery Care

1. Introduction

The Linux Battery Powered Mini-HOWTO has undergone some significant enhancements from its last publication in 1997. Specific attention will be paid towards recent advances in the Linux realm with ACPI, specific power saving techniques, and general battery issues.

1.1. Copyright Information

This document is the result of the work and contribution of many individuals. As such, it is released under the terms of the GNU Free Documentation License. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation. A copy of the license is available at

1.2. Disclaimer

Power management can be tricky stuff. As such, no liability for the contents of this document can be accepted. Use the concepts, examples and other content at your own risk. This information is provided "as is" without any warranty, condition, or representation of any kind, either express or implied, including but not limited to, any warranty respecting non-infringement, and the implied warranties of conditions of merchantability and fitness for a particular purpose. In no event shall anyone connected to this document be liable for any direct, indirect, special, incidental, consequential or other damages howsoever caused whether arising in contract, tort, or otherwise, arising out of or in connection with the use or performance of the information contained in this document.

1.3. About this document

This document was lovingly handcrafted on a Dell Latitude C400 laptop running Slackware Linux 9.0, in case anyone asks.

2. Power Management

If you have a relatively recent x86 laptop, odds are it supports either Advanced Power Management (APM) or Advanced Configuration and Power Interface (ACPI). ACPI is the newer of the two technologies and puts power management in the hands of the operating system, allowing for more intelligent power management than is possible with BIOS controlled APM. You can only have one power management interface in control of your machine at a time, so it's important you decide which method best suits your situation.

2.1. Advanced Power Management (APM)

Advanced Power Management (APM) is a method for saving power on your computer. This is mostly useful for battery-powered laptops. APM allows your computer's BIOS to control your system's power management without the knowledge of the operating system. The advantages to APM under Linux are that it's stable and has a solid history behind it. However, not much development has been done with it over the past few years.

To use it, you'll need to enable APM in the kernel. Most of the other APM options exist as work-arounds for known problems with specific hardware devices, so you'll probably only want to enable the first one (CONFIG_APM).

  • Advanced Power Management BIOS support (CONFIG_APM): You'll need to enable this in order to do anything useful with APM. User-space programs will receive notification of APM events (e.g., battery status change) and a /proc/apm device will provide you with battery status information.

  • Ignore USER SUSPEND (CONFIG_APM_IGNORE_USER_SUSPEND): This is a workaround for NEC Versa M notebooks.

  • Enable PM at boot time (CONFIG_APM_DO_ENABLE): Although it sounds nifty, most machines do not require this feature to be enabled and in fact can hang some systems at boot time.

  • Make CPU Idle calls when idle (CONFIG_APM_CPU_IDLE): On some machines, this option provides increased power savings. On others, it will hang the system at boot time. Use with caution.

  • Enable console blanking using APM (CONFIG_APM_DISPLAY_BLANK): Instead of blanking the virtual console actually turn off the screen. This won't work with X-Windows and actually can cause more problems that it solves.

  • RTC stores time in GMT (CONFIG_APM_RTC_IS_GMT): If you want to store GMT (Greenwich Mean Time) in your RTC (Real Time Clock), say yes here.

  • Allow interrupts during APM BIOS calls (CONFIG_APM_ALLOW_INTS): This is a workaround for some IBM Thinkpads that hang while suspending.

  • Use real mode APM BIOS call to power off (CONFIG_APM_REAL_MODE_POWER_OFF): This is a workaround for a number of broken BIOSes. If your computer crashes instead of powering off properly, turn this on.

You'll want to install the APM daemon from and configure your system startup scripts to activate it on boot:

# Start the APM daemon if APM is enabled in the kernel
if [ -x /usr/sbin/apmd -a -d /proc/apm ]; then
	if cat /proc/apm 1> /dev/null 2> /dev/null ; then
		echo "Starting APM daemon:  /usr/sbin/apmd"

The APM daemon is actually made up of three primary programs:

  • apmd - handles power management tasks

  • apm - a command-line tool to print the current battery status or suspend the computer

  • xapm - a simple battery meter for X

If you're looking for a simple, "works out of the box" approach to power management for your Laptop, APM is definitely the way to go.

2.2. Advanced Configuration and Power Interface (ACPI)

Advanced Configuration and Power Interface (ACPI) is the successor to APM, which places the responsibility of power management away from the BIOS and into the hands of the operating system. ACPI Linux is newer than APM Linux, more flexible in responding to power management events, has seen much more development as of late, and as a result of all this is prone to its own share of bugs from time to time.

If you're into cutting-edge development, are running a relatively recent (>2.4.10) kernel, and are not intimidated with kernel builds and applying patches against source code, ACPI is worth consideration.

There are two parts to ACPI under Linux: The ACPI driver built into the kernel itself, and the ACPI daemon (ACPID). ACPID in its current incarnation is pretty simple: monitor /proc/acpi/event and do things in response. Even if you don't load the daemon, you'll still get the benefit of ACPI features built into the kernel such as processor thermal support.

When booting your ACPI-enabled system, you can determine which version of the ACPI driver you are using by looking for something similar to this:

	ACPI: Subsystem revision 20030523
ACPI development is progressing at a steady rate, so you might want to consider patching your kernel against any recent updates to the kernel-level ACPI code. Once you have downloaded the patch for your specific kernel, you can patch it with something like:

$ gunzip acpi-[version]-[kernel].diff.gz
# mv acpi-[version]-[kernel].diff /usr/src/linux-[version]
# cd /usr/src/linux-[version]
# patch -p1 < acpi-[version]-[kernel].diff
You'll want to recompile your kernel after this, of course.

You'll also want to install the ACPID daemon from and configure your system startup scripts to activate it on boot:

if [ -x /usr/sbin/acpid -a -d /proc/acpi ]; then
	echo "Starting ACPID Daemon:  /usr/sbin/acpid"

A bit of history... Microsoft was the first vendor to implement ACPI. This is both good and bad. It is good because when you buy a system, you can pretty much guarantee that it has passed Microsoft's hardware compliance tests, including the test of its ACPI implementation. However, these tests come up short in that they do not indicate compliance with the ACPI specification, but rather with Microsoft's implementation of ACPI. When that same machine is used with Linux, some classes of errors that did not manifest themselves under Windows may become apparent. To protect against this problem, the Linux ACPI driver maintains a "bad BIOS" blacklist of known BIOS's that are known to not be ACPI compliant, and as a result will refuse to enable ACPI if your system is listed.

Many manufacturers are now validating that their systems run on Linux. However, they use major Linux distributions with the default kernel. This means that it is somewhat difficult to get OEMs to ensure that their systems work with ACPI-enabled Linux until a major Linux distribution ships an ACPI kernel. This presents a slight dilemma in that Linux distributions want to ship kernels that run on as many systems as possible, but there have been some positive moves in this area lately.

For more specific background information on ACPI itself, you can visit the ACPI website at

2.3. APM vs. ACPI: Which one?

There are currently two competing standards for providing power management: APM and ACPI. Both cannot be used at the same time, so which one is best for your situation? If you have a relatively recent (>2.4.10) kernel and are not intimidated by kernel builds and patching source code, you'll find many benefits with the flexibility of ACPI. If you just want to enable generic power management, or are using an older machine, choose APM. Neither method spins down idle hard drives; use hdparm for that instead. Either way, your system's BIOS must correctly support the power management scheme you'd like to use as well; if your system does not fully support either standard, some of the power management options might crash your system and/or cause data loss. You have been warned!

Regardless, you should be aware that even if you don't enable any power management on your laptop, on the x86 architecture Linux will always issue the "hlt" instruction to your processor whenever nothing needs to be done. This results in lowering the power consumption of your CPU. Note that the system doesn't power down when it receives the hlt instruction; it just stops executing instructions until there is an interrupt.

Some system manufacturers may have omitted the pre-ACPI tables used for SMP configuration. In this case, ACPI is required. If a system supports HyperThreading, it must use ACPI tables to discover all the virtual processors present. IA64 machines require ACPI, and NUMA servers are starting to require it for proper initialization as well. There is generally no advantage to enabling either type of power management on servers or workstations that do not fall into these categories.

One item to consider is actual use: Try using your laptop under both APM and ACPI. You'll probably be suprised if both methods provide approximately the same amount of power savings (hint, hint)!

3. Power Management Techniques

The basic goal of any power management technique is to reduce an entity's consumption. In the case of laptop power management, our focus is on decreasing CPU and hard drive usage. To make things a bit simpler, this is broken down into obvious, semi-obvious, and non-obvious techniques. Granted, your mileage may vary.

3.1. hdparm Tuning

hdparm is a Linux shell utility that can be used to spin down and improve the performance of various ATA/IDE drives. If it's not included with your system, you can fetch the source from For example, the following provides 32-bit IO support with sync (-c3), DMA support (-d1), Advanced Power Management (-B128), write-caching (-W1), disk spin down after five minutes (-S60). gains me tremendous performance with added power savings. Note that your mileage may vary, and you'll want to adjust this for your specific system to prevent data loss (especially the -B and -m flags!).

In the following example, we run some read/write benchmarks of our hard drive before and after using hdparm. Note that while our cache reads remain about the same, our actual physical reads from the drive increase tremendously! If you like living on the edge, you can play with the -m, -c, -B, and -u switches with caution (see the man page).

# hdparm -tT /dev/hda
Timing buffer-cache reads:   588 MB in  2.01 seconds = 292.15 MB/sec
Timing buffered disk reads:   14 MB in  3.46 seconds =   4.05 MB/sec

# hdparm -k1 -K1 -c3 -d1 -W1 /dev/hda
# hdparm -tT /dev/hda
Timing buffer-cache reads:   596 MB in  2.01 seconds = 297.01 MB/sec
Timing buffered disk reads:   72 MB in  3.05 seconds =  23.58 MB/sec

3.2. syslog Tuning

Examine your /etc/syslog.conf file for unnecessary logging activity and to optimize its performance. If you don't want to log any system activity, consider disabling syslogd and klogd entirely or, at the very least, minimize the amount of logging your system performs. You can also prefix each entry with the minus sign (-) to omit syncing the file after each log entry. For example, this will log anything with a priority of info or higher, but lower than warning, to /var/adm/messages or /var/adm/mail without needing to sync to disk after each write. Since we want to keep all messages with a priority of warning, this will be logged to a different file without disabling disk syncing (to prevent data loss in the event of a system crash).

	*.warning			/var/adm/syslog
	*.info;*.!warning;mail.none	-/var/log/messages;mail.!warning		-/var/log/mail

3.3. XF86Config Tuning

Screen blanking under X-Windows is primarily controlled five configuration options in /etc/X11/XF86Config. The most basic, and useless setting, is BlankTime, which creates a fake blanking effect on the screen.

If you have a DPMS-compliant monitor, you might want to try enabling support for it under the Monitor section of your XF86Config file:

Section "Monitor"
	[... other values here ...]
	Option	"DPMS"

To manipulate the DPMS functions, you can create/modify the following items in the ServerLayout section:
Section "ServerLayout"
	Option "BlankTime"	"10"	# Blank the screen
	Option "StandbyTime" 	"15"	# Turn off screen
	Option "SuspendTime"	"30"	# Full hibernation
	Option "OffTime"	"60"	# Turn off DPMS monitor

It's worth noting that the driver for your video card might not fully support these options.

3.4. Swapfile Tuning

Consider disabling your swap file in /etc/fstab to reduce hard drive access. If you've got lots of memory, this is definitely the way to go. One way to tell if you need your swap file is to enable it, use your system for a period of time, and examine /proc/meminfo and /proc/swaps to determine how much free memory you've got on average, and whether or not your swap file is even being utilized.

For example, today I've compiled several intensive programs and have been running my laptop for about eight hours straight. A simple examination of my system reveals:

bravo:~$ cat /proc/swaps
Filename                                Type            Size    Used    Priority
/dev/hda3                                partition      136544  0       -1

bravo:~$ cat /proc/meminfo
MemTotal:       513880 kB
MemFree:        254820 kB
Buffers:         42812 kB
Cached:         142880 kB
SwapCached:          0 kB
Active:         159644 kB
Inactive:        76888 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:       513880 kB
LowFree:        254820 kB
SwapTotal:      136544 kB
SwapFree:       136544 kB
Dirty:               0 kB
Writeback:           0 kB
Mapped:          86148 kB
Slab:            10748 kB
Committed_AS:   203944 kB
PageTables:       1140 kB
VmallocTotal:   516076 kB
VmallocUsed:      1468 kB
VmallocChunk:   514604 kB
HugePages_Total:     0
HugePages_Free:      0
Hugepagesize:     4096 kB
Given this, I'd opt to disable my swapfile if this is any indicator of my future usage.

3.5. /tmp Tuning

Compile your kernel with tmpfs (temporary file system) enabled and mount your /tmp directory using it. The useful bit here is that nothing will be written to your hard drive on this mount point as it will act like a RAM disk (however nothing will be saved either). The advantage of tmpfs over the more traditional ramfs is that it lives in the kernel internal cache and grows and shrinks to accommodate the files placed there. See your kernel's Documentation/filesystems/tmpfs.txt for full information. If you don't specify a maximum size, it will default to a ceiling limit of half your available memory. An example /etc/fstab with 100MB temporary ram file mounted on /tmp would look like:

	tmpfs	/tmp	tmpfs	size=100m,mode-1777	0 0

3.6. Miscellaneous Tuning

Boot your system and list the currently loaded modules with lsmod. Anything listed here most likely needs to be loaded on a regular basis; compiling these in as part of your kernel rather than as loadable modules may help to decrease the amount of time they must be loaded from disk, and to a very minor degree, decrease the amount of disk access required to start your system.

Examine your crontab settings to see if anything is being run on a regular basis. Comment out any unnecessary items. Don't forget to examine every user's crontab, including the user 'nobody'. If you don't need to schedule any background activity, consider disabling crond alltogether. The same advice goes for atd.

If you run httpd to test and/or develop web pages, try altering the values of MinSpareServers and StartServers to 1. Don't define any CustomLogging or at least increase the value of LogLevel to warn. If you're really sure of yourself, you can change the ErrorLog directive to point to /dev/null.

Additionally, it's worth considering anything in the following areas:

  • Adjust your system's BIOS settings to decrease or turn off your display's backlight.

  • Adjust your system's BIOS settings to reduce the CPU clock speed while on battery.

  • Avoid using PCMCIA devices while on battery. Better yet, eject your PCMCIA cards when not in use.

  • Avoid using external devices with your computer while on battery. This includes printers, external monitors, zip drives, and portable cameras.

  • Avoid using built-in devices while on battery. This includes cdroms and floppy drives.

  • Use simple software. A full blown multimedia application will create a lot more system load and disk activity than a small simple word processor

  • Use a simple window manager. While Gnome and KDE are nice, the extra time it takes to load and run is not worth it while on battery power. One nifty idea is to use a different xinitrc script to launch a different, more simple window manager based on whether or not your system is on battery power.

3.7. Power Saving Myths

One popular pastime involved modifying the update/bdflush daemon to change the frequency of flushing the filesystem buffers (sync). However, the current Linux kernels do not use a user space update daemon any more,so any modifications you make here will simply never take effect.

It used to be beneficial to recompile the Linux PCMCIA drivers to allow the slots to have APM power support. However, most of the functionality of these drivers are now built into the kernel itself. If you're interested in specifics, the PCMCIA project page is available at

Some people believe that APM offers better power savings over ACPI, and vice-versa. While their power management techniques differ, in actual battery-usage tests, both reportedly perform about the same.

4. Types of Batteries

There are currently three types of batteries commonly used for laptops: Nickel Cadmium, Nickel Metal Hydride, and Lithium Ion.

4.1. Nickel Cadmium (Ni-Cd)

Nickel Cadmium (Ni-Cd) batteries were the standard technology for years, but today they are out of date and new laptops don't use them anymore. They are heavy and very prone to the "memory effect". When recharging a NiCd battery that has not been fully discharged, it "remembers" the old charge and continues there the next time you use it. The memory effect is caused by crystallization of the battery's substances and can permanently reduce your battery's lifetime, even make it useless. To avoid it, you should completely discharge the battery and then fully recharge it again at least once every few weeks. As this battery contains cadmium, a toxic material, it should always be recycled or disposed of properly.

NiCad batteries, and to a some degree NiMH batteries, suffer from what's called the memory effect. Memory Effect means that if a battery is repeatedly only partially discharged before recharging, the battery will forget that it can further discharge. The best way to prevent this situation is to fully charge and discharge your battery on a regular basis.

4.2. Nickel Metal Hydride (Ni-MH)

Nickel Metal Hydride (Ni-MH) batteries are the cadmium-free replacement for NiCad. They are less affected by the memory effect than NiCd and thus require less maintenance and conditioning. However, they have problems at very high or low room temperatures. And even though they use less hazardous materials (i.e., they do not contain heavy metals), they cannot be fully recycled yet. Another main difference between NiCad and NiMH is that NiMH battery offers higher energy density than NiCads. In other words, the capacity of a NiMH is approximately twice the capacity of its NiCad counterpart. What this means for you is increased run-time from the battery with no additional bulk or weight.

4.3. Lithium Ion (Li-ion)

Lithium Ion (Li-ion) are the new standard for portable power. Li-ion batteries produce the same energy as NiMH but weighs approximately 20%-35% less. They do not suffer from the memory effect unlike their NiMH and Ni-Cd counterparts. Their substances are non-hazardous to the 0. Because lithium ignites very easily, they require special handling. Unfortunately, few consumer recycling programs have been established for Li-ion batteries at this point in time.

4.4. Smart Batteries

Smart batteries are not really a different type of battery, but they do deserve special mention. Smart batteries have internal circuit boards with chips which allow them to communicate with the laptop and monitor battery performance, output voltage and temperature. Smart batteries will generally run 15% longer due to their increased efficiency and also give the computer much more accurate "fuel gauge" capabilities to determine how much battery run time is left before the next recharge is required.

4.5. General Battery Care

Even if the battery case looks the same, you cannot just upgrade to another battery technology unless your laptop has been pre-configured from the manufacturer to accept more than one type of battery type, since the recharging process is different for each of the three types of batteries.

A battery that is not used for a long time will slowly discharge itself. Even with the best of care, a battery needs to be replaced after 500 to 1000 recharges. But still it is not recommended to run a laptop without the battery while on ac power -- the battery often serves as a big capacitor to protect against voltage peaks from your ac outlet.

As the manufacturers change the shapes of their batteries every few months, you might have problems to find a new battery for your laptop in a few years from now. This is somewhat of a concern only if you anticipate using the same laptop several years from now. If in doubt, buy a spare battery now - before it's out of stock.

New batteries come in a discharged condition and must be fully charged before use. It is recommended that you fully charge and discharge the new battery two to four times to allow it to reach its maximum rated capacity. It is generally recommend that you perform an overnight charge (approximately twelve hours) for this. Note: It is normal for a battery to become warm to the touch during charging and discharging. When charging the battery for the first time, the device may indicate that charging is complete after just 10 or 15 minutes. This is a normal with rechargeable batteries. New batteries are hard for the device to charge; they have never been fully charged and are not broken in. Sometimes the device's charger will stop charging a new battery before it is fully charged. If this happens, remove the battery from the device and then reinsert it. The charge cycle should begin again. This may happen several times during the first battery charge. Don't worry; it's perfectly normal. Keep the battery healthy by fully charging and then fully discharging it at least once every two to three weeks. Exceptions to the rule are Li-Ion batteries which do not suffer from the memory effect.

Batteries should be stored in a discharged state since they can self-discharge and may become inactive after a long storage period. They should not be stored for any length of time while connected to the laptop. High humidity and temperatures can cause the battery to deteriorate, so these should be avoided during storage.

Do not remove and carry a battery pack in your pocket, purse, or other container where metal objects (such as car keys or paper clips) could short-circuit the battery terminals. The resulting excessive current flow can cause extremely high temperatures and may result in damage to the battery pack or cause fire or burns.