ArchLinux 的CPU和显卡的节能设置

默认下Arch Linux系统是没有开启电源节能功能,CPU和显卡(指独立显卡,下同)以最大性能运行,而作为家用或者办公用计算机并不总需要最大性能,所以这会造成一定的能源浪费。本文目标有:

查看系统硬件的温度、电压和风扇转速等状态信息。 打开CPU的节能功能。 打开显卡的节能功能。 1、安装 Linux-monitoring sensors (lm_sensors)

这是一个 Linux 下的开源工具,用于监控系统硬件的温度、电压、风扇转速等状态信息。首先安装它:

$ sudo pacman -S lm_sensors

安装完毕之后要进行一次硬件探测:

$ sudo sensors-detect

程序会询问很多问题,一般情况下一路按回车直至完成即可。

现在可以手动启动 lm_sensors 的守护程序:

$ sudo /etc/rc.d/sensors start

然后运行 sensors 显示硬件状态信息:

$ sensors

(注意,上面的 sensors 是一个程序,而 /etc/rc.d/sensors 是一个守护程序控制脚本。)

没问题的话应该可以看到诸如系统温度、显卡温度、CPU电压和温度、风扇转速等信息,大致如下:

k10temp-pci-00c3Adapter: PCI adaptertemp1: +38.9°C (high = +70.0°C)(crit = +72.0°C, hyst = +70.0°C)radeon-pci-0100Adapter: PCI adaptertemp1: +53.0°Cit8718-isa-0228Adapter: ISA adapterin0: +1.14 V (min = +0.00 V, max = +4.08 V)in1: +1.60 V (min = +0.00 V, max = +4.08 V)in2: +3.28 V (min = +0.00 V, max = +4.08 V)+5V: +3.02 V (min = +0.00 V, max = +4.08 V)in4: +3.09 V (min = +0.00 V, max = +4.08 V)in5: +3.30 V (min = +0.00 V, max = +4.08 V)in6: +4.08 V (min = +0.00 V, max = +4.08 V)in7: +2.11 V (min = +0.00 V, max = +4.08 V)Vbat: +3.14 Vfan1: 1717 RPM (min = 10 RPM)fan2: 0 RPM (min = 0 RPM)fan3: 0 RPM (min = 0 RPM)fan5: 0 RPM (min = 0 RPM)temp1: +47.0°C (low = +127.0°C, high = +127.0°C) sensor = thermistortemp2: +42.0°C (low = +127.0°C, high = +70.0°C) sensor = thermal diodetemp3: +46.0°C (low = +127.0°C, high = +127.0°C) sensor = thermistorcpu0_vid: +1.050 V

上面数据当中的 +53.0°C 是显卡温度,最后的三个温度应该是CPU相关温度,因为下面准备打开显卡和CPU的节能功能,为了对比效果,可以用笔记下这两项。

最后别忘了将 lm_sensors 守护程序加入 rc.conf ,让系统启动时自动运行。即编辑 /etc/rc.conf 文件,在DAEMONS后面加上“sensors”,如下:

DAEMONS=(syslog-ng dbus networkmanager sensors)

2、打开CPU频率动态调节功能

现在新产的CPU和主板一般支持CPU频率动态调节功能,我们可以通过让系统在任务轻松时降低CPU频率以达到节能目的。这个功能可能叫作“Speedstep, Cool and Quiet, PowerNow!, ACPI.” 等,要先在BIOS里打开此项功能(我的主板是技嘉AMD主板,对应的名称是“Cool and Quiet”)。

然后安装CPU频率调节工具:

$ sudo pacman -S cpufrequtils

下面我们需要载入频率调节的内核模块(驱动),通过下面命令可以查看有哪些内核可用:

$ -r)/kernel/drivers/cpufreq/

对于 intel CPU 可以尝试:

$ sudo modprobe acpi-cpufreq

对于 AMD CPU 可以尝试:

$ sudo modprobe powernow-k8

假如有错误可以试试。

一旦载入成功,可以使用 cpufreq-info 命令查看当前CPU状态:

$ cpufreq-info

结果大致如下:

cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009Report errors and bugs to cpufreq@vger.kernel.org, please.analyzing CPU 0:driver: powernow-k8CPUs which run at the same hardware frequency: 0CPUs which need to have their frequency coordinated by software: 0maximum transition latency: 8.0 us.hardware limits: 800 MHz – 2.80 GHzavailable frequency steps: 2.80 GHz, 2.10 GHz, 1.60 GHz, 800 MHzavailable cpufreq governors: ondemand, conservative, userspace, powersave, performancecurrent policy: frequency should be within 800 MHz and 2.80 GHz.The governor “ondemand” may decide which speed to usewithin this range.current CPU frequency is 800 MHz.

上面的数据列出每个CPU(或者核心)的最小和最大频率、可选的频率、当前工作频率以及调速器(Scaling governors)等信息。

其中调速器(Scaling governors)有如下几种:

cpufreq_performance (默认,最大性能) cpufreq_ondemand (推荐,按需调节) cpufreq_conservative (也是按需调节,不过较为保守) cpufreq_powersave (最低频率,节能模式) cpufreq_userspace (手动模式)

注意调速器也是内核模块,需要先载入才能使用。比如:

$ sudo modprobe cpufreq_ondemand

然后更改各个CPU(或核心)选用的调速器(默认是最大性能):

$ ondemand$ ondemand$ ondemand$ ondemand

现在你可以再次运行 cpufreq-info 查看CPU的当前频率和调速器是否正确,过1、2分钟之后再次运行 sensors 查看CPU温度是否有所下降。如果都是的话,则可以把加载的内核模块名称添加到 rc.conf 的 MODULES 一行让系统启动时自动载入,大致如下:

MODULES=(vboxdrv vboxnetflt powernow-k8 cpufreq_ondemand)

最后,因为 cpufreq-set 程序的作用在系统重启后会自动消失,所以需要将掌管它的守护程序 cpufreq 写入到 rc.conf 的 DAEMONS 里,大致如下:

DAEMONS=(syslog-ng dbus networkmanager sensors @cpufreq)

然后修改配置文件 /etc/conf.d/cpufreq,去掉 governor=”ondemand” 一行的注释,,内容大致如下:

家!甜蜜的家!天下最美好的莫过於家

ArchLinux 的CPU和显卡的节能设置

相关文章:

你感兴趣的文章:

标签云: