Force Hard Drives to Sleep on Arch Linux

arch-linux-wd-usb

Hard drives can account for a big chunk if not the vast majority of power usage in home servers depending on the number of drives. Most hard drives can be put into sleep or stand-by mode to reduce power usage dramatically with standard Linux tools. Western Digital drives and many external USB drives however require a more forceful methods. Fortunately hd-idle can spin down any SATA or USB drive.

 

Install & Configure hd-idle

Install hd-idle.

sudo pacman -S hd-idle

 

Spin down all hard drives after 5 minutes of inactivity.

hd-idle -i 300

The -i option sets the timeout before the disk is spun down in seconds.

 

Spin down only specific hard drives after individually specified timeouts.

hd-idle -i 0 -a sdb -i 300 -a sdc -i 600 -a sdd -i 900

The first -i option specifies a timeout of 0 to prevent the spin down of all drives. All -a option explicitly selects the device that contains a give string in it’s name and the following -i option defines a timeout that applies to only that device.

 

Test Hard Drive Power State

Install hdparm.

sudo pacman -S hdparm

 

Check hard disk power state.

sudo hdparm -C /dev/sda

 

Run hd-idle at Startup

Hd-idle has a systemd service file by default. All that’s left to do is to edit the configuration file.

sudo nano /etc/conf.d/hd-idle

Enable hd-idle at boot replace the line START_HD_IDLE=false with START_HD_IDLE=true. Uncommenting the last line HD_IDLE_OPTS="-i 180 -l /var/log/hd-idle.log" and set the desired options.

 

Enable hd-idle service.

sudo systemctl enable hd-idle

 

Start hd-idle service.

sudo systemctl start hd-idle

 

Quick Reference

sudo pacman -S hd-idle
hd-idle -i 300
hd-idle -i 0 -a sdb -i 300 -a sdc -i 600 -a sdd -i 900
sudo pacman -S hdparm
sudo hdparm -C /dev/sda
sudo nano /etc/conf.d/hd-idle
sudo systemctl enable hd-idle
sudo systemctl start hd-idle

dom