How To Improve Laptop Battery Performance In Linux
I use Arch Linux in my Laptop. One big problem I noticed while using Arch Linux is the poor battery performance. As you know already, Arch Linux is rolling-release and DIY distro and doesn’t ship with any power saving utilities by default. I thought that there is something drains my battery and leads to poor battery backup. How absurd! Well, if you’re having the same issue, don’t panic. 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. These utilities are not just designed for Arch Linux, but for all Linux distros. If you’re facing any serious troubles with battery, you need to make sure you have setup power management right in your Laptop.
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, It is available in AUR. So, you can install it using any AUR helpers like Yay.
$ yay -S laptop-mode-tools
On Debian, Ubuntu, run:
$ sudo apt-get 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:
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:
Change it’s value from 0 to 1.
And also make sure the value of ENABLE_LAPTOP_MODE_ON_BATTERY option is set to 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:
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.
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.
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
Once installed, run it 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.
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:
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
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.
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.
- CPU Power Manager – Control And Manage CPU Frequency In Linux
- UnixBench – A Benchmark Suite For Unix-like Systems
- NetData : A Real-time performance monitoring tool for Linux
- How To Display CPU Usage From Commandline
And, that’s all for now. I will be soon here with another useful. If you find this guide useful, please share it on your social networks and support OSTechNix. More good stuffs to come. Stay tuned!
Thanks for stopping by!
Help us to help you:
- Subscribe to our Email Newsletter : Sign Up Now
- Support OSTechNix : Donate Via PayPal
- Download free E-Books and Videos : OSTechNix on TradePub
- Connect with us: Facebook | Twitter | Google Plus | LinkedIn | RSS feeds
Have a Good day!!