Thursday, April 18, 2013

Improve Power Usage / Battery Life In Linux With TLP

http://www.webupd8.org/2013/04/improve-power-usage-battery-life-in.html


There are various tweaks that you can apply to your laptop to save battery power, but many of them depend on the hardware, Linux distribution, some are outdated or too hard to apply for regular users and so on. TLP is an advanced power management command line tool for Linux that tries to apply these settings / tweaks for you automatically, depending on your Linux distribution and hardware.

Ubuntu laptop


TLP applies the following settings depending on the power source (battery / ac):
  • Kernel laptop mode and dirty buffer timeouts;
  • Processor frequency scaling including "turbo boost" / "turbo core";
  • Power aware process scheduler for multi-core/hyper-threading;
  • Hard disk advanced power management level and spin down timeout (per disk);
  • SATA aggressive link power management (ALPM);
  • PCI Express active state power management (PCIe ASPM) – Linux 2.6.35 and above;
  • Runtime power management for PCI(e) bus devices – Linux 2.6.35 and above;
  • Radeon KMS power management – Linux 2.6.35 and above, not fglrx;
  • Wifi power saving mode – depending on kernel/driver;
  • Power off optical drive in drive bay (on battery).

Additional TLP functions:
  • I/O scheduler (per disk);
  • USB autosuspend with blacklist;
  • Audio power saving mode – hda_intel, ac97;
  • Enable or disable integrated wifi, bluetooth or wwan devices upon system startup and shutdown;
  • Restore radio device state on system startup (from previous shutdown);
  • Radio device wizard: switch radios upon network connect/disconnect and dock/undock;
  • Disable Wake On LAN;
  • WWAN state is restored after suspend/hibernate;
  • Undervolting of Intel processors – requires kernel with PHC-Patch;
  • Battery charge thresholds – ThinkPads only;
  • Recalibrate battery – ThinkPads only.

TLP applies these settings automatically on startup and every time you change the power source. To use it, all you have to do is install TLP, however, there are some settings that you can apply manually, overwriting the TLP default settings, such as enabling or disabling the WiFi, Bluetooth or Wwan (3G or UMTS) radios, switching between AC or battery settings, ignoring the actual power source, apply autosuspend for all attached USB devices or power off the optical drive.

There are also some TinkPad-only settings that you can use, like temporarily changing the battery charge thresholds, temporarily set battery charge thresholds to factory settings, recalibrating the battery and more.

For more about these settings, see the TLP homepage or consult the TLP manpage (type "man tlp" in a terminal).

I've only been using TLP for a couple of hours so I can't say yet how efficient this tool is regarding battery life, but I've noticed that my laptop's temperature is lower than before using TLP. You may have seen an icon on my Unity launcher in some posts on WebUpd8, which displays a number that's usually around 65 - that's Psensor and it displays the CPU temperature (Celsius; it's 165 degrees Fahrenheit) - here's an example. Well, after installing TLP, the CPU temperature didn't go past 55 degrees Celsius (135 degrees Fahrenheit), at least not yet, with regular desktop usage: using a browser with quite a few tabs open, a text editor and a few AppIndicators running, under Unity. This, of course, depends on various factors but so far this tool seems to do its job. Also, some Reddit users have reported that TLP makes quite a big difference.



Install TLP in Ubuntu


Before proceeding with the installation, there are a couple of things you need to do:
  • firstly, if you've added any power saving settings / scripts (e.g.: in /etc/rc.local), remove them or else TLP may not work properly;
  • remove laptop-mode-tools ("sudo apt-get remove laptop-mode-tools").

Ubuntu (and Linux Mint, etc.) users can install TLP by using its official PPA. Add the PPA and install TLP using the following commands:
sudo add-apt-repository ppa:linrunner/tlp
sudo apt-get update
sudo apt-get install tlp tlp-rdw

TLP will automatically start  upon system startup, but to avoid having to restart the system to get it running for the first time, you can start it (required only the first time) using the following command:
sudo tlp start

There are some optional packages you can install for some extra features:
  • smartmontools - needed to display disk drive S.M.A.R.T. data;
  • ethtool - needed to disable wake on lan.

Install these tools (available in the Ubuntu repositories) using the following command:
sudo apt-get install smartmontools ethtool

There are also some ThinkPad only, optional packages you may need:
  • tp-smapi-dkms - needed for battery charge thresholds and ThinkPad specific status output of tlp-stat;
  • acpi-call-tools - acpi-call is needed for battery charge thresholds on Sandy Bridge and newer models (X220/T420, X230/T430, etc.).

Install these packages using the following command:
sudo apt-get install tp-smapi-dkms acpi-call-tools

Other Linux distributions: there are TLP packages for Debian 6.0+, Arch Linux, openSUSE 11.4+, Gentoo, Fedora 16+ - see the TLP homepage for installation instructions. You can grab the source / report bugs @ GitHub

Make sure to also read the TLP FAQ.

No comments:

Post a Comment