Set Hard Drive Spindown Timeout with hdparm -S

The hdparm -S command in Linux manages storage drive power consumption by configuring the idle spin-down timeout for mechanical hard disk drives (HDDs). This article explains the primary purpose of the command, the mathematical system used to define standby durations, the trade-offs between energy savings and hardware lifespan, and how to configure these settings on a Linux system.

The Purpose of the hdparm -S Command

The -S flag in the hdparm utility instructs a storage drive's internal firmware to enter an idle or standby state after a specified period of inactivity. When a mechanical hard drive enters standby mode, it parks its read/write heads and spins down the physical platters.

The primary purposes of spinning down an idle hard drive include:

Note that hdparm -S is intended for rotational media (mechanical hard drives). Solid-state drives (SSDs) do not possess moving parts, meaning mechanical spin-down does not apply to them; SSDs handle power states independently via standards like NVMe APST or SATA DIPM.

Decoding the Timeout Values

Unlike standard Linux utilities that accept time values in seconds or minutes (such as 10m or 600s), hdparm -S uses a non-linear legacy encoding system defined by the ATA specification. The value passed directly after -S determines the standby interval according to the following rules:

Usage and Syntax

To configure a spin-down timeout, execute hdparm with sudo or root privileges, targeting the specific block device.

To set a drive to spin down after 10 minutes of inactivity:

sudo hdparm -S 120 /dev/sdb

To verify if the drive has entered standby mode without spinning it up in the process, run:

sudo hdparm -C /dev/sdb

This returns either active/idle (platters spinning) or standby (platters stopped).

Trade-Offs and Hardware Considerations

While setting an aggressive spin-down timer saves power, it introduces specific performance and reliability considerations:

  1. Access Latency: When an application or the operating system requests data from a drive in standby, it must wait 5 to 15 seconds for the platters to reach operating RPM before the data can be read.
  2. Mechanical Wear: Hard drives are rated for a finite number of load/unload cycles (typically 300,000 to 600,000 cycles). Spinning down a drive too frequently—such as after only 1 to 2 minutes of idle time—can cause repeated start-stop cycles throughout the day, accelerating mechanical degradation.

Making Settings Persistent

Commands issued with hdparm are volatile and reset when the system reboots or when the drive is power-cycled. To maintain the configuration permanently, define the parameter in /etc/hdparm.conf on Debian and Ubuntu systems:

/dev/disk/by-id/ata-WDC_WD20EFRX-... {
    spindown_time = 120
}

Using the persistent device identifier located in /dev/disk/by-id/ ensures the settings target the correct physical drive even if disk drive letters (/dev/sda, /dev/sdb) change across reboots.