Biboroku

Power Management on Lenovo T430s with Debian Wheezy

Written by Taro Sato on . Tagged: Linux sysadmin ThinkPad

Since tp_smapi does not work properly on T430s, I am using TLP this time. I still want some traditional tools

$ sudo aptitude install powertop

but not others:

$ sudo aptitude remove --purge laptop-mode-tools

To install, follow the instruction. In short, first update the APT source list by adding the following line to /etc/apt/sources.list:

deb http://ppa.launchpad.net/linrunner/tlp/ubuntu lucid main

and run

$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 02D65EFF
$ sudo aptitude update
$ sudo aptitude install tlp tlp-rdw tp-smapi-dkms smartmontools ethtool acpi-call-tools</pre>

Upon reboot, TLP starts running.

I am impressed by the ease of installation and how effective TLP is on configuring T430s to star saving from the get go. According to powertop, T430s is already using just 7 - 8 W on battery. That’s several watts below I had been using on other ThankPads!!

Controlling the behavior of TPL is done by modifying /etc/default/tlp. I mostly use the default except the following changes:

...

# Main battery (values in %)
START_CHARGE_THRESH_BAT0=75
STOP_CHARGE_THRESH_BAT0=90
# Ultrabay battery (values in %)
START_CHARGE_THRESH_BAT1=75
STOP_CHARGE_THRESH_BAT1=90

...

# Radio devices to disable on connect
DEVICES_TO_DISABLE_ON_LAN_CONNECT=&quot;wifi wwan&quot;
DEVICES_TO_DISABLE_ON_WIFI_CONNECT=&quot;wwan&quot;
DEVICES_TO_DISABLE_ON_WWAN_CONNECT=&quot;wifi&quot;

# Radio devices to enable on disconnect
DEVICES_TO_ENABLE_ON_LAN_DISCONNECT=&quot;wifi&quot;
DEVICES_TO_ENABLE_ON_WIFI_DISCONNECT=&quot;&quot;
DEVICES_TO_ENABLE_ON_WWAN_DISCONNECT=&quot;&quot;

Note that in this configuration the battery charge thresholds are intentionally set lower than the factory default to prolong the health of batteries. When I wish to fully charge them, do:

$ sudo tlp fullcharge [ BAT0 | BAT1 ]

and the thresholds will be set back to the factory default. The setting reverts to the custom configuration upon next reboot.

Enables RC6 Power Saving

Edit /etc/default/grub and add the option i915.i915_enable_rc6=1 to GRUB:

GRUB_CMDLINE_LINUX_DEFAULT=&quot;quiet i915.i915_enable_rc6=1&quot;

After editing, update Grub:

$ sudo update-grub

This can save about 0.5 W of power!

Fan Control

I have not fine tuned this, but the fan can be controlled manually via thinkfan:

$ sudo aptitude install thinkfan

Create (or edit) /etc/modprobe.d/thinkpad_acpi.conf and add the line:

options thinkpad_acpi fan_control=1

Reboot. The fan can be controlled manually following this Wiki article.

Configuring System on Switch between AC & Battery

For regular daemons (like ssh), TLP provides a way to start/stop based on AC status.

For other 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:

#!/usr/bin/env 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

statuspath=&quot;/sys/class/power_supply/AC/online&quot;

if [ ! -f &quot;$statuspath&quot; ]; then
    exit 0
fi

tag=pmpersonal
status=`cat &quot;$statuspath&quot;`

if [ &quot;$status&quot; = &quot;1&quot; ]; then
    logger -t $tag &quot;on ac&quot;

    logger -t $tag &quot;start xflux&quot;
    for i in `pgrep ^xflux$` ; do kill -9 $i ; done
    xflux -l $LATITUDE -g $LONGITUDE

    logger -t $tag &quot;start dropbox&quot;
    dropbox start

    logger -t $tag &quot;enable system notification&quot;
    kwriteconfig --file=&quot;/home/$USERNAME/.kde/share/config/knotifyrc&quot; --group=Sounds --key=&quot;No sound&quot; false
else
    logger -t $tag &quot;on battery&quot;

    logger -t $tag &quot;stop xflux&quot;
    for i in `pgrep ^xflux$` ; do kill -9 $i ; done

    logger -t $tag &quot;stop dropbox&quot;
    dropbox stop

    logger -t $tag &quot;disable system notification&quot;
    kwriteconfig --file=&quot;/home/$USERNAME/.kde/share/config/knotifyrc&quot; --group=Sounds --key=&quot;No sound&quot; 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.

Preload Daemon

$ sudo aptitude install preload

In /etc/default/preload, uncomment the line reading

OPTIONS=&quot;-l /dev/null&quot;

This should reduce disk activity.

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.

comments powered by Disqus