Home Command line utilities How To Improve Laptop Battery Performance In Linux

How To Improve Laptop Battery Performance In Linux

By sk
Published: Updated: 5.5K views

In this tutorial, I will show you how to setup two most used power management tools called Laptop Mode Tools and Powertop to improve Laptop battery performance in Linux.

Improve Laptop Battery Performance In Linux

First, we will see how to improve battery performance using Laptop Mode Tools,

1. Laptop Mode Tools

Laptop Mode Tools, or LMT in short,  is a power saving tool for Unix-like operating systems. It extends the battery life of your Laptop in several ways. It enables the Laptop Mode feature of the Linux kernel, which lets your hard drive spin down. And also, Laptop Mode Tools allows us to tweak a number of other power-related settings for different hardware devices using a simple configuration file. It is a cross-platform power saving utility, thus It will work on almost all modern Unix-like operating systems, such as Arch Linux, Red Hat, Fedora, CentOS, Debian, Ubuntu etc.

Install Laptop Mode Tools

Make sure you have removed any previously installed power saving utilities like TLP or anything else. Laptop Mode Tools is available in the default repositories of some Linux distributions. So, you can install it using the default package manager.

For Arch Linux and its derivatives, Laptop Mode Tools is available in AUR. So, you can install it using any AUR helpers like Paru or Yay.

$ paru -S laptop-mode-tools

Or,

$ yay -S laptop-mode-tools

On Debian, Ubuntu, run:

$ sudo apt install laptop-mode-tools

Just in case your distribution doesn't have laptop-mode-tools in the repositories, you can download the source and compile and install it manually as described below.

To do so, git clone the laptop-mode-tools repository using command:

$ git clone https://github.com/rickysarraf/laptop-mode-tools.git

The above command will clone the laptop-mode-tools repository in a directory called "laptop-mode-tools" in the current working directory.

Go to the laptop-mode-tools directory:

$ cd laptop-mode-tools

Then, run the following command to install it.

$ sudo ./install.sh

Configure Laptop Mode Tools

There are two configuration files. The main configuration file located is /etc/laptop-mode/laptop-mode.conf, and /etc/laptop-mode/conf.d/* directory contains dozens of feature-specific modules.

First, we need to enable laptop mode in our Laptop.

To do so, create/edit ‘/etc/default/acpi-support’ file:

$ sudo vi /etc/default/acpi-support

Add the following line:

LAPTOP_MODE_ENABLED=true

Save and close the file.

Next, edit main configuration file /etc/laptop-mode/laptop-mode.conf:

$ sudo vi /etc/laptop-mode/laptop-mode.conf

Find the following line:

ENABLE_LAPTOP_MODE_ON_AC=0

Change it's value from 0 to 1.

ENABLE_LAPTOP_MODE_ON_AC=1

And also make sure the value of ENABLE_LAPTOP_MODE_ON_BATTERY option is set to 1.

ENABLE_LAPTOP_MODE_ON_BATTERY=1

Save and close the file.

Enable and start LMT service:

$ sudo systemctl enable laptop-mode
$ sudo systemctl start laptop-mode

That's it. Now, run the following command to verify if laptop-mode-tools is enabled or not.

$ cat /proc/sys/vm/laptop_mode

Sample output would be:

2

If you got the output as 2, LMT is enabled and working! If the output is 0(zero), LMT is not enabled. Reboot the system and check again. And make sure that you have removed all other power management tools from the system.

Also, you can individually enable or disable other hardware modules. These modules can found in /etc/laptop-mode/conf.d/ directory. To view the list of all modules, run:

$ ls /etc/laptop-mode/conf.d/

Sample output would be:

ac97-powersave.conf kbd-backlight.conf
auto-hibernate.conf lcd-brightness.conf
battery-level-polling.conf nmi-watchdog.conf
bluetooth.conf pcie-aspm.conf
configuration-file-control.conf radeon-dpm.conf
cpufreq.conf runtime-pm.conf
cpuhotplug.conf sched-mc-power-savings.conf
dpms-standby.conf sched-smt-power-savings.conf
eee-superhe.conf start-stop-programs.conf
ethernet.conf terminal-blanking.conf
exec-commands.conf vgaswitcheroo.conf
hal-polling.conf video-out.conf
intel-hda-powersave.conf wireless-ipw-power.conf
intel_pstate.conf wireless-iwl-power.conf
intel-sata-powermgmt.conf wireless-power.conf

Each module can be enabled, disabled, or set to auto by changing the CONTROL_ argument of the respective config file in conf.d/ directory. LMT will attempt enable any modules where CONTROL_ is set to auto if ENABLE_AUTO_MODULES is set in /etc/laptop-mode/laptop-mode.conf file.

To check the list of modules which are enabled, disabled or set as auto, use grep command as shown below.

$ grep -r '^\(CONTROL\|ENABLE\)_' /etc/laptop-mode/conf.d

If you find an important module is disabled, you can enable it by editing the respective module file.

2. Powertop

If you're not satisfied with the performance of Laptop Mode Tools, you can give Powertop a try. Powertop is a Linux power management tool designed by INTEL open source community. This tool can be used to investigate the power consumption issues of various hardware devices in your system.

Install Powertop

It is available in the default repositories of some Linux distributions.

In Arch Linux and its derivatives like Antergos, Manjaro Linux, Powertop can be installed using pacman as shown below.

$ sudo pacman -S powertop

On Debian, Ubuntu, Linux Mint:

$ sudo apt-get install powertop

On RPM based distributions like Fedora, run the following command to install it.

$ sudo dnf install powertop

After installing, enable and start powertop service using commands:

$ sudo systemctl enable powertop
$ sudo systemctl start powertop

Usage

Once installed, run Powertop as sudo user like below.

$ sudo powertop

When launching powertop without arguments, It starts in interactive mode.

The default interface of Powertop should look like below.

Powertop interface

Powertop interface

The utility has various sections. You can switch between them using the Tab and Shift+Tab keys. You can find all shortcut keys at the bottom of the Powertop interface. To quit this utility, just hit the Esc key.

As you see in Powertop interface, it lists the power usage of various hardware components. In addition, it also displays how many times the hardware components wakes up each second. So, if you want to improve the battery usage, you can reduce the wake up time of each devices.

To do this, go to Tunables section:

Powertop Tunables Section

Powertop Tunables Section

Here, Bad indicates that particular hardware is not saving power. And, “Good” indicates a power saving setting is in effect. To change between the values, just press ENTER key on any tunable.

Just pass "--auto-tune" argument with powertop command if you want to set all tunable options to their good setting without interaction.

$ sudo powertop --auto-tune

You can even generate a report in CSV or HTML format for data analysis.

To generate CSV report, run:

$ sudo powertop --csv=powertop.txt

Sample output:

Loaded 0 prior measurements
Preparing to take measurements
Taking 1 measurement(s) for a duration of 20 second(s) each.
PowerTOP outputing using base filename powertop.txt

You can view the csv report using any text editor.

To generate HTML report, run the following command instead.

$ sudo powertop --html=powertop.html

You can view the newly generated report in your web browser.

Powertop HTML report

Powertop HTML report

For more details, refer the man pages.

$ man powertop

A note of caution: Be mindful that just use only one power management tool. If you use multiple power saving tools at a time, you may not get the proper or no result at all.

Here are some additional tips to reduce Laptop overheating:

  • Make sure the room where you use your Laptop has proper air ventilation.
  • Do not use it in a room with no or less air circulation.
  • Buy and use any quality USB powered cooling pad.
  • Power off your Laptop if you don't use it. I have had a bad habit of leaving my Laptop powered on all day. Don't do that. If you don't use, just shut it down.
  • Get your Laptop cleaned from time to time, at least 3 months once.
  • More importantly, keep your Laptop out of sun, fire or any other hot places.

Suggested read:


Hope this helps.

Resources:

You May Also Like

1 comment

Ikem Krueger August 26, 2017 - 7:18 am

Additionaly you could spare a few mW by undervolting the cpu.

For AMD cpus you can use “amdmsrt” or “undervolt” to do that.

I used “amdmsrt” to undervolt the cpu and got a power reduction by 25%.

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More