Home Downloads How to fine-tune power management in Ubuntu using TLP

How to fine-tune power management in Ubuntu using TLP

Fine-tuning power management in Ubuntu is made easy with TLP. This guide provides step-by-step instructions on installing and configuring TLP, a powerful tool designed to optimize battery usage and improve energy efficiency. Learn how to customize TLP settings to suit your specific power management needs in Ubuntu.

by John Horan
optimize ubuntu battery life using tlp

In our ever-evolving digital world, managing the power efficiency of our devices is not just a necessity; it’s an art. Especially for Ubuntu users who are often on the go, mastering this art can mean the difference between hours of uninterrupted productivity and the relentless search for the nearest power outlet.

Enter TLP – an incredibly versatile tool designed to optimize power management in Ubuntu. It’s our secret weapon for extending battery life while maintaining performance. Whether you’re a seasoned Linux enthusiast or a newcomer, understanding and utilizing TLP can transform your Ubuntu experience, making your machine not just efficient, but eco-friendly.

Understanding TLP

Before we start tweaking, let’s talk about TLP. TLP is an advanced power management tool for Linux. It’s like a smart assistant that optimizes your laptop’s battery life without you needing to understand the intricacies of power management. The beauty of TLP is its simplicity and efficiency.

Installation of TLP

There are two main ways to install TLP on Ubuntu: using the official repositories or through a Personal Package Archive (PPA). Both methods have their pros and cons:

Official repositories (recommended):

  • Pros: Easier to install, no need for additional PPAs, integrated with your system updates.
  • Cons: May not have the latest version of TLP, may not offer the TLP graphical user interface (TLPUI).

PPA:

  • Pros: Provides the latest version of TLP and TLPUI, offers more configuration options.
  • Cons: Requires adding a PPA which can introduce instability, separate updates from your system.

Here’s how to install TLP using both methods:

Recommended method – Official repositories:

  1. Open a terminal window (Ctrl+Alt+T).
  2. Update your package list: sudo apt update
  3. Install TLP: sudo apt install tlp

PPA:

First things first, we need to install TLP. Open your terminal (Ctrl+Alt+T) and type the following commands:

sudo add-apt-repository ppa:linrunner/tlp
sudo apt-get update
sudo apt-get install tlp tlp-rdw

Install TLPUI (optional): 

sudo apt install tlp-ui

Once installed, TLP will start automatically. However, to see the magic, let’s restart it:

sudo tlp start

When you run the sudo tlp start command in your terminal, the output typically won’t be very detailed, as TLP silently starts and begins managing your system’s power in the background. However, you can expect to see something like this:

TLP started in AC mode.

Or, if your laptop is running on battery, it might say:

TLP started in battery mode.

This output indicates that TLP has successfully started and is now actively managing your system’s power settings based on whether your laptop is plugged in (AC mode) or running on battery.

Getting detailed info on TLP stats

To get more detailed information about what TLP is doing or to check the current settings, you can use the sudo tlp-stat command. This command provides a comprehensive report of your system’s power-related settings and statuses, including information on the CPU, battery, disk drives, and more. For example:

sudo tlp-stat -s

This would output a summary of the current power settings and statuses, including any TLP configurations that are actively being applied. Here’s an example of what the output might look like:

--- TLP 1.4.0 --------------------------------------------

+++ System Info
System = Dell Inc. XPS 13 9370
BIOS = 1.9.0
Release = Ubuntu 20.04 LTS
Kernel = 5.8.0-53-generic #60-Ubuntu SMP Thu May 6 07:47:36 UTC 2021 x86_64
/proc/cmdline = BOOT_IMAGE=/boot/vmlinuz-5.8.0-53-generic root=UUID=1234abcd-12ab-34cd-56ef-1234567890ab ro quiet splash vt.handoff=7
Init system = systemd v245 (245.4-4ubuntu3.11)
Boot mode = UEFI

+++ TLP Status
State = enabled
Last run = 09:23:46 AM, 800 sec(s) ago
Mode = AC
Power source = AC

+++ Processor
CPU model = Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz

/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver = intel_pstate
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor = powersave
/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors = performance powersave
/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq = 400000 kHz
/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq = 4000000 kHz
/sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference = balance_power
/sys/devices/system/cpu/cpu0/cpufreq/energy_performance_available_preferences = default performance balance_performance balance_power power

[... similar data for other CPUs ...]

+++ Temperatures
/sys/class/thermal/thermal_zone0/temp = 45 [°C]
/sys/class/thermal/thermal_zone1/temp = 43 [°C]

+++ Battery Features: Charge Thresholds and Recalibrate
natacpi = inactive (no kernel support)
tpacpi-bat = inactive (no kernel support)
tp-smapi = inactive (no kernel support)

+++ Battery Status
/sys/class/power_supply/BAT0/manufacturer = LGC-LGC3.67
/sys/class/power_supply/BAT0/model_name = DELL 5XJ288C
/sys/class/power_supply/BAT0/cycle_count = 150
/sys/class/power_supply/BAT0/energy_full_design = 60000 [mWh]
/sys/class/power_supply/BAT0/energy_full = 55000 [mWh]
/sys/class/power_supply/BAT0/energy_now = 30000 [mWh]
/sys/class/power_supply/BAT0/power_now = 15000 [mW]
/sys/class/power_supply/BAT0/status = Discharging

+++ Recommendations
* Install ethtool to disable Wake On LAN (WOL)
* Install smartmontools for disk drive health info

This output provides detailed information about the system, TLP status, CPU configurations, temperature readings, and battery status. It’s a comprehensive look at how TLP is interacting with your hardware and managing its power usage. Note that the actual output can vary depending on your system’s hardware and the specific version of TLP you’re using.

Optimizing your Ubuntu laptop’s battery with TLP

Basic configuration of TLP

TLP works out of the box with default settings, which are quite efficient. However, if you’re like me and love to have control, tweaking is where the fun begins.

Editing the TLP configuration file

The configuration file for TLP is located at /etc/tlp.conf. To edit it, use your favorite text editor. I prefer nano:

sudo nano /etc/tlp.conf

CPU frequency scaling

The CPU frequency scaling governor is a feature in the Linux kernel that dynamically adjusts the speed (frequency) of the CPU. The goal is to optimize performance and power usage. When you set the CPU_SCALING_GOVERNOR_ON_BAT parameter in TLP, you’re instructing your system how to manage the CPU speed when running on battery power.

The powersave governor

Setting CPU_SCALING_GOVERNOR_ON_BAT to powersave means that when your laptop is on battery, the CPU will prioritize energy efficiency over performance. This is how it works:

  • Reduced Clock Speed: The CPU runs at a lower frequency than its maximum capability. This reduction in speed means the CPU consumes less power, which can significantly extend your laptop’s battery life.
  • Responsiveness vs. Battery Life: While the powersave governor is great for saving battery, it can lead to reduced performance. This might be noticeable in CPU-intensive tasks like video editing or gaming. For general usage like browsing or document editing, the impact is usually minimal.
Example

Imagine you have a laptop with a CPU capable of running at a maximum of 3.0 GHz. Under normal conditions (plugged into power), the CPU might adjust between lower and higher speeds based on the current demand (using performance or ondemand governors). However, when on battery and using the powersave governor, the CPU might limit itself to a lower frequency range, say between 800 MHz and 2.0 GHz, to conserve power.

How to set it up

In TLP, you can configure this setting by editing the TLP configuration file, typically located at /etc/tlp.conf. By adding or modifying the line:

CPU_SCALING_GOVERNOR_ON_BAT=powersave

You’re telling TLP to enforce the powersave governor whenever your laptop is running on battery.

After setting the governor

After you have made the changes and saved the file, restart TLP to apply them:

sudo tlp start

This action ensures that your new settings are in effect. The powersave governor is a great way to extend battery life when you’re on the go and don’t need the full power of your CPU. However, if you find the performance reduction too significant for your needs, you might experiment with other governors like ondemand or conservative, which offer a more balanced approach between performance and power saving.

Advanced TLP tweaks

1. Setting up USB autosuspend

This feature suspends USB devices when they are not in use, saving precious power. Add the following line to your tlp.conf:

USB_AUTOSUSPEND=1

2. Enabling PCIe ASPM

This setting enables Active State Power Management for PCIe devices. This can be a bit tricky, but it worked well for me:

PCIE_ASPM_ON_BAT=powersave

3. Disk idle time management

Managing the idle time of your disk drives can significantly impact power consumption, especially for traditional spinning hard drives.

Configuring SATA link power management

This setting controls the power management policy for SATA host bus adapters. Lower power states can save power but might increase latency when the disk is accessed again.

Here’s how you can set it up in the TLP configuration file (/etc/tlp.conf):

# Set the SATA link power management policy for battery mode.
SATA_LINKPWR_ON_BAT=min_power

The min_power setting maximizes power saving. There’s also a medium_power option, which is a compromise between power saving and disk performance.

Setting disk idle time

You can also set the disk to enter a low power state after a certain period of inactivity. For example:

# Set disk idle time (in seconds) for battery mode.
DISK_IDLE_SECS_ON_BAT=60

This setting configures the disk to enter a low power state after 60 seconds of inactivity. Adjust the time based on your usage pattern for an optimal balance between power saving and responsiveness.

4. Wi-Fi power saving mode

Wi-Fi can be a significant consumer of power, especially when constantly searching for networks or maintaining a connection.

Enabling Wi-Fi power saving

TLP allows you to enable Wi-Fi power-saving mode, which can reduce the power used by your wireless card:

# Enable WiFi power saving mode on battery.
WIFI_PWR_ON_BAT=on

When set to on, this setting instructs the Wi-Fi card to use power saving features, reducing its power draw when on battery. Keep in mind that in some cases, this might impact the performance of your Wi-Fi connection, like slower data speeds or a slightly reduced range.

Applying and testing the changes

After making these changes in the TLP configuration file, remember to restart TLP:

sudo tlp start

You can then check the status of these settings using:

sudo tlp-stat -s

This command will give you an overview of the current power management settings, including the ones you’ve just adjusted. Advanced tweaks like these can significantly extend your battery life, especially during extended periods of mobile use. However, always keep an eye on how these changes impact the performance and adjust them accordingly to find the right balance for your needs.

Personal experience and tips

Through trial and error, I found that the biggest impact on battery life came from tweaking the CPU settings and managing the brightness of my screen. Don’t be afraid to experiment with different settings; just remember to monitor your system’s temperature and performance.

Remember the trade-offs

Power management is all about finding the right balance. More power saving usually means less performance, so find what works best for you.

FAQ: Mastering power management in Ubuntu with TLP

What is TLP?

TLP is an advanced power management tool specifically designed for Linux systems, particularly effective in Ubuntu. It optimizes battery use and overall system power consumption without the need for complex configurations.

Will TLP work automatically after installation?

Yes, TLP starts with default settings that work well for most users. However, for specific needs, you may want to tweak these settings for optimal performance.

How do I customize TLP settings?

Edit the TLP configuration file at /etc/tlp.conf using a text editor like nano or vim. Here, you can customize various settings such as CPU scaling, disk idle time, and Wi-Fi power saving.

Does TLP improve battery life significantly?

Yes, TLP can significantly improve battery life, especially when using features like the powersave CPU governor, SATA link power management, and others. The improvement varies based on your usage and settings.

Can TLP adjustments affect system performance?

Some settings, particularly those that reduce CPU frequency or disk activity, may impact performance. It’s about finding the right balance between power saving and performance for your needs.

Is TLP suitable for desktops, or is it just for laptops?

While TLP is particularly beneficial for laptops due to its battery-saving features, desktop users can also benefit from its system power management optimizations.

How can I check the current TLP configurations?

Run sudo tlp-stat -s in your terminal to view a summary of the current TLP configurations and system power status.

Do I need to restart TLP every time I change the settings?

Yes, after making changes to the TLP configuration file, restart TLP with sudo tlp start to apply the new settings.

Is TLP available for other Linux distributions?

Yes, TLP is available for various Linux distributions.

Fedora

Fedora users can use the DNF package manager:

sudo dnf install tlp tlp-rdw
sudo systemctl enable tlp

After installation, you may need to start TLP with:

sudo tlp start

Arch Linux and Manjaro

TLP is available in the official Arch repositories. You can install it using pacman:

sudo pacman -S tlp

For the Radio Device Wizard (rdw) feature, which is useful for laptops:

sudo pacman -S tlp-rdw

Enable and start TLP with:

sudo systemctl enable --now tlp

openSUSE

For openSUSE, use Zypper to install TLP:

sudo zypper install tlp

For the Radio Device Wizard:

sudo zypper install tlp-rdw

Enable TLP with:

sudo systemctl enable tlp

CentOS

For CentOS, the process is similar to Fedora, but you might need to enable the EPEL repository first:

sudo yum install epel-release
sudo yum install tlp tlp-rdw
sudo systemctl enable tlp

After installation, start TLP with:

sudo tlp start

By incorporating TLP into your daily Ubuntu use and understanding its capabilities, you can take a significant step toward efficient power management and a longer battery lifespan.

Conclusion

After ing deep into the realms of TLP and exploring its numerous features, from CPU frequency scaling with powersave to advanced tweaks like disk idle time management and Wi-Fi power saving mode, it’s clear that TLP is an indispensable tool for any Ubuntu user. The journey of fine-tuning TLP to suit inidual needs can be as rewarding as it is enlightening. Through careful adjustment and personalization of settings, we can achieve that elusive balance between conserving battery life and retaining optimal system performance.

You may also like

Leave a Comment

fl_logo_v3_footer

ENHANCE YOUR LINUX EXPERIENCE.



FOSS Linux is a leading resource for Linux enthusiasts and professionals alike. With a focus on providing the best Linux tutorials, open-source apps, news, and reviews written by team of expert authors. FOSS Linux is the go-to source for all things Linux.

Whether you’re a beginner or an experienced user, FOSS Linux has something for everyone.

Follow Us

Subscribe

©2016-2023 FOSS LINUX

A PART OF VIBRANT LEAF MEDIA COMPANY.

ALL RIGHTS RESERVED.

“Linux” is the registered trademark by Linus Torvalds in the U.S. and other countries.