加载中...

电源管理 - PowerTOP


完全用 GNU/Linux 工作

08. 电源管理 - PowerTOP

PowerTOP 是个分析、监控电力消秏的节能工具程式,它是由 Intel 于 2007 年以 GPLv2 授权释出的开放原始码专案。我们可以使用它找出 GNU/Linux 上秏电的套件,并透过停用不必要的功能以达到省电的效果,是笔记型电脑 (Laptop) 必装的实用工具。

2013-09-25-powertop-01.png

▲ PowerTOP 的起始画面。

开始前请先安装 powertop。

  1. # Debian, Ubuntu
  2. $ sudo aptitude install powertop
  3. # CentOS, RHEL, Fedora
  4. $ sudo yum install powertop
  5. # Arch Linux
  6. $ sudo pacman -S powertop

请使用方向键 ← → 切换至 Tunables 分页,并使用 ↑ ↓ 上下移动,于欲调校的项目按下 Enter 进行调校,当所有状态显示为 Good 后即可按下 q 离开。2013-09-25-powertop-02.png

▲ 调校前的 Tunables

2013-09-25-powertop-03.png

▲ 调校后的 Tunables

PowerTOP 本身并无储存功能,但我们可以借由 powertop '--html' 产生的报告来调校系统,甚至于开机时加载这些设定。

  1. $ sudo powertop --html
  2. Loaded 58 prior measurements
  3. Cannot load from file /var/cache/powertop/saved_parameters.powertop
  4. Preparing to take measurements
  5. Measuring 1 time(s) for 20 seconds each
  6. PowerTOP outputing using base filename powertop-20130915-231821.html

2013-09-25-powertop-04.png

▲ 此报告将依个人环境而有所不同,其各项目的详细说明可参考 Power saving - ArchWiki 一文。

接着将调校的指令贴到一个 shell script 打包起来。

  1. $ sudo vi /usr/local/bin/powersave
  2. #!/bin/bash
  3. # PowerTop conifg for ThinkPad T410 on Debian Wheezy.
  4. # Wireless Power Saving for interface wlan0
  5. iw dev wlan0 set power_save off
  6. # Enable SATA link power management for /dev/sda
  7. echo 'min_power' > '/sys/class/scsi_host/host0/link_power_management_policy';
  8. # NMI watchdog should be turned off
  9. echo '0' > '/proc/sys/kernel/nmi_watchdog';
  10. # VM writeback timeout
  11. echo '1500' > '/proc/sys/vm/dirty_writeback_centisecs';
  12. # Enable Audio codec power management
  13. echo '1' > '/sys/module/snd_hda_intel/parameters/power_save';
  14. # Autosuspend for USB device Biometric Coprocessor [UPEK]
  15. echo 'auto' > '/sys/bus/usb/devices/1-1.3/power/control';
  16. # Runtime PM for PCI Device Ricoh Co Ltd MMC/SD Host Controller
  17. echo 'auto' > '/sys/bus/pci/devices/0000:0d:00.0/power/control';
  18. # Runtime PM for PCI Device Intel Corporation Core Processor PCI Express x16 Root Port
  19. echo 'auto' > '/sys/bus/pci/devices/0000:00:01.0/power/control';
  20. # Runtime PM for PCI Device Intel Corporation 82577LM Gigabit Network Connection
  21. echo 'auto' > '/sys/bus/pci/devices/0000:00:19.0/power/control';
  22. # Runtime PM for PCI Device Intel Corporation 5 Series/3400 Series Chipset USB2 Enhanced Host Controller
  23. echo 'auto' > '/sys/bus/pci/devices/0000:00:1a.0/power/control';
  24. # Runtime PM for PCI Device Intel Corporation 5 Series/3400 Series Chipset High Definition Audio
  25. echo 'auto' > '/sys/bus/pci/devices/0000:00:1b.0/power/control';
  26. # Runtime PM for PCI Device Intel Corporation 5 Series/3400 Series Chipset PCI Express Root Port 4
  27. echo 'auto' > '/sys/bus/pci/devices/0000:00:1c.3/power/control';
  28. # Runtime PM for PCI Device Ricoh Co Ltd R5C832 PCIe IEEE 1394 Controller
  29. echo 'auto' > '/sys/bus/pci/devices/0000:0d:00.3/power/control';
  30. # Runtime PM for PCI Device Intel Corporation Centrino Wireless-N 1000 [Condor Peak]
  31. echo 'auto' > '/sys/bus/pci/devices/0000:03:00.0/power/control';
  32. # Runtime PM for PCI Device Intel Corporation 5 Series/3400 Series Chipset SMBus Controller
  33. echo 'auto' > '/sys/bus/pci/devices/0000:00:1f.3/power/control';
  34. # Runtime PM for PCI Device Intel Corporation 5 Series/3400 Series Chipset Thermal Subsystem
  35. echo 'auto' > '/sys/bus/pci/devices/0000:00:1f.6/power/control';
  36. # Runtime PM for PCI Device Intel Corporation 5 Series/3400 Series Chipset 6 port SATA AHCI Controller
  37. echo 'auto' > '/sys/bus/pci/devices/0000:00:1f.2/power/control';
  38. # Runtime PM for PCI Device NVIDIA Corporation GT218 [NVS 3100M]
  39. echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/power/control';
  40. # Runtime PM for PCI Device Intel Corporation 5 Series/3400 Series Chipset USB2 Enhanced Host Controller
  41. echo 'auto' > '/sys/bus/pci/devices/0000:00:1d.0/power/control';
  42. # Runtime PM for PCI Device Intel Corporation 5 Series/3400 Series Chipset PCI Express Root Port 1
  43. echo 'auto' > '/sys/bus/pci/devices/0000:00:1c.0/power/control';
  44. # Runtime PM for PCI Device Intel Corporation 5 Series/3400 Series Chipset PCI Express Root Port 5
  45. echo 'auto' > '/sys/bus/pci/devices/0000:00:1c.4/power/control';
  46. # Runtime PM for PCI Device NVIDIA Corporation High Definition Audio Controller
  47. echo 'auto' > '/sys/bus/pci/devices/0000:01:00.1/power/control';
  48. # Runtime PM for PCI Device Intel Corporation 5 Series/3400 Series Chipset PCI Express Root Port 2
  49. echo 'auto' > '/sys/bus/pci/devices/0000:00:1c.1/power/control';
  50. # Wake-on-lan status for device eth0
  51. #ethtool -s eth0 wol d;

给予执行权限。

  1. $ sudo chmod +x /usr/local/bin/powersave

因调校指令皆需管理者权限才可执行,若想省下打密码的功夫可参考 Firestarter 开机甭再次输入密码 一文修改。

  1. $ sudo visudo
  2. ......
  3. jonny ALL= NOPASSWD:/usr/local/bin/powersave

现在开机时只需使用 sudo powersave 即可手动切换至省电模式

若想加入开机自动启动可以参考 安装 indicator-virtualbox on Ubuntu 12.04 | 4. 加入开机自动启动 一文或使用较进阶的 udev 及 sysctl。

※ 注:请依个人需求自行调整,若造成系统不稳还请自行斟酌。

资料来源

  • PowerTOP - Wikipedia
  • Powertop - ArchWiki
  • 2.2. PowerTOP - Red Hat Customer Portal
  • 冷静: Powertop

还没有评论.