首頁 > 軟體

Ubuntu 16.04/17.10下安裝電源管理工具TLP 1.0

2020-06-16 16:59:09

TLP是Linux下高階電源管理工具。以下是在Ubuntu 14.04,Ubuntu 16.04,Ubuntu 17.10以及衍生版中通過PPA安裝最新的1.0版本。

TLP是一個具有自動後台任務的命令列工具。它帶有一個設定(/etc/default/tlp),預設已經針對電池壽命進行了優化,所以您可以安裝併後就不用什麼要做的了。儘管如此,TLP是高度可客製化的,以滿足您的具體要求。

如何在Ubuntu下安裝TLP 1.0:

雖然Ubuntu軟體只提供舊版本,但您可以隨時從其官方PPA安裝最新的TLP。到目前為止,支援Ubuntu 14.04,Ubuntu 16.04,Ubuntu 17.04和Ubuntu 17.10。

1. 開啟終端通過Ctrl + Alt + T或通過搜尋“終端”形式的應用程式啟動器。 當它開啟時,執行命令:

linuxidc@linuxidc:~$ sudo add-apt-repository ppa:linrunner/tlp
[sudo] linuxidc 的密碼: 在提示時輸入您的密碼(無視覺反饋),按Enter鍵繼續新增PPA。
 TLP is a power management tool for Linux. It brings you the benefits of advanced power management without the need to understand every technical detail.

Project homepage: http://linrunner.de/tlp

Note: starting with Ubuntu Wily TLP is provided via the official Ubuntu repos. Only newer versions will be published here.
 更多資訊: https://launchpad.net/~linrunner/+archive/ubuntu/tlp
Press [ENTER] to continue or Ctrl-c to cancel adding it.

gpg: keybox '/tmp/tmp65mlg99j/pubring.gpg' created
gpg: /tmp/tmp65mlg99j/trustdb.gpg:建立了信任度資料庫
gpg: 金鑰 2B3F92F902D65EFF:公鑰“Launchpad PPA for linrunner”已匯入
gpg: 合計被處理的數量:1
gpg:              已匯入:1
OK

2. 如果您安裝了以前的版本,請通過Software Updater實用程式升級模擬器升級TLP。

或者直接執行以下命令來安裝(或升級)TLP:

linuxidc@linuxidc:~$ sudo apt-get update
命中:1 http://cn.archive.ubuntu.com/ubuntu artful InRelease
獲取:2 http://cn.archive.ubuntu.com/ubuntu artful-updates InRelease [78.6 kB] 
獲取:3 http://cn.archive.ubuntu.com/ubuntu artful-backports InRelease [72.2 kB]
獲取:4 http://cn.archive.ubuntu.com/ubuntu artful-updates/main i386 Packages [109 kB]

......

linuxidc@linuxidc:~$ sudo apt-get install tlp
正在讀取軟體包列表... 完成
正在分析軟體包的依賴關係樹     
正在讀取狀態資訊... 完成     
將會同時安裝下列軟體:
  ethtool libgsasl7 libkyotocabinet16v5 libmailutils5 libMySQLclient20
  libntlm0 libunwind8 linux-tools-4.13.0-19 linux-tools-4.13.0-19-generic
  linux-tools-common linux-tools-virtual mailutils mailutils-common
  mysql-common postfix smartmontools tlp-rdw
建議安裝:
  mailutils-mh mailutils-doc procmail postfix-mysql postfix-pgsql postfix-ldap
  postfix-pcre postfix-lmdb postfix-sqlite sasl2-bin dovecot-common resolvconf
  postfix-cdb postfix-doc gsmartcontrol smart-notifier tp-smapi-dkms
  acpi-call-dkms
下列【新】軟體包將被安裝:
  ethtool libgsasl7 libkyotocabinet16v5 libmailutils5 libmysqlclient20
  libntlm0 libunwind8 linux-tools-4.13.0-19 linux-tools-4.13.0-19-generic
  linux-tools-common linux-tools-virtual mailutils mailutils-common
  mysql-common postfix smartmontools tlp tlp-rdw
升級了 0 個軟體包,新安裝了 18 個軟體包,要解除安裝 0 個軟體包,有 36 個軟體包未被升級。
需要下載 5,205 kB 的歸檔。
解壓縮後會消耗 23.3 MB 的額外空間。
您希望繼續執行嗎? [Y/n] Y

安裝過程中還會提示如下內容

安裝後,TLP作為後台任務靜靜地執行。您可以通過編輯/etc/default/tlp來更改預設設定,或使用命令列工具來指定您的需求。閱讀完整的文件

安裝成功後,就可以啟動TLP或者reboot(重新啟動)

sudo tlp start

檢查TLP是否正常執行

sudo tlp-stat

linuxidc@linuxidc:~$ sudo tlp stat
[sudo] linuxidc 的密碼:
--- TLP 1.0 --------------------------------------------

+++ Configured Settings: /etc/default/tlp
TLP_ENABLE=1
TLP_DEFAULT_MODE=AC
TLP_PERSISTENT_DEFAULT=0
DISK_IDLE_SECS_ON_AC=0
DISK_IDLE_SECS_ON_BAT=2
MAX_LOST_WORK_SECS_ON_AC=15
MAX_LOST_WORK_SECS_ON_BAT=60
CPU_HWP_ON_AC=balance_performance
CPU_HWP_ON_BAT=balance_power
SCHED_POWERSAVE_ON_AC=0
SCHED_POWERSAVE_ON_BAT=1
NMI_WATCHDOG=0
ENERGY_PERF_POLICY_ON_AC=performance
ENERGY_PERF_POLICY_ON_BAT=powersave
DISK_DEVICES="sda sdb"
DISK_APM_LEVEL_ON_AC="254 254"
DISK_APM_LEVEL_ON_BAT="128 128"
SATA_LINKPWR_ON_AC=max_performance
SATA_LINKPWR_ON_BAT=min_power
AHCI_RUNTIME_PM_TIMEOUT=15
PCIE_ASPM_ON_AC=performance
PCIE_ASPM_ON_BAT=powersave
RADEON_POWER_PROFILE_ON_AC=high
RADEON_POWER_PROFILE_ON_BAT=low
RADEON_DPM_STATE_ON_AC=performance
RADEON_DPM_STATE_ON_BAT=battery
RADEON_DPM_PERF_LEVEL_ON_AC=auto
RADEON_DPM_PERF_LEVEL_ON_BAT=auto
WIFI_PWR_ON_AC=off
WIFI_PWR_ON_BAT=on
WOL_DISABLE=Y
SOUND_POWER_SAVE_ON_AC=0
SOUND_POWER_SAVE_ON_BAT=1
SOUND_POWER_SAVE_CONTROLLER=Y
BAY_POWEROFF_ON_AC=0
BAY_POWEROFF_ON_BAT=0
BAY_DEVICE="sr0"
RUNTIME_PM_ON_AC=on
RUNTIME_PM_ON_BAT=auto
USB_AUTOSUSPEND=1
USB_BLACKLIST_BTUSB=0
USB_BLACKLIST_PHONE=0
USB_BLACKLIST_WWAN=1
RESTORE_DEVICE_STATE_ON_STARTUP=0

+++ System Info
System        = Hewlett-Packard 0999200000200010000610101 HP 242 G2 Notebook PC
BIOS          = F.01
Release        = Ubuntu 17.10
Kernel        = 4.13.0-17-generic #20-Ubuntu SMP Mon Nov 6 10:04:08 UTC 2017 x86_64
/proc/cmdline  = BOOT_IMAGE=/vmlinuz-4.13.0-17-generic.efi.signed root=UUID=61bddbce-c91d-43e1-acd2-ae110433b841 ro quiet splash vt.handoff=7
Init system    = systemd v234
Boot mode      = UEFI

+++ TLP Status
State          = enabled
Last run      = unknown
Mode          = unknown
Power source  = AC

+++ Processor
CPU model      = Intel(R) Core(TM) i5-4200M CPU @ 2.50GHz

/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver    = intel_pstate
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor  = powersave
/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors = performance powersave
/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq  =  800000 [kHz]
/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq  =  3100000 [kHz]

/sys/devices/system/cpu/cpu1/cpufreq/scaling_driver    = intel_pstate
/sys/devices/system/cpu/cpu1/cpufreq/scaling_governor  = powersave
/sys/devices/system/cpu/cpu1/cpufreq/scaling_available_governors = performance powersave
/sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq  =  800000 [kHz]
/sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq  =  3100000 [kHz]

/sys/devices/system/cpu/cpu2/cpufreq/scaling_driver    = intel_pstate
/sys/devices/system/cpu/cpu2/cpufreq/scaling_governor  = powersave
/sys/devices/system/cpu/cpu2/cpufreq/scaling_available_governors = performance powersave
/sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq  =  800000 [kHz]
/sys/devices/system/cpu/cpu2/cpufreq/scaling_max_freq  =  3100000 [kHz]

/sys/devices/system/cpu/cpu3/cpufreq/scaling_driver    = intel_pstate
/sys/devices/system/cpu/cpu3/cpufreq/scaling_governor  = powersave
/sys/devices/system/cpu/cpu3/cpufreq/scaling_available_governors = performance powersave
/sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq  =  800000 [kHz]
/sys/devices/system/cpu/cpu3/cpufreq/scaling_max_freq  =  3100000 [kHz]

/sys/devices/system/cpu/intel_pstate/min_perf_pct      =  25 [%]
/sys/devices/system/cpu/intel_pstate/max_perf_pct      = 100 [%]
/sys/devices/system/cpu/intel_pstate/no_turbo          =  0
/sys/devices/system/cpu/intel_pstate/turbo_pct        =  25 [%]
/sys/devices/system/cpu/intel_pstate/num_pstates      =  24

x86_energy_perf_policy: program for your kernel not installed.

/sys/module/workqueue/parameters/power_efficient      = Y
/proc/sys/kernel/nmi_watchdog                          = 1

+++ Undervolting
PHC kernel not available.

+++ Temperatures
CPU temp              =    42 [°C]
Fan speed              = (not available)

+++ File System
/proc/sys/vm/laptop_mode              =    0
/proc/sys/vm/dirty_writeback_centisecs =  500
/proc/sys/vm/dirty_expire_centisecs    =  3000
/proc/sys/vm/dirty_ratio              =    20
/proc/sys/vm/dirty_background_ratio    =    10

+++ Storage Devices
/dev/sda:
  Model    = WDC WD1200BEVS-22UST0                 
  Firmware  = 01.01A01
  APM Level = 254
  Status    = active/idle
  Scheduler = cfq

  Runtime PM: control = on, autosuspend_delay =  -1

  SMART info:
      4 Start_Stop_Count          =    7307
      5 Reallocated_Sector_Ct    =        0
      9 Power_On_Hours            =    14093 [h]
    12 Power_Cycle_Count        =    6184
    193 Load_Cycle_Count          =  433570
    194 Temperature_Celsius      =      26    [°C]


+++ SATA Aggressive Link Power Management
/sys/class/scsi_host/host0/link_power_management_policy  = max_performance
/sys/class/scsi_host/host1/link_power_management_policy  = max_performance
/sys/class/scsi_host/host2/link_power_management_policy  = max_performance
/sys/class/scsi_host/host3/link_power_management_policy  = max_performance
/sys/class/scsi_host/host4/link_power_management_policy  = max_performance
/sys/class/scsi_host/host5/link_power_management_policy  = max_performance

+++ AHCI Host Controller Runtime Power Management
/sys/bus/pci/devices/0000:00:1f.2/ata1/power/control = on
/sys/bus/pci/devices/0000:00:1f.2/ata2/power/control = on
/sys/bus/pci/devices/0000:00:1f.2/ata3/power/control = on
/sys/bus/pci/devices/0000:00:1f.2/ata4/power/control = on
/sys/bus/pci/devices/0000:00:1f.2/ata5/power/control = on
/sys/bus/pci/devices/0000:00:1f.2/ata6/power/control = on

+++ PCIe Active State Power Management
/sys/module/pcie_aspm/parameters/policy = default (using bios preferences)

+++ Intel Graphics
/sys/module/i915/parameters/enable_rc6      =  1 (enabled)
/sys/module/i915/parameters/enable_dc        = -1 (use per-chip default)
/sys/module/i915/parameters/enable_fbc      =  0 (disabled)
/sys/module/i915/parameters/enable_psr      =  0 (disabled)
/sys/module/i915/parameters/modeset          = -1 (use per-chip default)
/sys/module/i915/parameters/semaphores      =  1 (enabled)

+++ Radeon Graphics
/sys/class/drm/card1/device/power_dpm_state = balanced
/sys/class/drm/card1/device/power_dpm_force_performance_level = off

+++ Wireless
bluetooth = none (no device)
wifi      = on
wwan      = none (no device)

wlo1(rt2800pci)              : wifi, connected, power management = on

+++ Audio
/sys/module/snd_hda_intel/parameters/power_save            = 0
/sys/module/snd_hda_intel/parameters/power_save_controller = Y

+++ Runtime Power Management
Device blacklist = (not configured)
Driver blacklist = amdgpu nouveau nvidia radeon (default)

/sys/bus/pci/devices/0000:00:00.0/power/control = on  (0x060000, Host bridge, no driver)
/sys/bus/pci/devices/0000:00:01.0/power/control = on  (0x060400, PCI bridge, pcieport)
/sys/bus/pci/devices/0000:00:02.0/power/control = on  (0x030000, VGA compatible controller, i915)
/sys/bus/pci/devices/0000:00:03.0/power/control = on  (0x040300, Audio device, snd_hda_intel)
/sys/bus/pci/devices/0000:00:14.0/power/control = on  (0x0c0330, USB controller, xhci_hcd)
/sys/bus/pci/devices/0000:00:16.0/power/control = on  (0x078000, Communication controller, mei_me)
/sys/bus/pci/devices/0000:00:1a.0/power/control = on  (0x0c0320, USB controller, ehci-pci)
/sys/bus/pci/devices/0000:00:1b.0/power/control = on  (0x040300, Audio device, snd_hda_intel)
/sys/bus/pci/devices/0000:00:1c.0/power/control = on  (0x060400, PCI bridge, pcieport)
/sys/bus/pci/devices/0000:00:1c.2/power/control = on  (0x060400, PCI bridge, pcieport)
/sys/bus/pci/devices/0000:00:1c.3/power/control = on  (0x060400, PCI bridge, pcieport)
/sys/bus/pci/devices/0000:00:1c.6/power/control = on  (0x060400, PCI bridge, pcieport)
/sys/bus/pci/devices/0000:00:1d.0/power/control = on  (0x0c0320, USB controller, ehci-pci)
/sys/bus/pci/devices/0000:00:1f.0/power/control = on  (0x060100, ISA bridge, lpc_ich)
/sys/bus/pci/devices/0000:00:1f.2/power/control = on  (0x010601, SATA controller, ahci)
/sys/bus/pci/devices/0000:00:1f.3/power/control = on  (0x0c0500, SMBus, no driver)
/sys/bus/pci/devices/0000:01:00.0/power/control = auto (0x038000, Display controller, radeon)
/sys/bus/pci/devices/0000:07:00.0/power/control = on  (0x028000, Network controller, rt2800pci)
/sys/bus/pci/devices/0000:07:00.1/power/control = on  (0x0d1100, Bluetooth, no driver)
/sys/bus/pci/devices/0000:09:00.0/power/control = on  (0xff0000, Unassigned class [ff00], rtsx_pci)
/sys/bus/pci/devices/0000:0f:00.0/power/control = on  (0x020000, Ethernet controller, r8169)

+++ USB
Autosuspend        = enabled
Device whitelist    = (not configured)
Device blacklist    = (not configured)
Bluetooth blacklist = disabled
Phone blacklist    = disabled
WWAN blacklist      = enabled

Bus 002 Device 002 ID 8087:8000 control = auto, autosuspend_delay_ms =    0 -- Intel Corp.  (hub)
Bus 002 Device 001 ID 1d6b:0002 control = auto, autosuspend_delay_ms =    0 -- Linux Foundation 2.0 root hub (hub)
Bus 001 Device 002 ID 8087:8008 control = auto, autosuspend_delay_ms =    0 -- Intel Corp.  (hub)
Bus 001 Device 001 ID 1d6b:0002 control = auto, autosuspend_delay_ms =    0 -- Linux Foundation 2.0 root hub (hub)
Bus 004 Device 001 ID 1d6b:0003 control = auto, autosuspend_delay_ms =    0 -- Linux Foundation 3.0 root hub (hub)
Bus 003 Device 003 ID 04f2:b40d control = auto, autosuspend_delay_ms =  2000 -- Chicony Electronics Co., Ltd  (uvcvideo)
Bus 003 Device 004 ID 058f:6366 control = on,  autosuspend_delay_ms =  2000 -- Alcor Micro Corp. Multi Flash Reader (usb-storage)
Bus 003 Device 002 ID 10c4:8105 control = on,  autosuspend_delay_ms =  2000 -- Cygnal Integrated Products, Inc.  (usbhid)
Bus 003 Device 001 ID 1d6b:0002 control = auto, autosuspend_delay_ms =    0 -- Linux Foundation 2.0 root hub (hub)

+++ Battery Status
/sys/class/power_supply/BAT0/manufacturer                  = Hewlett-Packard
/sys/class/power_supply/BAT0/model_name                    = Primary
/sys/class/power_supply/BAT0/cycle_count                    = (not supported)
/sys/class/power_supply/BAT0/charge_full_design            =  2599 [mAh]
/sys/class/power_supply/BAT0/charge_full                    =  2599 [mAh]
/sys/class/power_supply/BAT0/charge_now                    =  2599 [mAh]
/sys/class/power_supply/BAT0/current_now                    =      0 [mA]
/sys/class/power_supply/BAT0/status                        = Full

Charge                                                      =  100.0 [%]
Capacity                                                    =  100.0 [%]

linuxidc@linuxidc:~$

然後如果找到 

+++ System Status
TLP power save = enabled
power source  = ac

TLP power save = enabled #說明已經成功開啟

sudo tlp stat #顯示所有資訊和設定

sudo tlp stat -b #只顯示電池資訊 相當於 sudo tlp-stat --battery

sudo tlp stat -c #只顯示設定資訊  相當於 sudo tlp-stat --config

sudo tlp stat -r  #顯示無線裝置的狀態資訊 相當於 sudo tlp-stat -rfkill

sudo tlp stat -t #只顯示溫度和風扇轉速 相當於 sudo tlp-stat --temp

sudo tlp stat -T #顯示debug資訊  (/var/log/debug)

如果想要關閉TLP,  vi /etc/default/tlp  將其中的 "TLP_ENABLE=1" 改為 "TLP_ENABLE=0"即可.如果想要客製化更多的東西,也可以去設定這個檔案.

解除安裝:

要刪除tlp,請開啟終端並執行命令:

sudo apt-get remove --autoremove tlp

要刪除PPA,請啟動Software&Updates並導航到“其他軟體”索引標籤。

你覺得Linux公社(www.linuxidc.com)的這篇教學有用嗎?請與你的朋友分享。


IT145.com E-mail:sddin#qq.com