TLP:一个可以延长Linux笔记本电池寿命的高级电源管理工具

系统 Linux
当我考虑延长电池寿命时,我没有多少选择,但我觉得 TLP 对我来说是一个更好的解决方案,所以我会继续使用它。在本教程中,我们将详细讨论 TLP 以延长电池寿命。

 [[265034]]

笔记本电池是针对 Windows 操作系统进行了高度优化的,当我在笔记本电脑中使用 Windows 操作系统时,我已经意识到这一点,但对于 Linux 来说却不一样。

多年来,Linux 在电池优化方面取得了很大进步,但我们仍然需要做一些必要的事情来改善 Linux 中笔记本电脑的电池寿命。

当我考虑延长电池寿命时,我没有多少选择,但我觉得 TLP 对我来说是一个更好的解决方案,所以我会继续使用它。

在本教程中,我们将详细讨论 TLP 以延长电池寿命。

我们之前在我们的网站上写过三篇关于 Linux 笔记本电池节电工具 的文章:PowerTOP电池充电状态

TLP

TLP 是一款自由开源的高级电源管理工具,可在不进行任何配置更改的情况下延长电池寿命。

由于它的默认配置已针对电池寿命进行了优化,因此你可能只需要安装,然后就忘记它吧。

此外,它可以高度定制化,以满足你的特定要求。TLP 是一个具有自动后台任务的纯命令行工具。它不包含GUI。

TLP 适用于各种品牌的笔记本电脑。设置电池充电阈值仅适用于 IBM/Lenovo ThinkPad。

所有 TLP 设置都存储在 /etc/default/tlp 中。其默认配置提供了开箱即用的优化的节能设置。

以下 TLP 设置可用于自定义,如果需要,你可以相应地进行必要的更改。

TLP 功能

  • 内核笔记本电脑模式和脏缓冲区超时
  • 处理器频率调整,包括 “turbo boost”/“turbo core”
  • 限制***/最小的 P 状态以控制 CPU 的功耗
  • HWP 能源性能提示
  • 用于多核/超线程的功率感知进程调度程序
  • 处理器性能与节能策略(x86_energy_perf_policy
  • 硬盘高级电源管理级别(APM)和降速超时(按磁盘)
  • AHCI 链路电源管理(ALPM)与设备黑名单
  • PCIe 活动状态电源管理(PCIe ASPM)
  • PCI(e) 总线设备的运行时电源管理
  • Radeon 图形电源管理(KMS 和 DPM)
  • Wifi 省电模式
  • 关闭驱动器托架中的光盘驱动器
  • 音频省电模式
  • I/O 调度程序(按磁盘)
  • USB 自动暂停,支持设备黑名单/白名单(输入设备自动排除)
  • 在系统启动和关闭时启用或禁用集成的 wifi、蓝牙或 wwan 设备
  • 在系统启动时恢复无线电设备状态(从之前的关机时的状态)
  • 无线电设备向导:在网络连接/断开和停靠/取消停靠时切换无线电
  • 禁用 LAN 唤醒
  • 挂起/休眠后恢复集成的 WWAN 和蓝牙状态
  • 英特尔处理器的动态电源降低 —— 需要内核和 PHC-Patch 支持
  • 电池充电阈值 —— 仅限 ThinkPad
  • 重新校准电池 —— 仅限 ThinkPad

如何在 Linux 上安装 TLP

TLP 包在大多数发行版官方存储库中都可用,因此,使用发行版的 包管理器 来安装它。

对于 Fedora 系统,使用 DNF 命令 安装 TLP。

  1. $ sudo dnf install tlp tlp-rdw

ThinkPad 需要一些附加软件包。

  1. $ sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
  2. $ sudo dnf install http://repo.linrunner.de/fedora/tlp/repos/releases/tlp-release.fc$(rpm -E %fedora).noarch.rpm
  3. $ sudo dnf install akmod-tp_smapi akmod-acpi_call kernel-devel

安装 smartmontool 以显示 tlp-stat 中 S.M.A.R.T. 数据。

  1. $ sudo dnf install smartmontools

对于 Debian/Ubuntu 系统,使用 APT-GET 命令APT 命令 安装 TLP。

  1. $ sudo apt install tlp tlp-rdw

ThinkPad 需要一些附加软件包。

  1. $ sudo apt-get install tp-smapi-dkms acpi-call-dkms

安装 smartmontool 以显示 tlp-stat 中 S.M.A.R.T. 数据。

  1. $ sudo apt-get install smartmontools

当基于 Ubuntu 的系统的官方软件***时时,请使用以下 PPA 存储库,该存储库提供***版本。运行以下命令以使用 PPA 安装 TLP。

  1. $ sudo apt-get install tlp tlp-rdw

对于基于 Arch Linux 的系统,使用 Pacman 命令 安装 TLP。

  1. $ sudo pacman -S tlp tlp-rdw

ThinkPad 需要一些附加软件包。

  1. $ pacman -S tp_smapi acpi_call

安装 smartmontool 以显示 tlp-stat 中 S.M.A.R.T. 数据。

  1. $ sudo pacman -S smartmontools

对于基于 Arch Linux 的系统,在启动时启用 TLP 和 TLP-Sleep 服务。

  1. $ sudo systemctl enable tlp.service
  2. $ sudo systemctl enable tlp-sleep.service

对于基于 Arch Linux 的系统,你还应该屏蔽以下服务以避免冲突,并确保 TLP 的无线电设备切换选项的正确操作。

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

对于 RHEL/CentOS 系统,使用 YUM 命令 安装 TLP。

  1. $ sudo yum install tlp tlp-rdw

安装 smartmontool 以显示 tlp-stat 中 S.M.A.R.T. 数据。

  1. $ sudo yum install smartmontools

对于 openSUSE Leap 系统,使用 Zypper 命令 安装 TLP。

  1. $ sudo zypper install TLP

安装 smartmontool 以显示 tlp-stat 中 S.M.A.R.T. 数据。

  1. $ sudo zypper install smartmontools

成功安装 TLP 后,使用以下命令启动服务。

  1. $ systemctl start tlp.service

使用方法

显示电池信息

  1. $ sudo tlp-stat -b
  2. $ sudo tlp-stat --battery
  1. --- TLP 1.1 --------------------------------------------
  2.  
  3. +++ Battery Status
  4. /sys/class/power_supply/BAT0/manufacturer = SMP
  5. /sys/class/power_supply/BAT0/model_name = L14M4P23
  6. /sys/class/power_supply/BAT0/cycle_count = (not supported)
  7. /sys/class/power_supply/BAT0/energy_full_design = 60000 [mWh]
  8. /sys/class/power_supply/BAT0/energy_full = 48850 [mWh]
  9. /sys/class/power_supply/BAT0/energy_now = 48850 [mWh]
  10. /sys/class/power_supply/BAT0/power_now = 0 [mW]
  11. /sys/class/power_supply/BAT0/status = Full
  12.  
  13. Charge = 100.0 [%]
  14. Capacity = 81.4 [%]

显示磁盘信息

  1. $ sudo tlp-stat -d
  2. $ sudo tlp-stat --disk
  1. --- TLP 1.1 --------------------------------------------
  2.  
  3. +++ Storage Devices
  4. /dev/sda:
  5. Model = WDC WD10SPCX-24HWST1
  6. Firmware = 02.01A02
  7. APM Level = 128
  8. Status = active/idle
  9. Scheduler = mq-deadline
  10.  
  11. Runtime PM: control = on, autosuspend_delay = (not available)
  12.  
  13. SMART info:
  14. 4 Start_Stop_Count = 18787
  15. 5 Reallocated_Sector_Ct = 0
  16. 9 Power_On_Hours = 606 [h]
  17. 12 Power_Cycle_Count = 1792
  18. 193 Load_Cycle_Count = 25775
  19. 194 Temperature_Celsius = 31 C]
  20.  
  21.  
  22. +++ AHCI Link Power Management (ALPM)
  23. /sys/class/scsi_host/host0/link_power_management_policy = med_power_with_dipm
  24. /sys/class/scsi_host/host1/link_power_management_policy = med_power_with_dipm
  25. /sys/class/scsi_host/host2/link_power_management_policy = med_power_with_dipm
  26. /sys/class/scsi_host/host3/link_power_management_policy = med_power_with_dipm
  27.  
  28. +++ AHCI Host Controller Runtime Power Management
  29. /sys/bus/pci/devices/0000:00:17.0/ata1/power/control = on
  30. /sys/bus/pci/devices/0000:00:17.0/ata2/power/control = on
  31. /sys/bus/pci/devices/0000:00:17.0/ata3/power/control = on
  32. /sys/bus/pci/devices/0000:00:17.0/ata4/power/control = on

显示 PCI 设备信息

  1. $ sudo tlp-stat -e
  2. $ sudo tlp-stat --pcie
  1. $ sudo tlp-stat -e
  2. or
  3. $ sudo tlp-stat --pcie
  4.  
  5. --- TLP 1.1 --------------------------------------------
  6.  
  7. +++ Runtime Power Management
  8. Device blacklist = (not configured)
  9. Driver blacklist = amdgpu nouveau nvidia radeon pcieport
  10.  
  11. /sys/bus/pci/devices/0000:00:00.0/power/control = auto (0x060000, Host bridge, skl_uncore)
  12. /sys/bus/pci/devices/0000:00:01.0/power/control = auto (0x060400, PCI bridge, pcieport)
  13. /sys/bus/pci/devices/0000:00:02.0/power/control = auto (0x030000, VGA compatible controller, i915)
  14. /sys/bus/pci/devices/0000:00:14.0/power/control = auto (0x0c0330, USB controller, xhci_hcd)
  15.  
  16. ......

显示图形卡信息

  1. $ sudo tlp-stat -g
  2. $ sudo tlp-stat --graphics
  1. --- TLP 1.1 --------------------------------------------
  2.  
  3. +++ Intel Graphics
  4. /sys/module/i915/parameters/enable_dc = -1 (use per-chip default)
  5. /sys/module/i915/parameters/enable_fbc = 1 (enabled)
  6. /sys/module/i915/parameters/enable_psr = 0 (disabled)
  7. /sys/module/i915/parameters/modeset = -1 (use per-chip default)

显示处理器信息

  1. $ sudo tlp-stat -p
  2. $ sudo tlp-stat --processor
  1. --- TLP 1.1 --------------------------------------------
  2.  
  3. +++ Processor
  4. CPU model = Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
  5.  
  6. /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver = intel_pstate
  7. /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor = powersave
  8. /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors = performance powersave
  9. /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq = 800000 [kHz]
  10. /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq = 3500000 [kHz]
  11. /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference = balance_power
  12. /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_available_preferences = default performance balance_performance balance_power power
  13.  
  14. ......
  15.  
  16. /sys/devices/system/cpu/intel_pstate/min_perf_pct = 22 [%]
  17. /sys/devices/system/cpu/intel_pstate/max_perf_pct = 100 [%]
  18. /sys/devices/system/cpu/intel_pstate/no_turbo = 0
  19. /sys/devices/system/cpu/intel_pstate/turbo_pct = 33 [%]
  20. /sys/devices/system/cpu/intel_pstate/num_pstates = 28
  21.  
  22. x86_energy_perf_policy: program not installed.
  23.  
  24. /sys/module/workqueue/parameters/power_efficient = Y
  25. /proc/sys/kernel/nmi_watchdog = 0
  26.  
  27. +++ Undervolting
  28. PHC kernel not available.

显示系统数据信息

  1. $ sudo tlp-stat -s
  2. $ sudo tlp-stat --system
  1. --- TLP 1.1 --------------------------------------------
  2.  
  3. +++ System Info
  4. System = LENOVO Lenovo ideapad Y700-15ISK 80NV
  5. BIOS = CDCN35WW
  6. Release = "Manjaro Linux"
  7. Kernel = 4.19.6-1-MANJARO #1 SMP PREEMPT Sat Dec 1 12:21:26 UTC 2018 x86_64
  8. /proc/cmdline = BOOT_IMAGE=/boot/vmlinuz-4.19-x86_64 root=UUID=69d9dd18-36be-4631-9ebb-78f05fe3217f rw quiet resume=UUID=a2092b92-af29-4760-8e68-7a201922573b
  9. Init system = systemd
  10. Boot mode = BIOS (CSM, Legacy)
  11.  
  12. +++ TLP Status
  13. State = enabled
  14. Last run = 11:04:00 IST, 596 sec(s) ago
  15. Mode = battery
  16. Power source = battery

显示温度和风扇速度信息

  1. $ sudo tlp-stat -t
  2. $ sudo tlp-stat --temp
  1. --- TLP 1.1 --------------------------------------------
  2.  
  3. +++ Temperatures
  4. CPU temp = 36 C]
  5. Fan speed = (not available)

显示 USB 设备数据信息

  1. $ sudo tlp-stat -u
  2. $ sudo tlp-stat --usb
  1. --- TLP 1.1 --------------------------------------------
  2.  
  3. +++ USB
  4. Autosuspend = disabled
  5. Device whitelist = (not configured)
  6. Device blacklist = (not configured)
  7. Bluetooth blacklist = disabled
  8. Phone blacklist = disabled
  9. WWAN blacklist = enabled
  10.  
  11. Bus 002 Device 001 ID 1d6b:0003 control = auto, autosuspend_delay_ms = 0 -- Linux Foundation 3.0 root hub (hub)
  12. Bus 001 Device 003 ID 174f:14e8 control = auto, autosuspend_delay_ms = 2000 -- Syntek (uvcvideo)
  13.  
  14. ......

显示警告信息

  1. $ sudo tlp-stat -w
  2. $ sudo tlp-stat --warn
  1. --- TLP 1.1 --------------------------------------------
  2.  
  3. No warnings detected.

状态报告及配置和所有活动的设置

  1. $ sudo tlp-stat
  1. --- TLP 1.1 --------------------------------------------
  2.  
  3. +++ Configured Settings: /etc/default/tlp
  4. TLP_ENABLE=1
  5. TLP_DEFAULT_MODE=AC
  6. TLP_PERSISTENT_DEFAULT=0
  7. DISK_IDLE_SECS_ON_AC=0
  8. DISK_IDLE_SECS_ON_BAT=2
  9. MAX_LOST_WORK_SECS_ON_AC=15
  10. MAX_LOST_WORK_SECS_ON_BAT=60
  11.  
  12. ......
  13.  
  14. +++ System Info
  15. System = LENOVO Lenovo ideapad Y700-15ISK 80NV
  16. BIOS = CDCN35WW
  17. Release = "Manjaro Linux"
  18. Kernel = 4.19.6-1-MANJARO #1 SMP PREEMPT Sat Dec 1 12:21:26 UTC 2018 x86_64
  19. /proc/cmdline = BOOT_IMAGE=/boot/vmlinuz-4.19-x86_64 root=UUID=69d9dd18-36be-4631-9ebb-78f05fe3217f rw quiet resume=UUID=a2092b92-af29-4760-8e68-7a201922573b
  20. Init system = systemd
  21. Boot mode = BIOS (CSM, Legacy)
  22.  
  23. +++ TLP Status
  24. State = enabled
  25. Last run = 11:04:00 IST, 684 sec(s) ago
  26. Mode = battery
  27. Power source = battery
  28.  
  29. +++ Processor
  30. CPU model = Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
  31.  
  32. /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver = intel_pstate
  33. /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor = powersave
  34. /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors = performance powersave
  35.  
  36. ......
  37.  
  38. /sys/devices/system/cpu/intel_pstate/min_perf_pct = 22 [%]
  39. /sys/devices/system/cpu/intel_pstate/max_perf_pct = 100 [%]
  40. /sys/devices/system/cpu/intel_pstate/no_turbo = 0
  41. /sys/devices/system/cpu/intel_pstate/turbo_pct = 33 [%]
  42. /sys/devices/system/cpu/intel_pstate/num_pstates = 28
  43.  
  44. x86_energy_perf_policy: program not installed.
  45.  
  46. /sys/module/workqueue/parameters/power_efficient = Y
  47. /proc/sys/kernel/nmi_watchdog = 0
  48.  
  49. +++ Undervolting
  50. PHC kernel not available.
  51.  
  52. +++ Temperatures
  53. CPU temp = 42 C]
  54. Fan speed = (not available)
  55.  
  56. +++ File System
  57. /proc/sys/vm/laptop_mode = 2
  58. /proc/sys/vm/dirty_writeback_centisecs = 6000
  59. /proc/sys/vm/dirty_expire_centisecs = 6000
  60. /proc/sys/vm/dirty_ratio = 20
  61. /proc/sys/vm/dirty_background_ratio = 10
  62.  
  63. +++ Storage Devices
  64. /dev/sda:
  65. Model = WDC WD10SPCX-24HWST1
  66. Firmware = 02.01A02
  67. APM Level = 128
  68. Status = active/idle
  69. Scheduler = mq-deadline
  70.  
  71. Runtime PM: control = on, autosuspend_delay = (not available)
  72.  
  73. SMART info:
  74. 4 Start_Stop_Count = 18787
  75. 5 Reallocated_Sector_Ct = 0
  76. 9 Power_On_Hours = 606 [h]
  77. 12 Power_Cycle_Count = 1792
  78. 193 Load_Cycle_Count = 25777
  79. 194 Temperature_Celsius = 31 C]
  80.  
  81.  
  82. +++ AHCI Link Power Management (ALPM)
  83. /sys/class/scsi_host/host0/link_power_management_policy = med_power_with_dipm
  84. /sys/class/scsi_host/host1/link_power_management_policy = med_power_with_dipm
  85. /sys/class/scsi_host/host2/link_power_management_policy = med_power_with_dipm
  86. /sys/class/scsi_host/host3/link_power_management_policy = med_power_with_dipm
  87.  
  88. +++ AHCI Host Controller Runtime Power Management
  89. /sys/bus/pci/devices/0000:00:17.0/ata1/power/control = on
  90. /sys/bus/pci/devices/0000:00:17.0/ata2/power/control = on
  91. /sys/bus/pci/devices/0000:00:17.0/ata3/power/control = on
  92. /sys/bus/pci/devices/0000:00:17.0/ata4/power/control = on
  93.  
  94. +++ PCIe Active State Power Management
  95. /sys/module/pcie_aspm/parameters/policy = powersave
  96.  
  97. +++ Intel Graphics
  98. /sys/module/i915/parameters/enable_dc = -1 (use per-chip default)
  99. /sys/module/i915/parameters/enable_fbc = 1 (enabled)
  100. /sys/module/i915/parameters/enable_psr = 0 (disabled)
  101. /sys/module/i915/parameters/modeset = -1 (use per-chip default)
  102.  
  103. +++ Wireless
  104. bluetooth = on
  105. wifi = on
  106. wwan = none (no device)
  107.  
  108. hci0(btusb) : bluetooth, not connected
  109. wlp8s0(iwlwifi) : wifi, connected, power management = on
  110.  
  111. +++ Audio
  112. /sys/module/snd_hda_intel/parameters/power_save = 1
  113. /sys/module/snd_hda_intel/parameters/power_save_controller = Y
  114.  
  115. +++ Runtime Power Management
  116. Device blacklist = (not configured)
  117. Driver blacklist = amdgpu nouveau nvidia radeon pcieport
  118.  
  119. /sys/bus/pci/devices/0000:00:00.0/power/control = auto (0x060000, Host bridge, skl_uncore)
  120. /sys/bus/pci/devices/0000:00:01.0/power/control = auto (0x060400, PCI bridge, pcieport)
  121. /sys/bus/pci/devices/0000:00:02.0/power/control = auto (0x030000, VGA compatible controller, i915)
  122.  
  123. ......
  124.  
  125. +++ USB
  126. Autosuspend = disabled
  127. Device whitelist = (not configured)
  128. Device blacklist = (not configured)
  129. Bluetooth blacklist = disabled
  130. Phone blacklist = disabled
  131. WWAN blacklist = enabled
  132.  
  133. Bus 002 Device 001 ID 1d6b:0003 control = auto, autosuspend_delay_ms = 0 -- Linux Foundation 3.0 root hub (hub)
  134. Bus 001 Device 003 ID 174f:14e8 control = auto, autosuspend_delay_ms = 2000 -- Syntek (uvcvideo)
  135. Bus 001 Device 002 ID 17ef:6053 control = on, autosuspend_delay_ms = 2000 -- Lenovo (usbhid)
  136. Bus 001 Device 004 ID 8087:0a2b control = auto, autosuspend_delay_ms = 2000 -- Intel Corp. (btusb)
  137. Bus 001 Device 001 ID 1d6b:0002 control = auto, autosuspend_delay_ms = 0 -- Linux Foundation 2.0 root hub (hub)
  138.  
  139. +++ Battery Status
  140. /sys/class/power_supply/BAT0/manufacturer = SMP
  141. /sys/class/power_supply/BAT0/model_name = L14M4P23
  142. /sys/class/power_supply/BAT0/cycle_count = (not supported)
  143. /sys/class/power_supply/BAT0/energy_full_design = 60000 [mWh]
  144. /sys/class/power_supply/BAT0/energy_full = 51690 [mWh]
  145. /sys/class/power_supply/BAT0/energy_now = 50140 [mWh]
  146. /sys/class/power_supply/BAT0/power_now = 12185 [mW]
  147. /sys/class/power_supply/BAT0/status = Discharging
  148.  
  149. Charge = 97.0 [%]
  150. Capacity = 86.2 [%]

责任编辑:庞桂玉 来源: Linux中国
相关推荐

2019-02-22 16:20:50

PowerTOPLinux电池寿命

2021-12-14 22:10:15

Windows 11Windows微软

2021-12-31 10:40:48

JarbootJavaGitHub

2019-07-22 20:03:23

Docker操作系统Linux

2011-04-29 13:41:52

笔记本电池

2011-08-09 16:13:22

数据中心UPS电池

2010-08-25 10:50:14

Linux命令

2011-04-29 13:19:45

笔记本电池

2021-11-11 15:24:24

手机电池充电

2018-11-09 09:40:52

2011-05-06 10:31:32

笔记本电池

2018-12-17 10:00:42

Linux电池命令

2021-08-16 08:44:56

UPS电池寿命

2018-05-16 11:45:42

Linux终端电池状态

2011-08-30 16:55:29

Ubuntu

2021-01-14 15:41:22

LinuxSupervisor命令

2009-03-25 09:10:29

微软Windows 7操作系统

2011-05-06 10:31:34

笔记本电池

2012-10-09 14:13:08

惠普笔记本电池保养

2019-08-30 08:00:00

WebminWebLinux
点赞
收藏

51CTO技术栈公众号