Use TLP to Optimize the Power Consumption In Ubuntu
I don’t know how it is with other GNU/Linux distributions, but recent versions of Ubuntu (such as 12.04 LTS) comes with a set of tools/scripts called ‘pm-utils’ that fine tune the power usage of your mobile computer. It is pre-optimized by default, thus under most circumstances, one doesn’t need to tweak anything manually.
However, if you do need to do that, then it is a little difficult because, as mentioned, ‘pm-utils’ is a set of scripts, and changing settings for various individual hardware means that you have to manually edit each script.
In that case, there is this a lesser known utility called ‘TLP’ that you should try. It too relies (mainly) on the above mentioned ‘pm-utils’ for controlling various hardware and optimizes them for either performance or maximum power efficiency. Once installed it too automatically applies the settings. So if you are a non-geek, then you can just install it, forget about it and it will do its job in the background :).
TLP adds tweaks for your CPU, HDD, Sound card, Wireless hardware, Bluetooth adapter, Ethernet card, file system, USB devices and even comes with few advanced options such as setting up battery calibration or top charge levels etc for Lenovo Thinkpads, which is something I have not seen in other tools.
And because it has a single configuration file, I find the single main configuration file in ‘TLP’ to be very simple looking and easy to tweak, even if you are new to Linux/Ubuntu.
As you can see from the above two screenshots, I tested it with a freshly installed Ubuntu 12.04 installation (without any tweaks), and after installing ‘TLP’, I saw a power reduction of 0.9 – 1.2 Watts (sometimes 1.5 Watts difference after enabling the HDD spin-down). That however, was mainly because Ubuntu 12.04 comes with a settings called ‘ALPM’ disabled, and ‘TLP’ enables it.
However, then I manually disabled some of ‘ALPM’ features, and still, there was like a 0.3-0.5 Watts reduction when compared with the default power consumption of Ubuntu. It might not sound like much, but in the long run, or if you’re crazy about tweaking power consumption to its maximum, then ‘TLP’ indeed is a handy utility.
Not only that, but by using ‘TLP’, we can easily enable/disable certain network hardware as well. For example, I don’t know why, but for some reason, after disabling Bluetooth, Ubuntu enables it on the next boot on my Vostro V131 notebook. So sometimes I have to manually disable it.
But ‘TLP’ lets you add devices that should be powered down upon the desktop loading, and once ‘Bluetooth’ is added to its configuration file, it gets the job done. And unlike with the above tools, ‘TLP’ also lets you enable/disable ‘Wake on LAN’ feature, plus, if you have more than one of the same hardware (say you have two SATA drives), then you can add settings to each device individually.
When considering the overall controllability and the user-friendliness (somewhat, as it is still a command-line based tool), ‘TLP’ looks and works really good.
If interested, you can install it in Ubuntu 11.04 Natty Narwhal, 11.10 Oneiric Ocelot, 12.04 Precise Pangolin and 12.10 Quantal Quetzal by using the below commands, thanks to its PPA.
sudo apt-add-repository ppa:linrunner/tlp
sudo apt-get update
sudo apt-get install tlp
Then reboot your computer and upon the reboot, ‘TLP’ will start automatically and start functioning from the background.
Some tips …
How to edit the TLP configuration file …
As said, because it looks simple and well documented, editing its main configuration file is very easy. But before you begin, enter the below command to backup the default config first.
sudo cp /etc/default/tlp ~
If you ever wanted to restore the original file, please use the below command.
sudo cp ~/tlp /etc/default/tlp
Now, enter the below command to edit it.
gksudo gedit /etc/default/tlp
By default, TLP disables the ‘spin-down’ feature of your HDD that comes enabled by default in Ubuntu (when enabled, and not used for a certain time-frame, this features spins-down your HDD to save power, plus, it also helps to reduce the noise and the heat as well).
But by using the configuration file, we can enable it easily.
So, assuming that you have opened the configuration file as shown above, scroll down until you find the below code (you can search for it to find more easily using ctrl+f).
First, remove the ‘#’ to enable it. Then, replace the ’0 0′ values with the spin-down time accordingly (in seconds). You may notice that there is a space between the two zeros, and that is because each zero represents an individual HDD. Meaning that, if you have two HDDs, then you can add different spin-down values. So, if you have one HDD and you want it to spin down after 50 seconds of inactivity, the output would beÂ #DISK_SPINDOWN_TIMEOUT_ON_BAT=”10 0″Â (see below for details on how this figure is worked out).
The ‘spin-down’ value calculation is a bit tricky, as once you’ve figured out the spin-down seconds, you have to divide that by ’5′ and enter that value instead.
For example, if you want the primary HDD to be spinned-down within ’50′ seconds, then the value that you should enter is ’10′ (taken from 50/5). If you want the OS to wait 2 minutes (120 seconds) before spinning-down the HDD, then the value is ’14′ (taken from 120/5). I hope this clarifies it for you.
Anyway, if you have more than one HDD, then make sure to put a space between each value. If you have a single HDD, then you can just enter the value by replacing the first zero and leave the other one alone. When done, save your changes and reboot your PC.
As you can see below, after enabling it, now and then Ubuntu spins-down the disks, and it saves about 0.3-04 Watts (might change according to your hardware) more as well.
How to disable the ‘ALPM” ?
‘ALPM’ is an advanced power saving technique that is only available for SATA disk drives. However, there is a reason why Ubuntu comes with it disabled and that is because due to various reasons, once enabled, it can lead to data corruptions under some SATA disk drives.Â So please only leave this enabled if you are certain that your drive is not affected by this bug.
So, as ‘TLP’ enables it by default, if you encounter any issues, such as data corruptions, then you can disable it, again by editing the ‘TLP’ configuration, search for the below term …
Then simply replace the ‘min_power’ text with the below one.
Now save your changes, close the configuration file, reboot your machine and now ‘ALPM” should be disabled.
How to enable ‘WOL’?
As said before, ‘TLP’ automatically disables ‘WOL’ (wake on lan) features in order to save a tiny bit of power. But if you use ‘WOL’, then this can be frustrating. So again open the ‘TLP’ configuration file and search for the following term …
Simply replace ‘Y’ with ‘N’, save your changes and reboot your device. ‘WOL’ will now be enabled again.
There are few other advanced tweaks that you can do to tweak the system further, but for the sake of simplicity I’ll stop here. If you want to know how to setup ‘TLP’ in other GNU/Linux distributions plus read its well documented help page that explains a lot of additional tweaks, then please visit the ‘TLP’ home page.
A big thanks goes to ‘Thomas Koch’ (the developer) for creating it!
About the Author:
Gayan is a technology enthusiast who has a particular interest in open-source software. He has been using GNU/Linux distributions for the past 9 years and has a blog called ‘HecticGeek.com‘, in which, he shares application reviews and other technology related articles that he has a particular interest in.