歡迎光臨
每天分享高質量文章

TLP:一個可以延長 Linux 筆記本電池壽命的高級電源管理工具 | Linux 中國

多年來,Linux 在電池優化方面取得了很大進步,但我們仍然需要做一些必要的事情來改善 Linux 中筆記本電腦的電池壽命。

— Magesh Maruthamuthu

 

筆記本電池是針對 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. +++ Battery Status
  3. /sys/class/power_supply/BAT0/manufacturer = SMP
  4. /sys/class/power_supply/BAT0/model_name = L14M4P23
  5. /sys/class/power_supply/BAT0/cycle_count = (not supported)
  6. /sys/class/power_supply/BAT0/energy_full_design = 60000 [mWh]
  7. /sys/class/power_supply/BAT0/energy_full = 48850 [mWh]
  8. /sys/class/power_supply/BAT0/energy_now = 48850 [mWh]
  9. /sys/class/power_supply/BAT0/power_now = 0 [mW]
  10. /sys/class/power_supply/BAT0/status = Full
  11. Charge = 100.0 [%]
  12. Capacity = 81.4 [%]

顯示磁盤信息

  1. $ sudo tlp-stat -d
  2. $ sudo tlp-stat --disk
  1. --- TLP 1.1 --------------------------------------------
  2. +++ Storage Devices
  3. /dev/sda:
  4. Model = WDC WD10SPCX-24HWST1
  5. Firmware = 02.01A02
  6. APM Level = 128
  7. Status = active/idle
  8. Scheduler = mq-deadline
  9. Runtime PM: control = on, autosuspend_delay = (not available)
  10. SMART info:
  11. 4 Start_Stop_Count = 18787
  12. 5 Reallocated_Sector_Ct = 0
  13. 9 Power_On_Hours = 606 [h]
  14. 12 Power_Cycle_Count = 1792
  15. 193 Load_Cycle_Count = 25775
  16. 194 Temperature_Celsius = 31 C]
  17. +++ AHCI Link Power Management (ALPM)
  18. /sys/class/scsi_host/host0/link_power_management_policy = med_power_with_dipm
  19. /sys/class/scsi_host/host1/link_power_management_policy = med_power_with_dipm
  20. /sys/class/scsi_host/host2/link_power_management_policy = med_power_with_dipm
  21. /sys/class/scsi_host/host3/link_power_management_policy = med_power_with_dipm
  22. +++ AHCI Host Controller Runtime Power Management
  23. /sys/bus/pci/devices/0000:00:17.0/ata1/power/control = on
  24. /sys/bus/pci/devices/0000:00:17.0/ata2/power/control = on
  25. /sys/bus/pci/devices/0000:00:17.0/ata3/power/control = on
  26. /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. --- TLP 1.1 --------------------------------------------
  5. +++ Runtime Power Management
  6. Device blacklist = (not configured)
  7. Driver blacklist = amdgpu nouveau nvidia radeon pcieport
  8. /sys/bus/pci/devices/0000:00:00.0/power/control = auto (0x060000, Host bridge, skl_uncore)
  9. /sys/bus/pci/devices/0000:00:01.0/power/control = auto (0x060400, PCI bridge, pcieport)
  10. /sys/bus/pci/devices/0000:00:02.0/power/control = auto (0x030000, VGA compatible controller, i915)
  11. /sys/bus/pci/devices/0000:00:14.0/power/control = auto (0x0c0330, USB controller, xhci_hcd)
  12. ......

顯示圖形卡信息

  1. $ sudo tlp-stat -g
  2. $ sudo tlp-stat --graphics
  1. --- TLP 1.1 --------------------------------------------
  2. +++ Intel Graphics
  3. /sys/module/i915/parameters/enable_dc = -1 (use per-chip default)
  4. /sys/module/i915/parameters/enable_fbc = 1 (enabled)
  5. /sys/module/i915/parameters/enable_psr = 0 (disabled)
  6. /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. +++ Processor
  3. CPU model = Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
  4. /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver = intel_pstate
  5. /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor = powersave
  6. /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors = performance powersave
  7. /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq = 800000 [kHz]
  8. /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq = 3500000 [kHz]
  9. /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference = balance_power
  10. /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_available_preferences = default performance balance_performance balance_power power
  11. ......
  12. /sys/devices/system/cpu/intel_pstate/min_perf_pct = 22 [%]
  13. /sys/devices/system/cpu/intel_pstate/max_perf_pct = 100 [%]
  14. /sys/devices/system/cpu/intel_pstate/no_turbo = 0
  15. /sys/devices/system/cpu/intel_pstate/turbo_pct = 33 [%]
  16. /sys/devices/system/cpu/intel_pstate/num_pstates = 28
  17. x86_energy_perf_policy: program not installed.
  18. /sys/module/workqueue/parameters/power_efficient = Y
  19. /proc/sys/kernel/nmi_watchdog = 0
  20. +++ Undervolting
  21. PHC kernel not available.

顯示系統資料信息

  1. $ sudo tlp-stat -s
  2. $ sudo tlp-stat --system
  1. --- TLP 1.1 --------------------------------------------
  2. +++ System Info
  3. System = LENOVO Lenovo ideapad Y700-15ISK 80NV
  4. BIOS = CDCN35WW
  5. Release = "Manjaro Linux"
  6. Kernel = 4.19.6-1-MANJARO #1 SMP PREEMPT Sat Dec 1 12:21:26 UTC 2018 x86_64
  7. /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
  8. Init system = systemd
  9. Boot mode = BIOS (CSM, Legacy)
  10. +++ TLP Status
  11. State = enabled
  12. Last run = 11:04:00 IST, 596 sec(s) ago
  13. Mode = battery
  14. Power source = battery

顯示溫度和風扇速度信息

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

顯示 USB 設備資料信息

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

顯示警告信息

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

狀態報告及配置和所有活動的設置

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

已同步到看一看
赞(0)

分享創造快樂