Improve the battery life of your notebook running Linux OS

Improve the battery life of your notebook running Linux OS

Running Linux on your notebook and wondering about poor battery life? In this article I'll give you some hints how to increase the lifetime of your battery. No magic here, but still may be useful for users who are working with Linux on a notebook for the first time.
Note: I wrote this article for a ThinkPad, but you can also use it for any other notebook running Linux!


After working with MacBook Pro for the last few years, one day I decided to say goodbye and switch to a notebook with a Linux OS. The choice wasn't difficult: Lenovo's ThinkPads have already made a name for themselves in the developers world, and I already had several of them in my hands when I prepared them for our office staff. So after a comparison I decided to take a ThinkPad X1 Carbon: lightweight, all the ports I need, native network adapter and awesome keyboard. Also ThinkPads are known for good batteries. What about operating system - I am well familiar with Debian-based distributions, so I decided to go with Linux Mint and Cinnamon as a desktop environment.

In the first day after preparing some stuff I need for my work, I closed the top of my laptop and got to sleep. The battery was about 90% at this state. But as I opened the notebook the next morning, I was more than surprised: the battery was at 16%. Well, the first thought was: What the f*ck? More as that, at a normal work day the battery last just about 3-4 hours without any CPU intensive activity.

I have some experience by managing Linux servers, but haven't worked on a Linux notebook before. So, after a short research I tried some things out and was stunned by how the battery life was increased.

So, what have I done?

Sleep mode

First of all, I changed the sleep state in the BIOS settings from Windows to Linux (this option is only available on Lenovo notebooks). My laptop was shipped by Lenovo with Windows 10, so the preset was also set to Windows. I did all the necessary security settings in BIOS at the first startup, but missed the point about the sleep state.
Depending on your manufacturer you might not find this setting in your BIOS. In this case you can also take a look into some BIOS settings for Hybrid Sleep mode. In most cases you can select between five states:

  • S0: Working mode. Your notebook will still be on and working.
  • S1: Sleep mode. CPU is stopped, RAM maintains power. The system functions in reduced power.
  • S2: Sleep mode. CPU has no power, RAM maintains power. The system is in lower S1 power mode.
  • S3: Standby mode. CPU has no power, RAM refreshes slowly. Power supply is in reduced mode. This mode is also knows as "Save to RAM" - the current state is saved in RAM.
  • S4: Hibernate mode. The power of most hardware is shut off. The current state was saved from memory into temporary file on the hard drive.
  • S5: Off mode. Everything is shutdown, nothing is saved. Basically powered off.

You can also read the full description of sleep modes here: System Sleep States — The Linux Kernel documentation

In most cases you will be fine with the S3 mode, since it uses less power and wake up faster. That's all for BIOS.

Power management with TLP

Now lets take a look into the actual setting, that got me the possibility to run my laptop over eight hours without power cable. All the credits are going to the package called TLP.

To keep it short, TLP is a tool for advanced power management on Linux. It comes with pre-configured modes for your notebook, so you can basically use it by installing without any configurations. For advanced users, it also provides fine tuned configurations for almost every hardware component of your laptop.

Install tlp packages first:

On Ubuntu run:

sudo apt-get update && sudo apt-get install tlp tlp-rdw

The packages are available in official Ubuntu repositories, but if you manage your sources by hand, you might also have to add the ppa:

sudo add-apt-repository ppa:linrunner/tlp

Important: On Lenovo ThinkPads it's recommended to additionally install packages for battery charge thresholds and recalibration. The tp-smapi-dkms package is available in PPA of most distributions, but the acpi-call-dkms can be installed from the universe repositories.

sudo apt-get install tp-smapi-dkms acpi-call-dkms

To install these packages on other distributions (e.g. Fedora, Arch or SUSE) just use your package manager/tool.

Now check if the service was started automatically: sudo service tlp status. Start it, if it's not active/running: sudo service tlp start.

That's actually it and you are ready to go. I use this package with basic setup (no additional configurations) for months with latest Linux kernel (currently 5.1.12) and had no issues with battery so far.

If you're curious about additional settings, run sudo tlp-stat for current configuration and hardware information. You can also limit output for specific hardware, e.g. sudo tlp-stat -b shows you current stats about the battery:

root@darkzone ~ # tlp-stat -b
--- TLP 1.2.2 --------------------------------------------

+++ Battery Features: Charge Thresholds and Recalibrate
natacpi    = active (data, thresholds)
tpacpi-bat = active (recalibrate)

+++ ThinkPad Battery Status: BAT0 (Main / Internal)
/sys/class/power_supply/BAT0/manufacturer              = SMP
/sys/class/power_supply/BAT0/model_name                = 01AV430
/sys/class/power_supply/BAT0/cycle_count               =     20
/sys/class/power_supply/BAT0/energy_full_design        =  57020 [mWh]
/sys/class/power_supply/BAT0/energy_full               =  60970 [mWh]
/sys/class/power_supply/BAT0/energy_now                =  58660 [mWh]
/sys/class/power_supply/BAT0/power_now                 =      0 [mW]
/sys/class/power_supply/BAT0/status                    = Unknown (threshold effective)

/sys/class/power_supply/BAT0/charge_start_threshold    =     96 [%]
/sys/class/power_supply/BAT0/charge_stop_threshold     =    100 [%]
tpacpi-bat.BAT0.forceDischarge                         =      0

Charge                                                 =   96.2 [%]
Capacity                                               =  106.9 [%]

The official documentation provides a lot of additional functions and features. Check it out: linrunner.de: TLP – Linux Advanced Power Management

I hope this short guide helps anyone and you'll be happy again with the battery runtime of your notebook!