搜尋
首頁系統教程Linux如何在Linux中使用TLP優化筆記本電腦電池壽命

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.

Table of Contents

What is TLP?

TLP is an advanced power management tool for Linux. Its goal is to improve battery life on laptops running Linux without the need for complex configurations.

TLP requires zero configuration. TLP comes with a default configuration that's already optimized for battery life. It implements Powertop's recommendations out of the box. So users can simply install it and forget about it.

Some of the things TLP handles include:

  • Power source-dependent configuration (whether you're running on battery or AC power)
  • Processor frequency scaling including "turbo boost" / "turbo core"
  • Power-saving settings for your hard disk or SSD
  • Runtime power management for PCI(e) bus devices
  • Wi-Fi power saving mode
  • And more.

TLP will apply these settings automatically depending on your power source. It's a great tool for Linux laptop users who want to maximize their battery life with minimal hassle.

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 need to 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-lts (Community) – This is an optional external kernel module for the LTS kernel. It provides battery recalibration for ThinkPad models from the year 2011 onwards, such as the T420/X220 and newer models.
  • tp_smapi (Community) – This is an optional external kernel module. It provides battery charge thresholds and recalibration for ThinkPads made before the year 2011. It also provides specific tlp-stat -b output for models made until the year 2011.
  • tp_smapi-lts (Community) – This is optional. Use it instead of tp_smapi when the LTS kernel is installed.

Install the appropriate package using your preferred package manager or with the following command:

$ sudo pacman -S acpi_call

Replace acpi_call with acpi_call-lts, tp_smapi or tp_smapi-lts where suitable.

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 (main) – This is an optional external kernel module that provides battery recalibration for ThinkPad models from the year 2011 onwards, such as the T420/X220 and newer.
  • tp-smapi-dkms (main) – This is an optional external kernel module. It provides battery charge thresholds and recalibration for ThinkPads made before the year 2011. It also provides specific tlp-stat -b output for models made until the year 2011.

Install the appropriate package using your preferred package manager or with the following command:

$ sudo apt install acpi-call-dkms

Replace 'acpi-call-dkms' with 'tp-smapi-dkms' as needed.

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 (Fedora repo) – This is required to build the kernel module from the akmod package.
  • akmod-tp_smapi (ThinkPad Extras repo) – This is an optional external kernel module source that provides battery charge thresholds and recalibration.

On openSUSE:

$ sudo zypper install tlp tlp-rdw

For Thinkpads, install the appropriate packages.

  • acpi_call – This is an optional external kernel module that provides battery recalibration for ThinkPad models from the year 2011 onwards, such as the T420/X220 and newer.
  • tp_smapi – This is an optional external kernel module. It provides battery charge thresholds and recalibration for ThinkPads made before the year 2011. It also provides specific tlp-stat -b output for models made until the year 2011.

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 (PPA or universe) – This is an optional external kernel module that provides battery recalibration for ThinkPad models from the year 2011 onwards, such as the T420/X220 and newer.
  • tp-smapi-dkms (universe) – This is an optional external kernel module. It provides battery charge thresholds and recalibration for ThinkPads made before the year 2011. It also provides specific tlp-stat -b output for models made until the year 2011.

You can install the appropriate package either using your preferred package manager or with the following command:

$ sudo apt install acpi-call-dkms

If necessary, replace 'acpi-call-dkms' with 'tp-smapi-dkms'.

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

As 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 these default settings in the TLP default configuration file, which is 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)
<strong> +++ TLP Status
 State          = enabled
 RDW state      = enabled</strong>
 Last run       = 02:46:11 PM IST,     53 sec(s) ago
 Mode           = battery
 Power source   = battery
[...]

如何在Linux中使用TLP優化筆記本電腦電池壽命

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 pressing CTRL+O followed by CTRL+X.

Force battery (BAT) configuration

When no power supply is 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.

Frequently Asked Questions

Q1: What is TLP?

A: TLP is a power management tool for Linux-based systems. It optimizes battery life by managing system settings such as power source preferences, CPU speed, hard disk spins, and Wi-Fi power saving.

Q2: Does TLP require configuration?

A: No, TLP comes pre-configured and generally works well with the default settings. However, users can modify its configuration to better suit their needs.

Q3: How do I install TLP?

A: TLP can be installed via the terminal using package management commands like apt for Debian/Ubuntu based systems, or dnf for Fedora systems.

Q4: Can TLP help with overheating issues?

A: Yes, TLP can help manage system heat by intelligently controlling system settings that affect power consumption and heat generation.

Q5: How do I check if TLP is running?

A: You can check if TLP is running by using the terminal command sudo tlp-stat -s.

Q6: Does TLP work on all laptops?

A: TLP is designed to work with most modern laptops, but its effectiveness may vary depending on the specific model and hardware.

Q7: Can I use TLP on desktop systems?

A: While TLP is primarily designed for laptops, it can also be used on desktop systems for some of its features. However, the benefits on a desktop may be less noticeable.

Q8: Is TLP free to use?

A: Yes, TLP is open-source and free to use. It's licensed under GPLv2.

Conclusion

TLP is one of the recommended application that you should install on your Linux laptop. It is also worth mentioning that you should not use multiple power saving utilities 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 recommended to use only TLP and remove other similar tools.

Resources:

  • TLP website
  • TLP GitHub Repository

Related read:

  • Automatically Optimize CPU Speed And Power With Auto-cpufreq In Linux
  • CPU Power Manager – Control And Manage CPU Frequency In Linux
  • How To Check Laptop Battery Status And Level In Terminal In Linux

Featured image by mohamed Hassan from Pixabay.

以上是如何在Linux中使用TLP優化筆記本電腦電池壽命的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
用sed命令掌握文本操縱用sed命令掌握文本操縱Mar 16, 2025 am 09:48 AM

Linux 命令行界面提供了豐富的文本處理工具,其中最強大的工具之一是 sed 命令。 sed 是 Stream EDitor 的縮寫,是一個多功能工具,允許對文本文件和流進行複雜的處理。 什麼是 Sed? sed 是一款非交互式文本編輯器,它操作管道輸入或文本文件。通過提供指令,您可以讓它修改和處理文件或流中的文本。 sed 最常見的用例包括選擇文本、替換文本、修改原始文件、向文本添加行或從文本中刪除行等操作。它可以在 Bash 和其他命令行 shell 中從命令行使用。 Sed 命令語法 sed

Linux內核源代碼超過4000萬行Linux內核源代碼超過4000萬行Mar 05, 2025 am 09:35 AM

Linux:现代计算的基石,从智能手机到超级计算机,无所不能。多年来,Linux内核的规模和复杂性显著增长。截至2025年1月,Linux内核源代码大约包含4000万行代码!这是开源、社区驱动项目历史上最伟大的成就之一。 本文将讨论Linux内核源代码行数的指数级增长,其原因以及如何自行检查当前行数。 目录 - Linux内核的历程 统计Linux内核源代码的行数 只统计C和头文件 内核增长的指数趋势 验证历史Linux内核行数 总结 Linux内核的历程 自1991年Linus Tor

PILET:由Raspberry Pi提供動力的模塊化,便攜式迷你計算機PILET:由Raspberry Pi提供動力的模塊化,便攜式迷你計算機Mar 06, 2025 am 10:11 AM

Discover Pilet:一種複古的,開源的迷你計算機,正在尋找一種將經典風格與尖端技術融合的迷你計算機? Meet Pilet是一個由Raspberry Pi 5的模塊化的開源奇蹟。擁有7小時的電池壽命

如何計算Linux中的文件和目錄:初學者指南如何計算Linux中的文件和目錄:初學者指南Mar 19, 2025 am 10:48 AM

有效地計數Linux中的文件和文件夾:綜合指南 知道如何快速計算Linux中的文件和目錄對於系統管理員和管理大型數據集的任何人至關重要。本指南使用簡單命令l演示

用Liquorix內核增強Linux系統的秘密武器用Liquorix內核增強Linux系統的秘密武器Mar 08, 2025 pm 12:12 PM

Liquorix內核:提升Linux系統性能的利器 Linux以其靈活、安全和高性能而聞名,成為開發人員、系統管理員和高級用戶的首選操作系統。然而,通用Linux內核並非總是能滿足尋求最大性能和響應速度用戶的需求。這就是Liquorix內核發揮作用的地方——一個針對性能優化的替代方案,有望增強您的Linux系統。本文將探討Liquorix內核是什麼,為什麼您可能想要使用它,以及如何安裝和配置它以充分發揮系統的性能。 Liquorix內核詳解 Liquorix內核是一個預編譯的Linux內核,專為

如何將用戶添加到Linux中的多個組如何將用戶添加到Linux中的多個組Mar 18, 2025 am 11:44 AM

有效管理用戶帳戶和組成員資格對於Linux/UNIX系統管理至關重要。 這樣可以確保適當的資源和數據訪問控制。 本教程詳細介紹瞭如何將用戶添加到Linux和Unix系統中的多個組中。 我們

System76介紹Meerkat Mini PC:小包裝中的大功能System76介紹Meerkat Mini PC:小包裝中的大功能Mar 05, 2025 am 10:28 AM

System76 Meerkat:強大的迷你PC,正在尋找一台功能強大但節省空間的計算機? 與System76結識Meerkat Mini PC!這個緊湊型強國非常適合整理台式機和苛刻的任務。 目錄 - 緊湊的設計,令人印象深刻

構建自己的Ubuntu個人云:創建安全數據天堂的分步指南構建自己的Ubuntu個人云:創建安全數據天堂的分步指南Mar 05, 2025 am 11:02 AM

在當今數字時代,數據不僅僅是信息,更是我們生活的一部分。從照片和文檔到敏感的個人信息,我們的數據代表著我們的回憶、工作和興趣。雖然雲存儲服務廣泛可用,但它們通常伴隨著隱私問題、訂閱費用和定制限制。這就是在Ubuntu上構建個人云作為強大替代方案的意義所在,它使您可以完全控制自己的數據,並靈活地根據需要進行自定義和擴展。 本指南將引導您設置基於Ubuntu的個人云,使用Nextcloud作為主要應用程序,並確保您的設置安全可靠。 為什麼在Ubuntu上構建個人云? Ubuntu是最流行的Linux

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

AI Hentai Generator

AI Hentai Generator

免費產生 AI 無盡。

熱門文章

R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
2 週前By尊渡假赌尊渡假赌尊渡假赌
倉庫:如何復興隊友
4 週前By尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
3 週前By尊渡假赌尊渡假赌尊渡假赌

熱工具

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版

EditPlus 中文破解版

EditPlus 中文破解版

體積小,語法高亮,不支援程式碼提示功能

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

Dreamweaver Mac版

Dreamweaver Mac版

視覺化網頁開發工具