Introduction #
For servers running 24/7, power usage can become a major operational cost. With PowerTOP and hd-idle, you can significantly optimize server power consumption. This is a complete guide.
Requirements #
- Linux OS (Ubuntu/Debian/CentOS etc)
- Root or sudo access
- Server with power-saving features supported
Part 1: Using PowerTOP #
1. Install PowerTOP #
# For Debian/Ubuntu
sudo apt update
sudo apt install powertop -y
# For CentOS/RHEL
sudo yum install powertop -y
# For Arch Linux
sudo pacman -S powertop
2. Calibrate PowerTOP #
Before using, run calibration:
sudo powertop --calibrate
This may take a few minutes and cause screen flickering.
3. Analyze Power Usage #
Run PowerTOP in interactive mode:
sudo powertop
It will show:
- List of power-hungry processes
- Power usage stats
- Optimization suggestions
4. Apply Optimizations Automatically #
To apply all tuning suggestions:
sudo powertop --auto-tune
5. Make PowerTOP Settings Persistent #
Create a PowerTOP service:
sudo nano /etc/systemd/system/powertop.service
Add this content:
[Unit]
Description=PowerTOP auto tune
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/usr/sbin/powertop --auto-tune
[Install]
WantedBy=multi-user.target
Enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable powertop.service
sudo systemctl start powertop.service
6. PowerTOP Usage Tips #
- Check the “Tunables” tab for adjustable settings
- Focus on components marked “Bad”
- Monitor system after tuning to ensure stability
Part 2: Using hd-idle to Save Hard Disk Power #
1. Install hd-idle #
# Debian/Ubuntu
sudo apt update
sudo apt install hd-idle -y
# CentOS/RHEL (might require building from source)
sudo yum install epel-release
sudo yum install hd-idle
2. Configure hd-idle #
Edit the config file:
sudo nano /etc/default/hd-idle
Example config to spin down disks after 10 minutes idle:
START_HD_IDLE=true
HD_IDLE_OPTS="-i 600 -l /var/log/hd-idle.log"
Parameter notes:
-i 600: 600 seconds idle time-l: log file path
3. Target Specific Disks #
To apply only to a specific disk (e.g. /dev/sdb):
HD_IDLE_OPTS="-i 600 -a sdb -l /var/log/hd-idle.log"
4. Start and Enable the Service #
sudo systemctl enable hd-idle
sudo systemctl start hd-idle
5. Verify hd-idle Is Running #
sudo systemctl status hd-idle
sudo tail -f /var/log/hd-idle.log
6. hd-idle Usage Tips #
- Avoid short idle times for frequently used disks
- Do not use it on the main system disk (usually /dev/sda)
- Monitor logs to ensure proper operation
Part 3: Additional Server Optimization #
1. Set CPU Governor #
To switch to power-saving mode:
# Install cpufrequtils if needed
sudo apt install cpufrequtils -y
# Set governor to powersave
sudo cpufreq-set -r -g powersave
# Verify
cpufreq-info
2. Reduce Load Average #
Disable unused services:
sudo systemctl list-unit-files --type=service | grep enabled
sudo systemctl disable <unneeded-service>
3. Optimize Swappiness #
Reduce swap usage:
sudo nano /etc/sysctl.conf
Add this line:
vm.swappiness=10
Apply changes:
sudo sysctl -p
4. Set Brightness (If Using Display) #
# Example to reduce brightness
sudo echo 50 > /sys/class/backlight/intel_backlight/brightness
Part 4: Monitor Power Saving Results #
1. Use PowerTOP to View Impact #
sudo powertop
Check power usage differences before and after optimization.
2. Use Physical Power Meter #
If available, use hardware to measure actual power draw.
3. Generate PowerTOP Report #
sudo powertop --html=powerreport.html
The HTML file contains detailed analysis.
Troubleshooting #
Common Issues and Solutions #
-
Performance drops significantly
- Lower the power-saving aggressiveness
- Set CPU governor back to “ondemand”
-
Disk won’t wake from idle
- Increase hd-idle timeout
- Exclude specific disks
-
PowerTOP not running
- Make sure you use sudo
- Check
dmesgfor hardware-related errors
Conclusion #
With PowerTOP and hd-idle, you can cut server power consumption significantly. Typical savings range from 10 to 30 percent depending on hardware and workload. Monitor regularly to balance power savings and performance.