无法在 systemd 启动时设置电源调整参数

无法在 systemd 启动时设置电源调整参数

我在笔记本电脑上使用 Fedora 30。我尝试使用 powertop (powertop.service) 附带的 systemd 服务设置电源调整参数,但没有成功。然后,我尝试创建一个 shell 脚本以及一个自定义 .service 文件以在启动时运行它,但这也不起作用,在使用 powertop 重新启动后检查参数显示它们没有被更改。登录后运行脚本即可。

自定义脚本“/root/bin/powertune-HPEnvy.sh”

#!/bin/sh
 echo '1' > '/sys/module/snd_hda_intel/parameters/power_save'; 
 echo 'auto' > '/sys/bus/i2c/devices/i2c-0/device/power/control'; 
 echo 'auto' > '/sys/bus/i2c/devices/i2c-2/device/power/control'; 
 echo 'auto' > '/sys/bus/i2c/devices/i2c-6/device/power/control'; 
 echo 'auto' > '/sys/bus/i2c/devices/i2c-1/device/power/control'; 
 echo 'auto' > '/sys/bus/pci/devices/0000:02:00.0/power/control'; 
 echo 'auto' > '/sys/bus/pci/devices/0000:00:1f.2/power/control'; 
 echo 'auto' > '/sys/bus/pci/devices/0000:00:14.0/power/control'; 
 echo 'auto' > '/sys/bus/pci/devices/0000:00:08.0/power/control'; 
 echo 'auto' > '/sys/bus/pci/devices/0000:00:1f.0/power/control'; 
 echo 'auto' > '/sys/bus/pci/devices/0000:00:15.0/power/control'; 
 echo 'auto' > '/sys/bus/pci/devices/0000:00:1f.4/power/control'; 
 echo 'auto' > '/sys/bus/pci/devices/0000:00:00.0/power/control'; 
 echo 'auto' > '/sys/bus/pci/devices/0000:00:1f.3/power/control'; 
 echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/power/control'; 
 echo 'auto' > '/sys/bus/pci/devices/0000:00:15.1/power/control'; 
 echo 'auto' > '/sys/bus/pci/devices/0000:00:02.0/power/control'; 
 echo 'auto' > '/sys/bus/pci/devices/0000:00:14.2/power/control'; 
 echo 'auto' > '/sys/bus/pci/devices/0000:00:04.0/power/control'; 
 echo 'auto' > '/sys/bus/pci/devices/0000:00:17.0/power/control'; 




 echo 'enabled' > '/sys/class/net/wlp1s0/device/power/wakeup'; 
 echo 'enabled' > '/sys/bus/usb/devices/usb1/power/wakeup'; 
 echo 'enabled' > '/sys/bus/usb/devices/usb2/power/wakeup'; 

自定义 systemd 服务'/etc/systemd/system/powertune-HPEnvy.service'

[Unit]
Description=Set HP Envy 15-as133cl powersaving

[Service]
Type=oneshot
ExecStart=/root/bin/powertune-HPEnvy.sh


[Install]
WantedBy=multi-user.target

答案1

我已经通过改变让它工作了

WantedBy=multi-user.target 

WantedBy=basic.target

然后将 a 添加sleep 10到 shell 脚本的开头,然后禁用/重新启用 systemd 服务。现在重新启动后,脚本就会生效。

相关内容