问题描述
我在Compaq 615上,它的粉丝响亮。你可以做的不多,但我试图保持CPU /GPU尽可能的酷。这就是Powertop所说的:
如果我将所有这些更改为”good”,则更改将无法在重新启动后继续存在。
我将行添加到“grub”文件中作为suggested here
如何使Powertop建议”Tunables”永久?
最佳解决思路
如果你将它们全部改为好,你可以简单地使用命令
sudo powertop --auto-tune
在启动时自动调用powertop auto-tune
1。
在使用systemd
作为启动管理器(如Ubuntu)的系统上,将其安装为服务:
cat << EOF | sudo tee /etc/systemd/system/powertop.service
[Unit]
Description=PowerTOP auto tune
[Service]
Type=idle
Environment="TERM=dumb"
ExecStart=/usr/sbin/powertop --auto-tune
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable powertop.service
2。
在不使用systemd
的系统上,或者如果要将旧样式与/etc/rc.local
文件一起使用,请将此行添加到/etc/rc.local
的末尾:
powertop --auto-tune
exit 0
注意:如果脚本已包含exit 0
,请确保将所有命令放在该行之前,因此退出脚本
如果你想将所有设置为良好但只需一行,你可以首先使用auto-tune,然后使用额外的行禁用一个设置,例如,如果你想要re-enable的touchscreen-device(在2-7),请在exit 0
之前添加:
powertop --auto-tune
echo 'on' > '/sys/bus/usb/devices/2-7/power/control'
exit 0
注意:在使用systemd
的Linux上,确保兼容服务在启动时执行/etc/rc.local
systemctl status rc-local.service
次佳解决思路
以下是如何使更改永久化:
sudo powertop --html
这将生成一个powertop-xxxxxxxxxx-xxxxxx.html
文件。
现在要么在浏览器中打开它,要么将“…需要调整”的echo
命令复制到/etc/rc.local
。
或者使用以下内容提取命令:
echo "grep 'echo ' powertop-20120805-125538.html | sed 's/.*\(echo.*\);.*/\1/g'"
如果rc.local
包含exit 0
,则需要确保将命令放在此行之前。
第三种解决思路
您需要下载并编译它,因为没有人拥有最新版本
下载powertop https://01.org/powertop/downloads/2013/powertop-v2.3
powertop-2.3.tar.gz< < <点击&下载我
在编译之前,您需要安装依赖项
安装依赖项(只需复制粘贴以下命令)
sudo apt-get install libtool autoconf libnl-dev ncurses-dev pciutils-dev build-essential -y
安装Powertop
要构建和安装PowerTOP,请键入以下命令:
cd Downloads/powertop* # assuming that you have downloaded in Downloads folder in you home directory
configure
make # use -j option if you want to see details below
make install
您还可以使用-j2表示要在./make.Replace -j2中使用的核心数,以及要用于编译过程的任何数量的CPU核心。例如,我使用过./make -j8
Powertop已安装,您可以拔掉交流电源并可以运行
sudo powertop
但是,大多数设置都不会保存,重启后会丢失。但是,您可以使用PowerTOP html报告中提供的命令使它们永久化。要生成HTML报告,请运行以下命令:webupd8.org
sudo powertop --html=powertop.html
在电池上实施Powertop建议并返回以最大化AC电源的性能
为此,您需要制作一个脚本,对电池运行powertop建议,并最大限度地提高交流电源的性能
Place it in /etc/pm/power.d/ and give execution rights
sudo gedit /etc/pm/power.d/power
复制粘贴以下电源文件中的以下内容
#!/bin/sh
# Shell script to reduce energy consumption when running battery. Place
# it in /etc/pm/power.d/ and give execution rights.
if on_ac_power; then
# Start AC powered settings --------------------------------------------#
# Disable laptop mode
echo 0 > /proc/sys/vm/laptop_mode
#NMI watchdog should be turned on
for foo in /proc/sys/kernel/nmi_watchdog;
do echo 1 > $foo;
done
# Set SATA channel: max performance
for foo in /sys/class/scsi_host/host*/link_power_management_policy;
do echo max_performance > $foo;
done
# CPU Governor: Performance
for foo in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor;
do echo performance > $foo;
done
# Disable USB autosuspend
for foo in /sys/bus/usb/devices/*/power/level;
do echo on > $foo;
done
# Disable PCI autosuspend
for foo in /sys/bus/pci/devices/*/power/control;
do echo on > $foo;
done
# Disabile audio_card power saving
echo 0 > /sys/module/snd_hda_intel/parameters/power_save_controller
echo 0 > /sys/module/snd_hda_intel/parameters/power_save
# End AC powered settings ----------------------------------------------#
else
# Start battery powered settings ---------------------------------------#
# Enable Laptop-Mode disk writing
echo 5 > /proc/sys/vm/laptop_mode
#NMI watchdog should be turned on
for foo in /proc/sys/kernel/nmi_watchdog;
do echo 0 > $foo;
done
# Set SATA channel to power saving
for foo in /sys/class/scsi_host/host*/link_power_management_policy;
do echo min_power > $foo;
done
# Select Ondemand CPU Governor
for foo in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor;
do echo ondemand > $foo;
done
# Activate USB autosuspend
for foo in /sys/bus/usb/devices/*/power/level;
do echo auto > $foo;
done
# Activate PCI autosuspend
for foo in /sys/bus/pci/devices/*/power/control;
do echo auto > $foo;
done
# Activate audio card power saving
# (sounds shorter than 5 seconds will not be played)
echo 5 > /sys/module/snd_hda_intel/parameters/power_save
echo 1 > /sys/module/snd_hda_intel/parameters/power_save_controller
# End battery powered settings -----------------------------------------#
fi
现在您需要分配电源脚本的执行权限
sudo chmod +x /etc/pm/power.d/power
现在当你拔掉电源插头时,Powertop建议将接管并最大化电池续航时间。你插入交流电源就可以获得Max Performance。
有用的链接
http://ubuntuforums.org/showthread.php?t=1855126&page=3 http://www.webupd8.org/2012/08/install-powertop-21-in-ubuntu-1204.html
对于-j选项http://dnscrypt.org/
第四种思路
这不是您要求的答案,但您可以尝试在laptop-mode
中运行。去做这个:
open a terminal and type:
gksu gedit /etc/default/acpi-support
enter password and then go to the bottom and in the section where it talks about laptop-mode write true instead of false, close document and save of course
Then enter:
gksu gedit /etc/laptop-mode/laptop-mode.conf
this file is a bit longer, but here is how I edited mine. I added # before the default line on those line I modified, like this:
# # Should laptop mode tools add the "noatime" option to the mount options when # laptop mode is enabled? # #CONTROL_NOATIME=0 CONTROL_NOATIME=1
the default was 0 and I turned it to 1, modify only the lines I modified. There are a few options in here you’ll want to review and toggle as you see fit. When you’re close and save.
After this is done you will want to type:
gksu gedit
now in the text editor click open and go into /etc/laptop-mode/conf.d/ folder, there are various files, you probably are interested in usb autosuspend, hda audio, iwl intel wireless, intel sata and sched mc powersaving. Open these files one by one and read them, they’re written in a perfect standard english and explain everything very well. You will know what to do, remember that 0 stands for off and 1 for on most of the time.
When you’re done close and save each file.
Now restart and admire laptop-mode in action, then:
sudo powertop
and examine power consumption, if you’ve done everything correctly powertop won’t have any addition suggestion to make because you’ve tweaked all there is to tweak (more or less).
资料来源:http://ubuntuforums.org/showthread.php?t=1157408&p=7271995#post7271995(Axx83)
第五种思路
使用udev规则直接在源上配置设置,而不是创建脚本或依赖可能未安装的软件包。因此,只要udev
添加了硬件,就会应用您的设置。
正确的udev
规则使得当硬件不存在时设置不适用,从而使配置更加便携。并且您将了解有关Linux内核内部工作原理的更多信息:-)。采用这种方式配置,也适用于不使用电池运行时。
可调谐Enable SATA link power Managmenet for host0
的示例。建议是:
# echo 'min_power' > '/sys/class/scsi_host/host0/link_power_management_policy'`
这已经让您了解硬件的位置:in /sys /class /scsi_host。您可以通过以下方式验证:
# udevadm info -a -p /sys/class/scsi_host/host?
…
looking at device '/devices/pci0000:00/0000:00:1f.2/ata1/host0/scsi_host/host0':
KERNEL=="host0"
SUBSYSTEM=="scsi_host"
…
ATTR{eh_deadline}=="0"
ATTR{link_power_management_policy}=="max_performance"
ATTR{host_busy}=="0"
最好不要触及/lib/udev/rules.d/中的系统udev规则,并在/etc/udev/rules.d/中创建自己的udev规则文件,大致为60级。例如使用nano编辑器:
$ nano /etc/udev/rules.d/60-power.rules
其他一些例子写下如下规则:
KERNEL=="host[0-5]", SUBSYSTEM=="scsi_host", ATTR{link_power_management_policy}="min_power"
我会说,当链接电源管理策略设置为max_performance时,仅应用它,并使您的规则更好。看看差别很小(寻找双方程符号):
KERNEL=="host[0-5]", SUBSYSTEM=="scsi_host", ATTR{link_power_management_policy}=="max_performance", ATTR{link_power_management_policy}="min_power"
使用udevadm test /devices/…
测试您的规则:
# udevadm test /devices/pci0000:00/0000:00:1f.2/ata1/host0/scsi_host/host0/link_power_management_policy
calling: test
version 204
This program is for debugging only, it does not run any program
specified by a RUN key. It may show incorrect results, because
some values may be different, or not available at a simulation run.
=== trie on-disk ===
tool version: 204
file size: 5660180 bytes
header size 80 bytes
strings 1265196 bytes
nodes 4394904 bytes
load module index
read rules file: /lib/udev/rules.d/40-crda.rules
read rules file: /lib/udev/rules.d/40-gnupg.rules
read rules file: /lib/udev/rules.d/40-hyperv-hotadd.rules
read rules file: /lib/udev/rules.d/42-usb-hid-pm.rules
read rules file: /lib/udev/rules.d/50-firmware.rules
read rules file: /lib/udev/rules.d/50-udev-default.rules
read rules file: /lib/udev/rules.d/55-dm.rules
read rules file: /lib/udev/rules.d/60-cdrom_id.rules
read rules file: /lib/udev/rules.d/60-keyboard.rules
read rules file: /lib/udev/rules.d/60-persistent-alsa.rules
read rules file: /lib/udev/rules.d/60-persistent-input.rules
read rules file: /lib/udev/rules.d/60-persistent-serial.rules
read rules file: /lib/udev/rules.d/60-persistent-storage-dm.rules
read rules file: /lib/udev/rules.d/60-persistent-storage-tape.rules
read rules file: /lib/udev/rules.d/60-persistent-storage.rules
read rules file: /lib/udev/rules.d/60-persistent-v4l.rules
read rules file: /etc/udev/rules.d/60-power.rules
read rules file: /lib/udev/rules.d/61-accelerometer.rules
read rules file: /lib/udev/rules.d/64-btrfs.rules
read rules file: /etc/udev/rules.d/70-persistent-net.rules
read rules file: /lib/udev/rules.d/70-power-switch.rules
read rules file: /lib/udev/rules.d/70-uaccess.rules
read rules file: /lib/udev/rules.d/71-biosdevname.rules
read rules file: /lib/udev/rules.d/71-seat.rules
read rules file: /lib/udev/rules.d/73-idrac.rules
read rules file: /lib/udev/rules.d/73-seat-late.rules
read rules file: /lib/udev/rules.d/75-net-description.rules
read rules file: /lib/udev/rules.d/75-persistent-net-generator.rules
read rules file: /lib/udev/rules.d/75-probe_mtd.rules
read rules file: /lib/udev/rules.d/75-tty-description.rules
read rules file: /lib/udev/rules.d/78-graphics-card.rules
read rules file: /lib/udev/rules.d/78-sound-card.rules
read rules file: /lib/udev/rules.d/80-drivers.rules
read rules file: /lib/udev/rules.d/85-hdparm.rules
read rules file: /lib/udev/rules.d/85-keyboard-configuration.rules
read rules file: /lib/udev/rules.d/85-regulatory.rules
read rules file: /lib/udev/rules.d/95-udev-late.rules
rules contain 24576 bytes tokens (2048 * 12 bytes), 11335 bytes strings
1814 strings (22027 bytes), 1179 de-duplicated (11328 bytes), 636 trie nodes used
ATTR '/sys/devices/pci0000:00/0000:00:1f.2/ata1/host0/scsi_host/host0/link_power_management_policy' writing 'min_power' /etc/udev/rules.d/60-power.rules:1
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:1f.2/ata1/host0/scsi_host/host0
SUBSYSTEM=scsi_host
USEC_INITIALIZED=1203444595
unload module index
我找不到应用规则的方法,所以在这种情况下我重新启动以应用新创建的udev规则。
第六种思路
我通过创建一个破折号脚本/root/power_save.sh
来解决这个问题:
#!/bin/dash
find /sys/devices/pci* -path "*power/control" -exec bash -c "echo auto > '{}'" \;
将其设置为可执行:
sudo chmod u+x /root/power_save.sh
并使用sudo crontab -e
将其添加到root crontab:
@reboot /root/power_save.sh
第七种思路
这个链接谈论同样的问题是:
https://bbs.archlinux.org/viewtopic.php?pid=860406
我自己对解决方案感兴趣,稍后会尝试。告诉我如果您能够设法实施此解决方案。
我无法让它运行,因为系统总是告诉我拒绝运行可执行文件的权限。
然而,这似乎工作:
http://philatwarrimoo.blogspot.com/2011/06/powertop-howto-enable-device-power.html
我使用short命令并使用sudo运行它。
作为半自动解决方案,我创建了一个启动器:
脚本如下:
有没有办法阻止要求我的密码?