HDD Spindown Configuration via rc.local
Configure hard drive idle timeout for power savings using hdparm and rc.local systemd service to automatically spin down drives after inactivity.
Status
live
Difficulty
intermediate
Time Required
20m
Last Tested
2026-06-01
Overview
HDDs can be configured to automatically spin down after a period of inactivity, reducing power consumption and heat. This guide uses hdparm with the -S flag to set idle timeout and ensures the setting persists across reboots using /etc/rc.local.
The hdparm -S 240 command sets the idle timeout to 20 minutes (240 * 5 seconds = 1200 seconds).
Step 1: Open rc.local File
Edit the /etc/rc.local file:
sudo nano /etc/rc.local
Step 2: Add hdparm Command
Add the hdparm command just before the exit 0 line. Replace /dev/sdX with your actual disk device:
#!/bin/bash
# Your other startup commands here
# Set HDD idle timeout to 20 minutes (240 * 5 seconds = 1200 seconds)
sudo hdparm -S 240 /dev/sdX
exit 0
Finding Your Disk Device
List all block devices to identify your HDD:
lsblk
# or
sudo fdisk -l
# or
sudo hdparm -I /dev/sdX | grep "Model"
Common device names: /dev/sdb, /dev/sdc, /dev/sdd, etc.
Step 3: Make rc.local Executable
Ensure the file is executable:
sudo chmod +x /etc/rc.local
Step 4: Enable rc.local Service (Ubuntu 18.04+)
Modern Ubuntu versions don't run /etc/rc.local by default. Create a systemd service file:
Create the Service File
sudo nano /etc/systemd/system/rc-local.service
Add Service Configuration
[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99
[Install]
WantedBy=multi-user.target
Enable and Start Service
sudo systemctl daemon-reload
sudo systemctl enable rc-local
sudo systemctl start rc-local
Step 5: Reboot and Verify
Reboot the system to apply the configuration:
sudo reboot
After rebooting, verify the idle timeout is set correctly:
sudo hdparm -I /dev/sdX | grep -i idle
Expected output shows the idle timeout value set.
hdparm Spindown Values
The -S flag uses a specific scale:
| Value | Timeout | |-------|---------| | 1 | 5 seconds | | 2 | 10 seconds | | 3 | 15 seconds | | 12 | 1 minute | | 60 | 5 minutes | | 120 | 10 minutes | | 240 | 20 minutes | | 255 | 21 minutes (max) |
Alternative: Using systemd Timer
For more complex scheduling, create a systemd timer instead of /etc/rc.local:
Create Service File
sudo nano /etc/systemd/system/hdparm-spindown.service
[Unit]
Description=Set HDD Spindown Timeout
After=syslog.target
[Service]
Type=oneshot
ExecStart=/usr/sbin/hdparm -S 240 /dev/sdX
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
Enable Service
sudo systemctl daemon-reload
sudo systemctl enable hdparm-spindown
sudo systemctl start hdparm-spindown
Monitoring HDD Activity
Check current HDD power state:
sudo hdparm -C /dev/sdX
Output will show:
drive state is: active/idle- Currently active or idledrive state is: standby- Spun down
Monitor real-time disk activity:
iotop
# or
iostat -x 1
Troubleshooting
hdparm Command Not Found
Install hdparm:
sudo apt install hdparm
Service Won't Start
Check service status:
sudo systemctl status rc-local.service
sudo journalctl -u rc-local.service -n 20
Setting Doesn't Persist
Verify /etc/rc.local is executable:
ls -la /etc/rc.local
Device Not Found
Ensure the device path is correct:
sudo lsblk -o NAME,TYPE,SERIAL,SIZE
Power Saving Benefits
- Reduced power consumption: Inactive drives consume ~0.1W vs 5-10W when spinning
- Lower temperatures: Cooler operating conditions extend disk lifespan
- Quieter operation: Spindown reduces fan noise
Best Practices
- Don't set spindown time too short (causes excessive spin-up cycles)
- Monitor drives during spindown to ensure no data loss
- Use with backup drives or non-critical storage
- Test before production deployment