How to extend your laptop battery lifespan on Linux Ubuntu/Debian

As computers become more powerful and more efficient, they rapidly drain their batteries because they consume more electricity. While this might depend on the number of running applications, laptop moans are mainly caused by battery life especially when they are not plugged in throughout the day.

It is still possible however to get some improvements by some software tweaks and good practice. Notwithstanding the use of a lightweight desktop environment, laptop users running on Ubuntu have the possibility to extend the life of their batteries by using a power management utility called TLP.

In this article, we will provide a description of TLP and explain how to enable it on your Ubuntu laptop . We also provide some useful tips to help optimize power consumption. Finally we shall delve into Intel’s PowerTop utility which is a system diagnosis tool.

What is TLP ?

TLP is a free, feature-rich open source utility for battery use improvement on laptops running Linux distros such as Ubuntu.

Without having to delve deeper into technical details, the TLP tool can exploit Linux advanced power management to bring users its many benefits. Indeed, when your laptop is unplugged, i.e. running on its battery, the TLP operates by optimizing the hardware devices power usage. Here are some features of TLP :

  • Many customization options and several power saving parameters
  • Provides USB autosuspend with blacklist
  • Uses dirty buffer timeouts and kernel laptop mode
  • Power management for PCI Express active state (PCIe ASPM)
  • Multi-core/hyper-threading process scheduler power awareness
  • Supports processor “turbo boost” and “turbo core”
  • PCI(e) bus devices runtime power management
  • Wifi and audio power saving mode support
  • Hard disk advanced power handling and spin down (non SSD) timeout (per disk)
  • Radeon graphics power management support (KMS and DPM)
  • SATA aggressive link power management (ALPM) support
  • Includes an I/O scheduler (per disk)

The default settings that come with TLP are already optimized and perfectly tuned for better battery management so that you do not have to tweak anything. The configuration file can be found at /etc/default/tlp. This is said, TLP offers users different customization options in order to fulfill their specific needs. TLP is available in GUI and CLI (Command Line Interface or terminal) so that beginner and advanced users alike can use it as they see fit. All that is needed is to get TLP installed and that’s it !

Installation of TLP

Open up your terminal or command line either by pressing on Ctrl+Alt+T or through the Application Launcher.

You would first need to have an up-to-date repository index by running the command below :

sudo apt-get update

The package lists will be downloaded from the remote repositories and will be updated with information on the latest versions of packages along with their dependencies. Make sure to use sudo or a user with the required privileges.

In order to install TLP , invoke the command below:

sudo apt-get install tlp

You will be prompted with a Y/N question to continue the installation. Go ahead and enter Y in order to proceed with the installation. Depending on your Internet connection speed, this might take several seconds. Once completed, TLP will be added to the list of installed applications.

Read: How to save power on Linux Ubuntu/Debian using cpufreq

TLP will be running as a service after system start. You could check if it is up and running by using the command below :

sudo systemctl status tlp

Using TLP with the command line

Starting TLP

Now that TLP is ready to be used, let’s start it in the terminal by running the following command :

sudo tlp start

TLP status

In order to see the status of the TLP utility as well as detailed system information execute the command below:

sudo tlp-stat -s

TLP default configuration

As mentioned above, TLP operates initially using a default configuration that is perfectly tuned to fit the needs of your operating system and hardware. You can display the default configuration of TLP using the following command:

sudo tlp-stat -c

Battery report display

TLP allows you to view a detailed report about your current laptop battery. This can is achieved by using the -b switch as shown below :

sudo tlp-stat -b

Temperature display

To display the temperature of the CPU, issue the command below :

sudo tlp-stat -t

Uninstalling TLP

In order to remove TLP from your system, you could use the command below for instance :

sudo apt-get remove tlp

Using TLP with the GUI

Installation of the required PPA

Besides CLI, TLP utility offers a graphical interface that can be installed from Linux Uprising PPA. This is because TLP is not available at the Official Ubuntu repositories as highlighted in the snapshot below.

You would first need to add the PPA which will be used to install the TLP graphical user interface application. Open your terminal ad issue the command below :

sudo add-apt-repository ppa:linuxuprising/apps

Allow few seconds for this to run.

Installation of TLP UI

As was done before in the case of CLI, you would need to run the command below beforehand in order to to have an up-to-date repository index:

sudo apt-get update

Now to install the TLP UI, run the command :

sudo apt-get install tlpui

You will be prompted with a Y/N question to continue the installation. Go ahead and enter Y in order to proceed with the installation. Depending on your Internet connection speed, this might take several seconds. Once completed, TLP UI will be added to the list of installed applications.

Using TLP UI

TPL UI is now ready to be used. You can launch it by searching for ‘tlp’ in the Application Launcher as follows:

This can also be done by running the command below in the Terminal :

tlpui

This will launch the TLP UI application as shown in the snapshot below :

You could edit the TLP settings on the configuration tab above.

The statistics tab will enable you to view your battery and system statistics.

Using the checkbox TLP_ENABLE below :

You will have the possibility to enable or disable battery optimization feature through TLP, based on your settings.

Uninstalling TLP UI

To remove the TLP UI utility from your system , run the command below :

sudo apt-get remove tlpui

To also remove the added PPA, use the command below :

sudo rm /etc/apt/sources.list.d/linuxuprising-ubuntu-apps-bionic.list

Final word on TLP

You have seen two methods which allow you to install and use TLP. TLP utility will allow you to efficiently use your laptop battery on your Ubuntu system. You will hopefully start to notice some improvements on the way your battery is used after you run the TLP service. To know more about TLP, you can visit its website here.

Useful tips to improve your battery life

In this section, you will find some short tips on how to ameliorate your average laptop battery lifespan and how to optimize its usage.

Unplug or turn off peripheral devices

Since your laptop motherboard has to power all your USB connected devices such as webcams, USB keys, mouse , you would just need to eject them to save some juice unless this is absolutely necessary.

The webcam can be turned off using a function button. Your speakers should also be muted if you do not need sound, since every time your laptop beeps this can be a drain.

Laptop backlight

A Laptop screen can drain more power than some other devices of the laptop. This power-hungry screen can consume large amounts of your battery power in order for you to enjoy clear and bright looking display.

There is a nonlinear dependency between power consumed and brightness level. This means that increasing the brightness level in the lowest settings consumes less power than when stepping this up in the highest settings.

You can simply turn the brightness down and avoid the full level in order to save some power. Measurements on a typical laptop show that dropping to 2/3 brightness will save you about 1 Watt.

Reduce Wakeup Events

Wakeup events triggered by some applications can arouse an idle processor which leads to power consumption. There some applications which cause such wakeups, for instance flash in web pages, in which case you can choose to not install flash or simply close your browser tab when you don’t need it anymore. There are some tools that can help identify similar situations, like Intel’s PowerTop which is featured further down in this article.

Use a lightweight desktop environment

Ubuntu offers a lightweight desktop environment called Lubuntu that does not require extensive computer power (graphics). To install Lubuntu, execute the command below :

sudo apt-get install lubuntu-desktop

Once finished, you could load Lubuntu desktop environment directly from the login screen.

Some common applications have lightweight alternatives. For example, you might want to use Gdebi (package installer) or AppGrid rather thenUbuntu Software Center or AbiWord instead of LibreOffice Writer .

Wi-Fi disabling

The laptop built-in wireless networking capabilities are amongst the parts that sap the battery life the most. The battery is constantly being drained by Wi-Fi since power is continuously drawn by the wireless device, even when it is not connected since it is looking for available wireless networks nearby.

When there are no wireless networks available, you can simply turn off this device. On Ubuntu you can do this manually by switching to airplane mode as follows :

  • Open up the Activities application and type in Wi-Fi
  • Click on Wi-Fi tab to open the corresponding panel
  • Switch on Airplane Mode. You wireless connection will be turned off until airplane mode is enabled again.

It is also possible turn off your Wi-Fi connection directly from the system menu:

  • Simply click on the connection name and choose Turn Off

If you are at ease with the command line, you could issue the commands below to disable your WiFi :

  • nmcli radio wifi off

To re-enable it, use the command :

  • nmcli radio wifi on

For more on this, refer to the documentation as per the commands below :

  • nmcli radio help
  • nmcli radio wifi help

Fix high memory usage

You might be using few applications on the frontend, but on the background, unknown to you, there could be many services running in the backend. These background processes are actually draining away your battery for instance, workspace, Compiz or dock .

The best remedy here is to stop unnecessary services from running at boot. We have written a detailed article on how to achieve this along with other methods which might help lower memory usage and thereby save some power.

Using PowerTop

In this section we will be looking at another Linux tool called PowerTOP that monitors your battery performance by setting appropriate system configuration to help manage power on your Linux laptop machine.

What is PowerTop ?

PowerTop is a diagnosis application created by Intel that helps users monitor power usage by active programs on a Linux laptop when it is unplugged. This terminal based utility offers an interactive mode allowing users to tweak several power management settings.

How to install PowerTop ?

In order to install PowerTop on Ubuntu and similar distributions, run the command below:

sudo apt-get install powertop

Using PowerTop ?

In order to use this tool, the user would need to have root privileges or sudo rights since the information required by PowerTop, is retrieved from the system hardware directly.

To run PowerTop, issue the command below :

sudo powertop

This will show the following interactive mode display :

Unplug your laptop so that the battery power usage can be monitored by PowerTop. In the snapshot above, one can see some statistics related to the overall power usage by the system and also by its power-hungry individual components that are using most of the system power or that are sending wake-up calls to the processor most frequently.
These are listed in the following categories: processes, devices, kernel works (kWork) , system timer and interrupts.

In order to navigate between the different tabs at the top, use Shift + Tab keys as mentioned on the bottom of the screen.

Idle stats tab

This shows information about the processor C-states which are used to reduce or optimize power consumption in idle mode .

Frequency stats tab

This tab shows the frequency of wake-up calls to the CPU.

Device stats tab

This tab displays similar data to the main but is only related to devices.

Tunables tab

In tab you will find some useful power consumption optimization suggestions.

Minimizing system wake-ups would lead to maximizing battery power consumption. In the snapshot above :

“Bad” indicates that a given setting is not saving power, but it might be good system- performance wise.

“Good” shows that specific setting is saving power. Press [Enter] key to switch it to the other setting.

Report Generation – csv format

PowerTop allows you to generate a CSV report for several seconds. in the command below, we will generate a report for 5 seconds

sudo powertop –csv=output_report.txt –time=5s

In order to view the generated report, issue the command below in you preferred editor :

The output shows the following entries ;

Which indicates the top 10 power consumers.

Here we can see an overview of software power consumers, or the processes that consume the most power.

Device power report is provided above.

Process device activity is displayed.

Above we see the software settings which need tuning.

Here we can see some suggestions for optimal tuning.

Report Generation – html format

In addition to the csv format, PowerTop allows also to generate a report html. This is achieved by using the command below :

powertop –html=output_in_html

This will generate a report that runs for a duration of 20 seconds.

The generated report can be displayed in a browser :

Final word on PowerTop

Now that you know PowerTop, you can install it and try to observe if there are improvements on the performance of your battery. If you want to use it for tuning other devices, you can visit this link for more details.

Conclusion

You have seen some tools as well as some tips that might help extend the life of your laptop battery. TLP utility will enable you to use your laptop battery on your Ubuntu system in an efficient way. PowerTop, a diagnosis tool, can help identify applications that are consuming high amounts of power and will allow you to tweak various power management settings. Good practice tips might also come in handy, like for instance dimming your laptop screen or unplugging connected USB devices .

ziad nahdy

Ziad Nahdy, fan of open source, worked at SAP for 17 years. He is a technical writer, blogger and Linux enthusiast. He loves to read and help others with their problems. He is addicted to open source software but he also loves other technology related stuff.

This Post Has One Comment

  1. The first line in your article reads, “As computers become more powerful and more efficient, they rapidly drain their batteries because they consume more electricity.” More efficient means consuming less electricity. The rest of the article is fine.

    The best way to extend your battery lifespan is taking it out of the laptop when it is plugged in for long periods of time. Use the battery only when traveling, otherwise store it at 50% charge.

Leave a Reply

Close Menu