Skip to content

Instantly share code, notes, and snippets.

@andrebrait
Last active October 23, 2025 02:42
Show Gist options
  • Save andrebrait/20a83d5de2c8d149a38156c32ac4f2cf to your computer and use it in GitHub Desktop.
Save andrebrait/20a83d5de2c8d149a38156c32ac4f2cf to your computer and use it in GitHub Desktop.
Enable Power-saving features for Intel-based servers running Linux
# This enabled the power settings present in the script
# >> Skip this file for unRAID, since it does not use systemd <<
# Put this file in /etc/systemd/system/power.service
# Then manually run it, 'systemctl start power'
# Check the output with 'systemctl status power'
# Then enable it with 'systemctl enable power'
[Unit]
Description=Power saving script
[Service]
Type=idle
Environment="TERM=dumb"
ExecStart=/opt/power/apply.sh
[Install]
WantedBy=multi-user.target
#!/usr/bin/env bash
# This prevents the freeze with the message 'e1000e eno1: Detected Hardware Unit Hang'
# For Proxmox VE:
# 1. Run 'mkdir -p /opt/power'
# 2. Put this file in /opt/power/apply.sh
# 3. Then run 'chmod +x /opt/power/apply.sh'
# For unRAID:
# 1. Install the 'User Scripts' plugin
# 2. Create a new script and paste the contents of this file in it
# 3. Set it to run at first array startup only
# 4. Apply
# 5. Reboot, or use the 'RUN SCRIPT' button
#!/usr/bin/env bash
# Enable power management of interfaces -- requires powertop, but it works very nicely
# powertop --auto-tune
# (OPTIONAL) set all PCIe devices to use ASPM L1 and sub-states
#PCIE_POLICY_FILE=/sys/module/pcie_aspm/parameters/policy
#PCIE_POLICY_OPTION=powersupersave
#if [ -f $PCIE_POLICY_FILE ]; then
# if grep -q $PCIE_POLICY_OPTION $PCIE_POLICY_FILE; then
# echo $PCIE_POLICY_OPTION > $PCIE_POLICY_FILE
# else
# echo "Option $PCIE_POLICY_OPTION cannot be applied to $PCIE_POLICY_FILE"
# fi
#else
# echo "File $PCIE_POLICY_FILE does not exist. Skipping this"
#fi
# Set the power governor to powersave
echo powersave | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
# Enable all hints for the governor to tell it to optimize for power (but not all the way)
echo balance_power | tee /sys/devices/system/cpu/cpu*/cpufreq/energy_performance_preference
echo balance-power | tee /sys/devices/system/cpu/cpu*/power/energy_perf_bias
# Enable the safest and most energy efficient link power management for SATA hosts, if any
echo med_power_with_dipm | tee /sys/class/scsi_host/host*/link_power_management_policy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment