Introduction

There are many ways to reduce power consumption and extend battery life in Ubuntu. By default, most of these are not enabled because they are unreliable. With a little experimentation, you can get your power consumption down to a minimum.

Measure power consumption with PowerTOP

Before you start making any changes, it is a good idea to first get a base line for what your current power consumption is:

sudo aptitude install powertop
sudo powertop

You must be running on battery power for powertop to get the machine's current watt usage.

PowerTOP Tunables

One may tab over to the Tunables section to adjust the power management setting for each item in the list.

Measure temperature via lm-sensors

One helpful tool is to monitor the internal hardware temperatures via lm-sensors. For more on this, please see here. Please be mindful that taking temperature readings too often could also cause your temperature to increase. Hence, it's best to use the longest time interval for your intended use.

Using less power with pm-powersave

The pm-utils package comes with scripts for managing low-power modes.

sudo aptitude install pm-utils

In order to enter low power mode, run this:

sudo pm-powersave true

In order to leave low power mode, run this:

sudo pm-powersave false

These commands will run the hooks in /etc/pm/power.d and /usr/lib/pm-utils/power.d, passing the argument true when entering power save and false when leaving.

When you run pm-powersave it combines the scripts in these two directories and executes them in sorted order. If both directories contain a script with the same name, the one in /etc/pm/power.d/ has a higher precedence and only this one will be executed.

Therefore to disable a script from /usr/lib/pm-utils/power.d/ simply create an empty file in /etc/pm/power.d/ with the same name and without the execute bit set.

An example power.d hook

#
# A script to agressively toggle power management between high performance and very low power usage.
# For more information on each of these options, see http://www.lesswatts.org
#
# To install:
#
# sudo install 99-savings /etc/pm/sleep.d
# sudo install 99-savings /etc/pm/power.d
#

##
## POWER SAVE OFF
##

ac_power()
{
  ##
  ## DISK and FILESYSTEMS
  ##

  # Set the drive to mostly stay awake.  Some may want to change -B 200
  # to -B 255 to avoid accumulating Load_Cycle_Counts
  # -S 240 => put in standby after 20 minutes idle
  # -B 200 => do not permit spindown
  # -M => not supported by my drive
  hdparm -B 200 -S 240 /dev/sda

  # Remount ext3/4 filesystems so the journal commit only happens every 60
  # seconds.  By default this is 5 but, I prefer to reduce the disk
  # activity a bit.
  mount -o remount,commit=60,atime /

  # Turn off the laptop mode disk optimization
  echo 0 > /proc/sys/vm/laptop_mode

  # Set the SATA to max performance
  echo max_performance > /sys/class/scsi_host/host0/link_power_management_policy
  echo max_performance > /sys/class/scsi_host/host1/link_power_management_policy

  ##
  ## NETWORK
  ##

  # set the wifi to no power savings.
  iwconfig wlan0 power off

  ##
  ## CPU AND MEMORY
  ##

  # Set kernel dirty page value back to default
  echo 10 > /proc/sys/vm/dirty_ratio
  echo 5 > /proc/sys/vm/dirty_background_ratio

  # Only wakeup every 60 seconds to see if we need to write dirty pages
  # By default this is every 5 seconds but, I prefer 60 to reduce disk
  # activity.
  echo 6000 > /proc/sys/vm/dirty_writeback_centisecs

  # Make sure ondemand governor is set
  echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

  ##
  ## SOUND AND VIDEO
  ##

  # Turn off sound card power savings
  echo 0 > /sys/module/snd_hda_intel/parameters/power_save

  # Enable the webcam driver
  modprobe uvcvideo
}

##
## POWER SAVE ON
##

battery_power()
{
  ##
  ## DISK and FILESYSTEMS
  ##

  # Set the disks to aggressively save power.
  # Some might find these settings too aggressive.  If so, change
  # "-S 4" to something larger like -S 24 (two minutes) and -B 1 to -B 255.
  # -S 4 => put in standby after 20 seconds idle
  # -B 1 => highest degree of power savings
  # -M => not supported by my drive
  hdparm -B 1 -S 4 /dev/sda

  # Change ext3/ext4 filesystem settings to reduce disk activity.
  # noatime => disable updates to a file's access time when the file is read.
  # commit=600 => Change the commit times to 10 minutes.
  mount -o remount,noatime,commit=600 /

  # Set laptop disk write mode
  echo 5 > /proc/sys/vm/laptop_mode

  # Set SATA to minimum power
  echo min_power > /sys/class/scsi_host/host0/link_power_management_policy
  echo min_power > /sys/class/scsi_host/host1/link_power_management_policy

  ##
  ## NETWORK
  ##

  # set the wifi to power savings.
  iwconfig wlan0 power on

  ##
  ## CPU AND MEMORY
  ##

  # Make sure ondemand governor is set
  echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

  # Reduce disk activity by waiting up to 10 minutes before doing writes
  echo 90 > /proc/sys/vm/dirty_ratio
  echo 1 > /proc/sys/vm/dirty_background_ratio
  echo 60000 > /proc/sys/vm/dirty_writeback_centisecs

  ##
  ## SOUND AND VIDEO
  ##

  # Set sound card power savings
  echo 10 > /sys/module/snd_hda_intel/parameters/power_save

  # Remove the webcam driver
  modprobe -r uvcvideo
}

##
## APPLY SETTINGS
##

case "$1" in
  false) ac_power ;;
  true) battery_power ;;
esac

Debugging pm-powersave

sudo tail -f /var/log/pm-powersave.log &
sudo pm-powersave true

Using less power with laptop-mode-tools

It is confusing: laptop_mode is a state that the kernel may be in, but laptop-mode-tools is a collection of scripts which attempt to reduce power consumption and allows you to tweak a number of power-related settings using a simple configuration file.

aptitude install laptop-mode-tools

If laptop-mode-tools is present, pm-utils will not manage disk settings but will assume that laptop-mode-tools is going to handle it (/usr/lib/pm-utils/power.d/95hdparm-apm).

However, pm-utils will not automatically start and stop laptop-mode-tools. To do so, we need to create a hook for pm-utils:

sudo touch /etc/pm/sleep.d/10-laptop-mode-tools
sudo chmod a+x /etc/pm/sleep.d/10-laptop-mode-tools
sudo gedit /etc/pm/sleep.d/10-laptop-mode-tools

case $1 in
    hibernate)
        /etc/init.d/laptop-mode stop
        ;;
    suspend)
        /etc/init.d/laptop-mode stop
        ;;
    thaw)
        /etc/init.d/laptop-mode start
        ;;
    resume)
        /etc/init.d/laptop-mode start
        ;;
    *)
        echo Something is not right.
        ;;
esac

lm-profiler

Recent versions (1.11 and later) of laptop-mode-tools include a new tool lm-profiler. It will monitor your system's disk usage and running network services and suggests to disable unneeded ones.

CPU governor

One may governor their CPU via the cpufreq-selector command, provided by the package gnome-applets. For example, if one had a dual core CPU, one could execute at a terminal:

sudo cpufreq-selector --cpu=0 --governor=powersave && sudo cpufreq-selector --cpu=1 --governor=powersave 

This will change your CPU setting from ondemand, to powersave. Then, you could verify the CPU governor status by executing at a terminal:

cpufreq-info 

This is provided by the package cpufrequtils.

If one wanted to have a lower CPU frequency persist through reboots, and choose which speed the CPU frequency runs on, one may edit the file /etc/init.d/cpufrequtils.

Dual and multi graphics card setups running hotter than Windows

Disable unused graphics cards

If one is not utilizing the discrete graphics card much, one would want to disable the card in the BIOS if an available option.

AMD FGLRX proprietary driver

Certain AMD graphics cards may have better heat profiles using the proprietary AMD driver fglrx, versus the default open source ones. The Ubuntu repositories offer various versions of the proprietary drivers noted here.

Radeon open source driver

For the radeon driver, one may perform:

echo low | sudo tee /sys/class/drm/card0/device/power_profile
exit

One may verify the new profile via:

cat /sys/class/drm/card0/device/power_profile
low

nouveau open source driver

For those with nvidia Optimus enabled graphics cards utilizing the nouveau driver, one may want to test Bumblebee to see if this would provide a desired improvement in the heat profile.

Increase fan speed

Dell Inspiron laptops

For Dell Inspiron laptops, one may use i8kmon to increase the fan speed. This utility is provided by the package i8kutils. For instructions on using this, please see the man page.

Power Saving Tweaks

For more power saving tweaks, please see https://wiki.ubuntu.com/Kernel/PowerManagement/PowerSavingTweaks.

General maintenance

Use a can of air to regularly blow out the dust that may accumulate in the computer exhaust area, which can cause incorrect heat flow, and air blockages. As well, do not obstruct the exhaust areas.

Related Links

PowerManagement/ReducedPower (last edited 2014-03-20 01:31:40 by penalvch)