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:
- Energy Conservation: Mechanical drives consume between 4 to 10 watts while spinning. Power consumption drops to under 1 watt when spun down, which is beneficial for home servers, Network Attached Storage (NAS) devices, and battery-powered laptops.
- Thermal Management: Spinning motors generate heat. Reducing motor activity lowers the operating temperature within tight drive enclosures or multi-drive chassis.
- Acoustic Reduction: Spinning platters generate low-frequency vibration and motor noise. Entering standby mode makes the drive completely silent.
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:
- Value 0: Disables standby spin-down entirely. The drive platters will spin continuously regardless of idle time.
- Values 1 to 240: Multiples of 5 seconds. For
example, a value of
12equals 60 seconds (12 × 5 seconds), and a value of120equals 10 minutes (120 × 5 seconds). - Values 241 to 251: Multiples of 30 minutes,
calculated as
(value - 240) * 30 minutes. A value of241equals 30 minutes,242equals 1 hour, up to251which equals 5.5 hours. - Value 252: Hard-coded to represent 21 minutes.
- Value 253: Vendor-defined timeout period (often between 8 to 12 hours).
- Value 255: Hard-coded to represent 21 minutes and 15 seconds.
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/sdbTo verify if the drive has entered standby mode without spinning it up in the process, run:
sudo hdparm -C /dev/sdbThis 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:
- 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.
- 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.