LinuxCommandLibrary

hd-idle

Spin down idle hard drives

TLDR

Start a service to manage hard drive spin down. By default hard disks will spin down after 10 minutes of inactivity

$ systemctl start hd-idle
copy

Spin down a disk immediately
$ hd-idle -t [/dev/sdX]
copy

Set disks to never spin down, then set explicit idle times (in seconds) for disks which have "sda" or "sdb" in their device name
$ hd-idle -i 0 -a /dev/sda -i [300] -a /dev/sdb -i [1200]
copy

SYNOPSIS

hd-idle [-h] [-V] [-i idle_seconds] [-a /dev/sdX] [-t poll_seconds] [-l logfile] [-d] [-u user] [-p pidfile] [-n]

PARAMETERS

-i idle_seconds
    Set idle timeout before spin-down (default: 600 seconds / 10 minutes).

-a /dev/sdX
    Monitor specific disk device (repeatable for multiple drives).

-t poll_seconds
    Polling interval for I/O checks (default: 10 seconds).

-l logfile
    Log to specified file instead of stdout.

-d
    Run in foreground (do not daemonize).

-u user
    Drop privileges and run as specified user.

-p pidfile
    Write process ID to pidfile.

-n
    Stay in foreground, do not fork.

-h
    Display usage help.

-V
    Show version information.

DESCRIPTION

hd-idle is a lightweight Linux daemon designed to automatically spin down hard disk drives (HDDs) after a configurable period of inactivity, helping to reduce power consumption and heat generation. It polls specified disk devices at regular intervals to check for I/O activity. If no activity is detected for the set idle timeout, it issues a standby command to spin down the drive.

Primarily useful for laptops, servers, or NAS systems with external or infrequently accessed HDDs. It supports multiple drives via repeated -a options and runs as a background process by default. SSDs do not benefit as they lack spinning platters, and excessive spin-down cycles can wear mechanical parts, so timeouts should be tuned carefully.

The tool is minimalistic, with no dependencies beyond standard libc, making it ideal for embedded systems or minimal installs. It logs events to stdout or a file, aiding in monitoring and debugging.

CAVEATS

Not suitable for SSDs; may increase mechanical wear on HDDs with short timeouts. Requires disk access permissions. Some drives ignore spin-down commands or resume frequently due to background tasks.

EXAMPLE USAGE

Monitor all SATA drives:
hd-idle -i 1800 -a /dev/sd[a-z]
Run as daemon: systemctl enable hd-idle.service

SYSTEMD INTEGRATION

Commonly packaged; create /etc/default/hd-idle with HD_IDLE_OPTS='-i 3600 -a /dev/sda' then enable service.

HISTORY

Developed by Andreas Weber in 2003 for power-saving on Linux systems. Maintained sporadically; latest versions (v1.07+) add multi-drive support and privilege dropping. Widely used in NAS like Synology DSM.

SEE ALSO

hdparm(8), smartctl(8), sdparm(8)

Copied to clipboard