add script(s) and service for powertop

This commit is contained in:
Daniel Sommer 2024-10-01 15:57:03 +02:00
parent 88ef0ad3ac
commit cf352f1062
4 changed files with 1107 additions and 0 deletions

76
scripts/powertop/n100.sh Executable file
View file

@ -0,0 +1,76 @@
#!/usr/bin/env zsh
# author: Daniel Sommer <daniel.sommer@velvettear.de>
# license: MIt
echo 'med_power_with_dipm' > '/sys/class/scsi_host/host0/link_power_management_policy';
echo 'med_power_with_dipm' > '/sys/class/scsi_host/host17/link_power_management_policy';
echo 'med_power_with_dipm' > '/sys/class/scsi_host/host18/link_power_management_policy';
echo '0' > '/proc/sys/kernel/nmi_watchdog';
echo 'med_power_with_dipm' > '/sys/class/scsi_host/host16/link_power_management_policy';
echo '1500' > '/proc/sys/vm/dirty_writeback_centisecs';
echo 'med_power_with_dipm' > '/sys/class/scsi_host/host15/link_power_management_policy';
echo 'med_power_with_dipm' > '/sys/class/scsi_host/host9/link_power_management_policy';
echo 'med_power_with_dipm' > '/sys/class/scsi_host/host13/link_power_management_policy';
echo 'med_power_with_dipm' > '/sys/class/scsi_host/host7/link_power_management_policy';
echo 'med_power_with_dipm' > '/sys/class/scsi_host/host11/link_power_management_policy';
echo 'med_power_with_dipm' > '/sys/class/scsi_host/host5/link_power_management_policy';
echo 'med_power_with_dipm' > '/sys/class/scsi_host/host3/link_power_management_policy';
echo 'med_power_with_dipm' > '/sys/class/scsi_host/host1/link_power_management_policy';
echo 'med_power_with_dipm' > '/sys/class/scsi_host/host14/link_power_management_policy';
echo 'med_power_with_dipm' > '/sys/class/scsi_host/host24/link_power_management_policy';
echo 'med_power_with_dipm' > '/sys/class/scsi_host/host8/link_power_management_policy';
echo 'med_power_with_dipm' > '/sys/class/scsi_host/host12/link_power_management_policy';
echo 'med_power_with_dipm' > '/sys/class/scsi_host/host21/link_power_management_policy';
echo 'med_power_with_dipm' > '/sys/class/scsi_host/host22/link_power_management_policy';
echo 'med_power_with_dipm' > '/sys/class/scsi_host/host6/link_power_management_policy';
echo 'med_power_with_dipm' > '/sys/class/scsi_host/host10/link_power_management_policy';
echo 'med_power_with_dipm' > '/sys/class/scsi_host/host20/link_power_management_policy';
echo 'med_power_with_dipm' > '/sys/class/scsi_host/host23/link_power_management_policy';
echo 'med_power_with_dipm' > '/sys/class/scsi_host/host4/link_power_management_policy';
echo 'med_power_with_dipm' > '/sys/class/scsi_host/host19/link_power_management_policy';
echo 'med_power_with_dipm' > '/sys/class/scsi_host/host2/link_power_management_policy';
echo 'med_power_with_dipm' > '/sys/class/scsi_host/host25/link_power_management_policy';
echo 'auto' > '/sys/bus/usb/devices/3-7.3/power/control';
echo 'auto' > '/sys/bus/usb/devices/3-4/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/ata18/power/control';
echo 'auto' > '/sys/block/sda/device/power/control';
echo 'auto' > '/sys/block/sdb/device/power/control';
echo 'auto' > '/sys/block/sdc/device/power/control';
echo 'auto' > '/sys/block/sdd/device/power/control';
echo 'auto' > '/sys/block/sde/device/power/control';
echo 'auto' > '/sys/block/sdf/device/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:00:17.0/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:00:17.0/ata1/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:00:1f.0/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/ata16/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/ata17/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/ata15/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/ata19/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/ata14/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:02:00.0/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/ata12/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/ata13/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/ata10/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/ata11/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:00:17.0/ata2/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/ata24/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/ata25/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:04:00.0/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/ata3/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/ata4/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:03:00.0/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/ata7/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/ata8/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/ata9/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/ata5/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/ata26/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/ata22/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/ata23/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/ata20/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/ata21/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:00:1f.5/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:00:14.2/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:01:00.0/ata6/power/control';
echo 'auto' > '/sys/bus/pci/devices/0000:00:00.0/power/control';

File diff suppressed because one or more lines are too long

18
scripts/powertop/powertop.sh Executable file
View file

@ -0,0 +1,18 @@
#!/usr/bin/env zsh
# author: Daniel Sommer <daniel.sommer@velvettear.de>
# license: MIT
# exit on error
set -e
# check permissions
[[ "$EUID" != 0 ]] && printf "error: permission denied!\n" >&2 && exit 1
# check if script exists
script="$(dirname $(realpath "$0"))/$(hostname).sh"
[[ ! -x "$script" ]] && printf "error: script '"$script"' does not exist or is not executable!\n" >&2 && exit 1
# execute script
printf ">> executing script '"$script"'...\n"
. "$script"

9
systemd/powertop.service Normal file
View file

@ -0,0 +1,9 @@
[Unit]
Description=enable various powersaving modes
[Service]
Type=oneshot
ExecStart=/home/velvettear/.dots/scripts/powertop/powertop.sh
[Install]
WantedBy=multi-user.target