26.6 C
Jaipur
Sunday, June 20, 2021

How To Optimize Laptop Battery Life With TLP In Linux

Must read

There are quite a few tools exists to power saving and battery life extension in Laptops. We already have looked at two tools namely Laptop Mode Tools and Powertop that improves the Linux Laptop battery performance. Today we will discuss yet another Laptop power management utility named TLP. TLP is a feature-rich commandline tool to optimize Laptop battery life in Linux.

TLP requires zero configuration. The default settings of TLP is well optimized for saving battery power in a Linux laptop. It implements Powertop’s recommendations out of the box. So you just install TLP in your Linux Laptop and forget it. TLP takes care of everything. Even though TLP’s default settings are just enough to provide optimal battery life, it is highly customizable to fulfill a specific requirement.

Install TLP in Linux

TLP is packaged for many Linux distributions including Arch Linux, Debian, Fedora, Gentoo, openSUSE and Ubuntu.

To install TLP in Arch Linux and its variants, run:

$ sudo pacman -S tlp tlp-rdw

If you’re using Thinkpad, you will install any one of the following packages. If you don’t know exactly which package to install, run tlp-stat -b command as sudo or root user. It will guide you which package to install.

  • acpi_call – External kernel module providing battery recalibration for newer ThinkPads (X220/T420 and later).
  • tp_smapi – External kernel module providing battery charge thresholds, recalibration and specific tlp-stat -b output for older ThinkPads.
  • tp_smapi-lts – Use instead of tp_smapi when the LTS kernel is installed.

On Debian:

$ sudo apt install tlp tlp-rdw

If you are using any Thinkpad model Laptops, you may need to install any one of the following packages. The output of tlp-stat -b will guide you which package to install.

  • acpi-call-dkms – External kernel module providing battery recalibration for newer ThinkPads (X220/T420 and later)
  • tp-smapi-dkms External kernel module providing battery charge thresholds, recalibration and specific tlp-stat -b output for older ThinkPads

On Fedora:

$ sudo dnf install tlp tlp-rdw

If you use any Thinkpad model Laptops, install any one of the following packages. The dependencies of following packages are not available in the default repositories. So, first enable RPM Fusion repository in Fedora and then install the appropriate packages. If you don’t know which package to install, run tlp-stat -b command as sudo or root user.

  • kernel-devel Needed for the akmod packages below
  • akmod-acpi_call External kernel module providing battery recalibration for newer ThinkPads (X220/T420 and later)
  • akmod-tp_smapi External kernel module providing battery charge thresholds, recalibration and specific tlp-stat -b output for older ThinkPads

On openSUSE:

$ sudo zypper install tlp tlp-rdw

For Thinkpads, install the appropriate packages.

  • acpi_call – External kernel module providing battery recalibration for newer ThinkPads (X220/T420 and later) – Download acpi_call
  • tp_smapi_kmp – External kernel module providing battery charge thresholds, recalibration and specific tlp-stat -b output for older ThinkPads – Download tp-smapi

On Ubuntu:

To install TLP in Ubuntu and its derivatives, add the TLP official PPA:

$ sudo add-apt-repository ppa:linrunner/tlp

And install TLP using command:

$ sudo apt install tlp tlp-rdw

For Thinkpad Laptops, install the appropriate packages:

  • acpi-call-dkms External kernel module providing battery recalibration for newer ThinkPads (X220/T420 and later)
  • tp-smapi-dkms – External kernel module providing battery charge thresholds, recalibration and specific tlp-stat -b output for older ThinkPads

Again if you don’t know which package to install, run tlp-stat -b command as sudo or root.

Enable and start TLP service

After installing TLP on your Linux machine, make sure it is enabled on startup and start the service using commands:

$ sudo systemctl enable tlp.service
$ sudo systemctl start tlp.service

You should also mask the following services to avoid conflicts and assure proper operation of TLP’s Radio Device Switching options:

$ sudo systemctl mask systemd-rfkill.service
$ sudo systemctl mask systemd-rfkill.socket

Optimize Laptop battery life with TLP in Linux

Like I already mentioned, TLP requires NO configuration. It works out of the box! The default settings are well optimized for better Laptop battery life. You can view the default settings in TLP default configuration file located at /etc/tlp.conf.

To view the current TLP configurion, system information, active power saving settings and battery data, run:

$ sudo tlp-stat

Sample output:

--- TLP 1.3.1 --------------------------------------------
 +++ Configured Settings:
 defaults.conf L0004: TLP_ENABLE="1"
 defaults.conf L0005: TLP_PERSISTENT_DEFAULT="0"
 defaults.conf L0006: DISK_IDLE_SECS_ON_AC="0"
 defaults.conf L0007: DISK_IDLE_SECS_ON_BAT="2"
 defaults.conf L0008: MAX_LOST_WORK_SECS_ON_AC="15"
 defaults.conf L0009: MAX_LOST_WORK_SECS_ON_BAT="60"
 defaults.conf L0010: CPU_ENERGY_PERF_POLICY_ON_AC="balance_performance"
 defaults.conf L0011: CPU_ENERGY_PERF_POLICY_ON_BAT="balance_power"
 defaults.conf L0012: SCHED_POWERSAVE_ON_AC="0"
 defaults.conf L0013: SCHED_POWERSAVE_ON_BAT="1"
 defaults.conf L0014: NMI_WATCHDOG="0"
 defaults.conf L0015: DISK_DEVICES="nvme0n1 sda"
 defaults.conf L0016: DISK_APM_LEVEL_ON_AC="254 254"
 defaults.conf L0017: DISK_APM_LEVEL_ON_BAT="128 128"
 defaults.conf L0018: DISK_IOSCHED="keep keep"
 defaults.conf L0019: SATA_LINKPWR_ON_AC="med_power_with_dipm max_performance"
 defaults.conf L0020: SATA_LINKPWR_ON_BAT="med_power_with_dipm min_power"
 defaults.conf L0021: AHCI_RUNTIME_PM_TIMEOUT="15"
 defaults.conf L0022: PCIE_ASPM_ON_AC="default"
 defaults.conf L0023: PCIE_ASPM_ON_BAT="default"
 defaults.conf L0024: RADEON_POWER_PROFILE_ON_AC="default"
 defaults.conf L0025: RADEON_POWER_PROFILE_ON_BAT="default"
 defaults.conf L0026: RADEON_DPM_PERF_LEVEL_ON_AC="auto"
 defaults.conf L0027: RADEON_DPM_PERF_LEVEL_ON_BAT="auto"
 defaults.conf L0028: WIFI_PWR_ON_AC="off"
 defaults.conf L0029: WIFI_PWR_ON_BAT="on"
 defaults.conf L0030: WOL_DISABLE="Y"
 defaults.conf L0031: SOUND_POWER_SAVE_ON_AC="0"
 defaults.conf L0032: SOUND_POWER_SAVE_ON_BAT="1"
 defaults.conf L0033: SOUND_POWER_SAVE_CONTROLLER="Y"
 defaults.conf L0034: BAY_POWEROFF_ON_AC="0"
 defaults.conf L0035: BAY_POWEROFF_ON_BAT="0"
 defaults.conf L0036: BAY_DEVICE="sr0"
 defaults.conf L0037: RUNTIME_PM_ON_AC="on"
 defaults.conf L0038: RUNTIME_PM_ON_BAT="auto"
 defaults.conf L0039: RUNTIME_PM_DRIVER_BLACKLIST="amdgpu mei_me nouveau nvidia pcieport radeon"
/etc/tlp.conf L0323: USB_AUTOSUSPEND="0"
 defaults.conf L0041: USB_BLACKLIST_BTUSB="0"
 defaults.conf L0042: USB_BLACKLIST_PHONE="0"
 defaults.conf L0043: USB_BLACKLIST_PRINTER="1"
 defaults.conf L0044: USB_BLACKLIST_WWAN="0"
 defaults.conf L0045: USB_AUTOSUSPEND_DISABLE_ON_SHUTDOWN="0"
 defaults.conf L0046: RESTORE_DEVICE_STATE_ON_STARTUP="0"
 defaults.conf L0047: RESTORE_THRESHOLDS_ON_BAT="0"
 defaults.conf L0048: NATACPI_ENABLE="1"
 defaults.conf L0049: TPACPI_ENABLE="1"
 defaults.conf L0050: TPSMAPI_ENABLE="1"
 +++ System Info
 System         = Dell Inc. Not Specified Inspiron N5050
 BIOS           = A05
 Release        = "Fedora release 34 (Thirty Four)"
 Kernel         = 5.11.17-300.fc34.x86_64 #1 SMP Wed Apr 28 14:21:28 UTC 2021 x86_64
BOOT_IMAGE=(hd0,msdos1)/vmlinuz-5.11.17-300.fc34.x86_64 root=UUID=2dbf3f8b-de51-413e-8872-5fb61c06cb8f ro rootflags=subvol=root rhgb quiet
 Init system    = systemd 
 Boot mode      = BIOS (CSM, Legacy)
 SELinux status = enabled (enforcing)
 +++ TLP Status
 State          = enabled
 RDW state      = enabled
 Last run       = 02:46:11 PM IST,     53 sec(s) ago
 Mode           = battery
 Power source   = battery
[...]
View current TLP configurion settings, power saving settings and battery data

Disable USB auto suspend

When TLP is started with default configuration, some USB devices will be automatically suspended to save power when your Laptop is running on battery. To disable USB autosuspend, edit /etc/tlp.conf file:

$ sudo nano /etc/tlp.conf

Find the following line and set its value as 0.

USB_AUTOSUSPEND=0

You can also exclude specific devices from USB autosuspend (separate with spaces). First, use lsusb command to get the ids. Then, mention the device ids with space-separated like below

USB_BLACKLIST="8078:0014 065d:8023"

Save and close the file by presing CTRL+O follwed by CTRL+X.

Force battery (BAT) configuration

When no power supply can be detected, the setting for AC will be used on devices like desktops and embedded hardware. If you want to force the battery (BAT) settings when using TLP on these devices to enable more power saving, edit /etc/tlp.conf file:

$ sudo nano /etc/tlp.conf

Find the following lines and set their values as shown here:

# Operation mode when no power supply can be detected: AC, BAT.
TLP_DEFAULT_MODE=BAT

# Operation mode select: 0=depend on power source, 1=always use TLP_DEFAULT_MODE
TLP_PERSISTENT_DEFAULT=1

For more details, check the TLP website and its GitHub page given at the end.

TLP is one of the recommended application that you should install on your Linux latop. It is also worth mentioning that you shold not use multiple power saving utlities simultaneously. The TLP’s settings get overwritten by the other tools settings and vice versa, so you may not get optimal result. It is always recommdended to use only TLP and remove other similar tools.

Resources:

Related read:

Featured image by mohamed Hassan from Pixabay.

Source link

- Advertisement -

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement -

Latest article