Search:  
Gentoo Wiki

Power_Management

The Gentoo Power Management Guide covers setting up power management. Read it first, and refer to this guide for clarifications and methods not mentioned there. Note, some options may vary depending on your laptop model.

Contents

LCD Power Management

Explanation of the X config settings mentioned in the official guide's LCD Power Management section:

Note: The following options require DPMS support in both monitor and display adapter

How to set these options can be found here.

DPMS may also be managed using xscreensaver (or its counteparts gnome-screensaver and kscreensaver in gnome and kde).

emerge -av x11-misc/xscreensaver

Note that many 3D screensavers can cause increased power consumption. You may want to use

$ <xscreensaver-command> --throttle

to only blank the screen instead when running on battery. A good idea is to attach this command to the ACPI action "lid closed."

Adjust LCD brightness

As of Linux kernel 2.6.10, there is a generic ACPI video driver:

Linux Kernel Configuration: Power Management video support
 Power management options (ACPI, APM)  --->
    ACPI (Advanced Configuration and Power Interface) Support  --->
       <*>   Video
 Device Drivers  --->
    Graphics support  --->
       <*> Lowlevel video output switch controls
       [*] Backlight & LCD device support  --->
          <*>   Lowlevel Backlight controls

To see what states your LCD supports:

# cat /proc/acpi/video/(Laptop dependent)/LCD/brightness

the (Laptop dependent) section depends on your model (specifically the DSDT tables of your computer). This is often "VGA" or "GRFX".

If the driver is loaded and your display device is supported, the above command should show the supported brightness levels. To change the brightness in a script, or on the command line, use:

# echo N > /proc/acpi/video/.../LCD/brightness

The N is a number from the supported levels provided by the 'cat' command above.

Hard disk

The hard disk is a large consumer of power within your laptop. In order to save power you would want to minimize your hard disk activity. This can be done by combining a couple of techniques:

These goals can be achieved using the following means:

Hard disk performance

hdparm is used to tweak hard disk settings. Starting with kernel 2.6, most of these improvements are turned on by default (unless your hardware is problematic).

One of these settings disabled by default (set to 0) is the sleep time (support for this depends on your hard disk model). Use:

# hdparm -S12 <hard disk device file> 

These the number in the switch is multiples of 5 seconds. After that time the hard disk will spin down.

# hdparm -S0 <hard disk device file>

disabled this behavior.

Warning: This should not be used in combination with the laptop mode.

SysLog tuning

Examine your system logger's config file for unnecessary logging activity and minimize its activity. If you don't want to log any system activity, consider disabling it entirely.

Laptop mode

Introduced in the official guide. For more information read /usr/src/linux/Documentation/laptop-mode.txt and the laptop-mode website

Swap space

swapoff -a can be used to turn off swap. Use swapon -a to turn it back on.

One way to tell if you need your swap file is to enable it and use your system for a period of time. Examine /proc/meminfo and /proc/swaps to determine the amount of free memory, and whether or not your swap file is even being utilized.

Another, easier way to see if you have a swapfile is to do free -m if you have a swap file enabled it will tell be listed there.

See swappiness for another tip on using swap files with a laptop.

Filesystem

Filesystem types have an impact on CPU utilization and so on battery life (http://forums.gentoo.org/viewtopic-t-347574-start-0-postdays-0-postorder-asc-highlight-love.html suggests you use JFS or Ext3).

CPU frequency scaling

In addition to the kernel settings mention in the official guide, you might need to enable "Relaxed speedstep Capability Checks" if your processor isn't detected as a speedstepping-capable CPU.

Warning: Make sure your CPU actually supports speedstep. If it isn't this could be harmful!
Linux Kernel Configuration: Relaxed speedstep Capability Checks
Power management options (ACPI, APM)  --->
   [*] Power Management support
        CPU Frequency scaling  --->
           [*] Relaxed speedstep Capability Checks

Suspend to Disk (Hibernate)

Suspend to disk is the Linux equivalent of Windows' hibernate functionality. It saves the contents of memory to disk and powers down. When the computer is started up again, it reloads the contents and the user can continue from where they left off. No documents need to be reloaded or applications reopened and the process is much faster than a normal shutdown and start up.

At this time, July 2007, Software Suspend v2 is not yet included in the mainstream or Gentoo Kernel (vanilla-sources or gentoo-sources). It is however included in suspend2-sources which is the same as gentoo-sources with the swsusp2 patch applied on top.

HOWTO Software Suspend v2 contains an extended guide to this feature. The following includes the minimum you need to get things working :

Kernel Settings

Linux Kernel Configuration: Software suspend 2
Power management options (ACPI, APM)  --->
   [*] Power Management support
   [ ] Software Suspend
   <*> Suspend 2  --->
      <*> Swap Allocator
      <*> File Allocator
      <*> Userspace User Interface support
      <*> Compression support
      [*] Replace swsusp by default

Application

Suspend to RAM and Standby

The laptop can be placed into a minimal power consumption mode. Kernel Settings

Linux Kernel Configuration: Sleep states
 Power management options  --->
   ACPI (Advanced Configuration and Power Interface) Support  --->
     [*] ACPI Support
     [*] Sleep States

Usage

To see what capabilities your system has:

cat /sys/power/state

Example output:

 standby mem disk

Enable Standby with:

 echo -n "standby" > /sys/power/state

or Suspend to RAM with:

 echo -n "mem" > /sys/power/state

Suspend to RAM might need the kernel parameter acpi_sleep=s3_bios if the monitor doesn't wake up on resume.

Application

Other power saving methods

Finding power draining devices

The following script will allow you to get an accurate handle on how much power your machine is drawing. Start by fully charging the battery and unplug it with all external devices enabled. Run the test again after each of these steps:

It is best to run this in terminal mode without a graphical environment running. If using graphical environment, make sure not to touch the mouse or keyboard during the test to prevent skewing the results.

Code: power_test.sh
 #! /bin/bash
 # /usr/bin/batterydraw
 # Copyright 2007        Morgan McClure <mtm28@case.edu>
 # License GPLv2
 # 1-25-2007
 # Power draw isolation script
 
 REGEXP='[0-9]+'
 case $# in
 0 )
   echo "usage: batterydraw SAMPLES [SLEEPTIME] [PRETESTCYCLES]"
   exit
 ;;
 1 ) SLEEPTIME=1
 ;;
 2 ) SLEEPTIME=$2
 ;;
 3 )
 # This is a trick to avoid the first few cycles so as to level
 # the draw on the battery and get a more accurate reading
   SLEEPTIME=$2
   N=0
   while [ $N != $3 ]
     do
       cat /proc/acpi/battery/BAT0/state|grep "present rate"|grep -Eo $REGEXP
       ((N++))
       sleep $SLEEPTIME
     done
 ;;
 esac
 
 N=0
 S=0
 X=0
 while [ $N != $1 ]
   do
     ((X= "$(cat /proc/acpi/battery/BAT0/state|grep "present rate"|grep -Eo $REGEXP)"))
     ((S += X))
     ((N++))
     echo $X $N
     sleep $SLEEPTIME
   done
 ((S=S/N))
 echo -e "\E[0;34mAverage draw:\E[0m"
 echo -e "\E[0;32m$S\E[0m"


Note: The /proc/acpi/battery directory is deprecated in newer kernels, but still available if configured. To use the new sysfs, remove the REGEXP variable and change the 'cat | grep | grep' commands to
cat /sys/class/power_supply/BAT0/current_now
. This gives the current in microamperes and not in milliamperes as the script above. To make it easier to read, you can also replace ((S=S/N)) with ((S=S/1000/N)).
Retrieved from "http://www.gentoo-wiki.info/Power_Management"

Last modified: Tue, 16 Sep 2008 19:54:00 +0000 Hits: 23,786