Laptops

How to Install and Configure TLP to Improve Battery Backup in Linux Laptops

This article will cover a guide on installing and using the TLP battery optimization tool in Linux. TLP is a free and open source utility that can apply various tweaks to improve battery life on various battery powered Linux devices like laptops and tablets. It comes with a predefined and well commented config file that you can customize to configure power optimization settings according to your needs. It also comes with some sensible defaults that are used to automatically optimize power consumption on your Linux system.

Main Features of TLP

TLP can automatically apply different power profiles depending on whether your device is connected or disconnected to AC power. It can also apply power profiles on fresh system reboots. TLP comes with support for monitoring Bluetooth, Wifi, LAN and other such network connections so that it can automatically toggle them based on user settings and selected power profile. Other main features of TLP includes ability to upscale or downscale CPU frequency, automatic application of vendor specific tweaks for different CPU and GPU hardware, supports hard disk power management including an option to spin them down, AHCI power management tweaks, supports managing power for PCIe devices, can monitor AMD GPUs to reduce power consumption, ability to power off audio devices and optical drives, and so on. Full detailed list of its features is available here.

Installing TLP in Linux

To install TLP in Ubuntu, use the following command:

$ sudo apt install tlp

You can install TLP in other Linux distributions from the package manager. More installation instructions and download options are available here.

Checking Status of TLP

After you have installed TLP, reboot your system for the changes to take effect. TLP does not have a background process so you may not find a process for it in task managers. To optimize power consumption, it makes use of events produced by systemd services and other system daemons that run on a fresh boot. TLP automatically applies some sane tweaks after its installation. You can check if TLP is running on your system or not by using the command mentioned below:

$ tlp-stat -s

You should get some output similar to this:

+++ TLP Status
State          = enabled
RDW state      = enabled
Last run       = 03:55:11 PM
Mode           = AC
Power source   = unknown

As you can see in the output, TLP is enabled and it also shows the time of last run.

Setting up the Configuration File

TLP makes optimizations to your PC depending on various parameters defined in its config file. By default, TLP creates a file at “/etc/tlp.conf” path on the first run. This file comes with definitions for all TLP parameters but they are commented out by default, you have to manually change the config file parameters to change behavior of TLP.

There are two ways you can configure the TLP config file. In the first method, you can copy and make a backup of the original config file located at “/etc/tlp.conf” path and then edit the existing config file. In the second method, you can create a new config file from scratch without touching the original config file. To create a new config file for TLP, run the following two commands:

$ mkdir -p /etc/tlp.d
$ cp /etc/tlp.conf /etc/tlp.d/01-myconfig.conf

These commands will create a new directory called “tlp.d” and copy the original TLP config file inside it. TLP will now read this config file called “01-myconfig.conf” in addition to the default file and then apply changes according to user customizations made in the custom config file. This way the original config file is kept pristine and users can keep track of changes made by them in the custom config file. The name of the custom config file should start with two digits indicating load order in case there are multiple custom config files. So you can create “01-myconfig.conf” and “02-myconfig.conf” custom config files and they both will be read by TLP in ascending order taking into consideration the first two digits of the filename.

Configuring TLP Settings

Now that you have a custom config file, open it in a text editor. It should look similar to this:

Each configurable parameter is well explained in the TLP file and is denoted by upper case letters. To understand what each parameter does, you will have to read the explanations provided in the config file itself as they are very thorough. In case you need additional information about each parameter, you can check their explanations in official documentation available here.

All parameters listed in the config file are disabled by default. To enable a particular parameter, all you have to do is uncomment it by removing “#” symbol in front of it. Similarly, you can disable an already enabled parameter by putting “#” symbol in front of it.

Note that if any parameter is disabled, TLP will use a default value for it according to the parameter’s fallback default value mentioned by the “Default: X” syntax. For instance, the first setting in the config file looks like this:

# Set to 0 to disable, 1 to enable TLP.
# Default: 1

#TLP_ENABLE=1

Notice the “Default: 1” string. It indicates that if the parameter is disabled, a value of “1” will be used for it. In other words, if you don’t manually enable or disable TLP, it will be enabled by default. These fallback default values in “Default: X” format are defined for all parameters available in the config file.

Another important point you should keep in mind is that any parameters ending with “_AC” suffix are only used when your device is connected to an AC power source through a charger. On the other hand, parameters ending with “_BAT” are only used when your system is running on battery power.

To load settings from your custom config file and apply changes, you will need to reload TLP by running the following command:

$ sudo tlp start

Alternatively, you can reboot your Linux system for the changes to take effect.

Conclusion

TLP provides extensive configuration parameters to optimize battery life of your Linux devices in a variety of ways. This is the only utility of its kind that provides so many configuration parameters to improve battery backup. You can make changes to the config file according to your needs and it will take care of the rest and automatically optimize battery life on every reboot.

About the author

Nitesh Kumar

I am a freelancer software developer and content writer who loves Linux, open source software and the free software community.