NOTE: This is an older method. I have moved on to using TLP and the amount of powersaving is quite amazing (yes, 6 – 7 W is possible!!). I will eventually try to update this post, but for now the solution that I wrote for T430s should be followed.
Here is my continuously growing notes. I use Debian Wheezy (amd64) on T420.
First, install must-have packages:
$ sudo aptitude install powertop acpi acpid tp-smapi-dkms
To load tp-smapi module on boot, add the line
tp-smapi
to /etc/modules.
To monitor the power consumption, use powertop:
$ sudo powertop
This is one of the most useful tool for power management. I can see which processes wake up the computer most, and try to eliminate them one by one.
Laptop Mode Configurations
Install laptop-mode-tools:
$ sudo aptitude install laptop-mode-tools
In /etc/laptop-mode/laptop-mode.conf, make sure to have this line:
ENABLE_AUTO_MODULES=1
(which was set to 0 by default on Squeeze but does not appears to be the case for Wheezy). When on battery this will apply a bunch of power saving settings. This sole step should typically save about 2 – 2.5 W of power consumption according to powertop! Note that wattage information only shows up while running on battery.
The following additional tweaks (overriding the default settings) are optional.
To disable ethernet when on battery, make sure /etc/laptop-mode/conf.d/ethernet.conf has the following lines:
CONTROL_ETHERNET="auto"
DISABLE_ETHERNET_ON_BATTERY=1
For more aggressive power saving on Intel HDA, make sure /etc/laptop-mode/conf.d/intel-hda-powersave.conf has the following lines:
CONTROL_INTEL_HDA_POWER="auto"
INTEL_HDA_DEVICE_TIMEOUT=2
INTEL_HDA_DEVICE_CONTROLLER=1
For more aggressive power saving on the wireless adapter, make sure /etc/laptop-mode/conf.d/wireless-iwl-power.conf has the following lines:
CONTROL_IWL_POWER="auto"
IWL_BATT_POWER=3
After changing the configuration, restart laptop-mode:
$ sudo /etc/init.d/laptop-mode restart
to make the changes effective.
Disabling Nepomuk, Strigi and Akonadi on KDE
I am not fond of these daemon. Disable them by going to System Settings -> Desktop Search and unchecking “Enable Nepomuk Semantic Desktop.” In ~/.config/akonadi/akonadiserverrc, set:
StartServer=false
so that it doesn’t start at all. On powertop, this shows up as a service running mysqld constantly.
Starting & Stopping Services
Some daemons running in the background can be stopped while on battery by laptop-mode. If the init scripts are stored under /etc/init.d, the simplest method is to place a symlink to the init script under /etc/laptop-mode/*-stop directories.
For example, if I want to stop ssh from running while on battery, do this:
$ cd /etc/laptop-mode/batt-stop
$ sudo ln -s /etc/init.d/ssh .
Now, I want ssh to get restarted when on AC:
$ cd /etc/[lm|nolm]-ac-start
$ sudo ln -s /etc/init.d/ssh .
(depending on how laptop-mode is configured, I create a symlink either in lm-ac-start or nolm-ac-start.)
I should create similar symlinks for all services that should be stopped while on battery.
Configuring System on Switch between AC & Battery
For certain things that laptop-mode does not take care of, I create a script which gets run each time the AC is plugged or unplugged. Depending on the state (on battery or on AC), I change some settings.
Such a script may look like this:
#!/bin/bash
if [ ! -f /sys/devices/platform/smapi/ac_connected ]; then
exit 0
fi
TAG=pmtp
STATUS=`cat /sys/devices/platform/smapi/ac_connected`
if [ "$STATUS" = "1" ]; then
logger -t $TAG "on ac"
logger -t $TAG "increasing swappiness"
sysctl -w vm.swappiness=60
else
logger -t $TAG "on battery"
logger -t $TAG "reducing swappiness"
sysctl -w vm.swappiness=10
fi
Let us save this script as /usr/local/bin/pmtp. (FYI, this script changes the amount of swap disk usage, effectively reducing disk access while on battery. This is a recommended thing to do.)
To let laptop-mode handle this script, modify /etc/laptop-mode/conf.d/exec-commands.conf to have these lines:
BATT_EXEC_COMMAND_0="/usr/local/bin/pmtp"
LM_AC_EXEC_COMMAND_0="/usr/local/bin/pmtp"
NOLM_AC_EXEC_COMMAND_0="/usr/local/bin/pmtp"
This way the script gets run each time the AC/battery state changes.
For personal processes, KDE power management can also do some work by running a script upon dis/connecting with AC. In particular, the sound for the KDE system notifications should be disabled entirely, because they cause quite a number of unwanted interruptions according to powertop. Also, I wish to start/stop programs like flux and Dropbox when on battery just to squeeze more juice. I create a script like this:
#!/bin/bash
##############################################################################
# This is a script to run when AC/battery switches. Ideally used
# within the power management configuration setting on KDE. Requires
# tp_smapi to be loaded for the detection of AC/battery.
USERNAME=johndoe
LATITUDE=37.78
LONGITUDE=-122.42
##############################################################################
# DO NOT MODIFY BELOW
if [ ! -f /sys/devices/platform/smapi/ac_connected ]; then
exit 0
fi
TAG=pmpersonal
STATUS=`cat /sys/devices/platform/smapi/ac_connected`
if [ "$STATUS" = "1" ]; then
logger -t $TAG "on ac"
logger -t $TAG "start xflux"
for i in `pgrep ^xflux$` ; do kill -9 $i ; done
xflux -l $LATITUDE -g $LONGITUDE
logger -t $TAG "start dropbox"
dropbox stop
dropbox start
logger -t $TAG "enable system notification"
kwriteconfig --file="/home/$USERNAME/.kde/share/config/knotifyrc" --group=Sounds --key="No sound" false
else
logger -t $TAG "on battery"
logger -t $TAG "stop xflux"
for i in `pgrep ^xflux$` ; do kill -9 $i ; done
logger -t $TAG "stop dropbox"
dropbox stop
logger -t $TAG "disable system notification"
kwriteconfig --file="/home/$USERNAME/.kde/share/config/knotifyrc" --group=Sounds --key="No sound" true
fi
Save this to ~/bin/pmpersonal.sh. Go to System Settings -> Power Management -> Energy Saving Settings. There, for each of “On AC,” “On Battery,” and “On Low Battery,” I can set different configurations. I can also specify “Run Script” option for each profile to enable/disable a few desktop related applications and settings. The script should be run on profile load.
Disabling Bluetooth
To control the on/off status of wireless device on the command line, I need:
$ sudo aptitude install rfkill
... below is an example usage ...
$ rfkill list
I can live without Bluetooth entirely (in fact, my T420 does not have Bluetooth). To disable Bluetooth at boot time, add the following line:
rfkill block bluetooth
to /etc/rc.local before the “exit 0″ statement.
Preload Daemon
$ sudo aptitude install preload
In /etc/default/preload, uncomment the line reading
OPTIONS="-l /dev/null"
This should reduce disk activity.
Changing Swappiness
On the command line,
$ sudo sysctl -w vm.swappiness=10
The system will try to use physical RAM as much as possible instead of swapping. To make this in effect upon boot, add the line
vm.swappiness=10
to /etc/sysctl.conf. However, I opt to change this particular setting dynamically using a custom script described above.
Battery Charge Thresholds
To extend battery life, charge thresholds should be tweaked. My current settings are:
$ echo 90 | sudo tee /sys/devices/platform/smapi/BAT0/start_charge_thresh
$ echo 95 | sudo tee /sys/devices/platform/smapi/BAT0/stop_charge_thresh
Do this for each battery in my system (BAT0, BAT1, etc.)
Chromium over Firefox
My default browser is Firefox. When browsing the web, however, Chromium is much easier on power. I can save about 1 W using Chromium.
Powertop Status
Currently, I typically use 11 – 13 W during typical usage.
Reference