Howto: Extend the Life of Your Thinkpad's Battery (tp_smapi) on Ubuntu Feisty and Gutsy

You may or may not be aware that lithium ion batteries (like those present in the newer Thinkpad models) survive best when kept charged between 30%-85%. They should not be kept fully charged, and should be left off for long periods of time charged to ~%40. See here for more tips on Thinkpad battery treatment.

One way to extend the life of your Thinkpad's battery is to control the way it charges -- that is, to make sure that you keep it in the 30%-85% charged range whenever possible. This is possible easily and quickly through the tp_smapi kernel module.

(1) Download the tp_smapi code here. For the examples presented here, let's assume that you download the tarball to your home directory (~/):

Code:

wget http://easynews.dl.sourceforge.net/sourceforge/tpctl/tp_smapi-0.32.tgz ~/tp_smapi-0.32.tgz
(2) Make sure that you have the necessary pre-requisites installed. You must have the necessary compiler and build tools (build-essentials), and the kernel source code for your kernel (linux-source-`uname -r`). For the example below, it is assumed that you are using the newest kernel in the repository:

Code:

sudo aptitude install build-essential linux-source-2.6.22
(2b) If you haven't gotten and extracted the kernel source code before, goto /usr/src, and extract the kernel source you got from the above step (which should be in a file called linux-source-2.6.22.tar.bz2):

Code:

sudo -s
cd /usr/src
tar -xjf linux-source-2.6.22.tar.bz2

This should extract the source to linux-source-2.6.22. Be patient... decompressing bzip2 files takes forever! (If you'd care to speed it up, however, there is a program in the Ubuntu repositories called pbzip2 which can decompress it with multiple threads, taking advantage of both CPU cores.)

(2c) Now go into /lib/modules/`uname -r`. Both the "build" and "source" symbollic links should point to your source folder. You can check this by observing the output of ln -l, or just create it this way with the following:

Code:

sudo -s
rm -i /lib/modules/`uname -r`/source /lib/modules/`uname -r`/build
ln -s /usr/src/linux-source-2.6.22 /lib/modules/`uname -r`/source
ln -s /usr/src/linux-source-2.6.22 /lib/modules/`uname -r`/build

(3) Extract the tp_smapi code:

Code:

tar -xzf ~/tp_smapi-0.32.tgz
(4) Change to the new directory, make and install tp_smapi:

Code:

cd tp_smapi-0.32 && make && sudo make install
Should you want to use HDAPS (the IBM Active Protection System Linux Drive) in the future, include the HDAPS module in your build:

Code:

cd tp_smapi-0.32 && make && sudo make install HDAPS=1
(5) Make sure that the tp_smapi module is loaded upon startup:

Code:

sudo -s;
echo "tp_smapi" >> /etc/modules

(6) Now reboot, or load the tp_smapi module:

Code:

sudo modprobe tp_smapi
(7) To set the charge thresholds, edit the following files:

Quote:

/sys/devices/platform/smapi/BAT0/start_charge_thre sh
/sys/devices/platform/smapi/BAT0/stop_charge_thres h
For example, to keep the charge constantly varying between 30 and 85% while plugged into AC, use the following commands:

Code:

sudo -s;
echo "30" > /sys/devices/platform/smapi/BAT0/start_charge_thresh;
echo "85" > /sys/devices/platform/smapi/BAT0/stop_charge_thresh;

This may interfere with your ACPI battery charge reports, since it will technically report "charged" at 30% battery (even though it will continue to cycle between 30 and 85 while plugged in). Thus, for those who use a system monitor (such as Conky or GKrellM), the following may be a more practical solution:

Code:

sudo -s;
echo "81" > /sys/devices/platform/smapi/BAT0/start_charge_thresh;
echo "85" > /sys/devices/platform/smapi/BAT0/stop_charge_thresh;

This will keep the charge below 85% when charged.

Hope this helps! Most of this information has come from here. Please let me know if you have any problems.

Clicky Web Analytics