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
Spin down a disk immediately
Set disks to never spin down, then set explicit idle times (in seconds) for disks which have "sda" or "sdb" in their device name
SYNOPSIS
hd-idle [options]
hd-idle -a <device> -i <interval>
PARAMETERS
-a
Target a specific <device> (e.g., /dev/sdb) to monitor with a <interval> (in seconds) for its activity. This overrides the global interval.
-i
Set the global check <interval> in seconds. hd-idle will check for inactivity on all monitored drives every <interval> seconds. Default is 5 seconds.
-t
Set the spin-down <timeout> in seconds. A drive will spin down if no I/O activity is detected for this period. Default is 600 seconds (10 minutes).
-s
Log total <sectors> read/written to/from a drive (requires -d for display).
-n
Do not daemonize. Run hd-idle in the foreground. Useful for debugging.
-d
Enable debug output. Shows detailed drive activity and actions taken by the command.
-v
Display version information of hd-idle and exit.
-h
Display a help message with command usage and options, then exit.
-c
Execute the specified <command> just before a drive is spun down. Useful for pre-spindown tasks.
-p
Specify the <path> for the PID file when running as a daemon. This file stores the process ID.
-l
Specify the <path> for the log file where hd-idle will write its activity logs.
-e
Exclude devices from monitoring for a specific number of <secs> after they are initially detected. Useful for drives that might be busy during startup.
-r
Re-read configuration or command-line parameters every <secs>. Primarily used with service managers like systemd.
-u
WARNING: Attempt to unmount drives before spinning them down. Can cause data loss or file system corruption if partitions are still in use.
-D
Do not spin down drives that are not currently mounted. This prevents unmounted drives from being affected.
-k
Keep drives awake if any I/O activity is detected, even if it's minimal. Ensures continuous operation for active drives.
DESCRIPTION
hd-idle is a command-line utility for Linux systems designed to spin down hard disk drives after a configurable period of inactivity. Its primary purpose is to conserve power, reduce noise, and potentially extend the lifespan of HDDs that are not in constant use.
By monitoring I/O activity on specified or all connected drives, hd-idle sends a spindown command (typically using hdparm internally or similar ATA commands) when no read or write operations have occurred for a defined timeout period. It can operate as a daemon in the background, continuously monitoring the drives. This tool is particularly useful for servers, Network Attached Storage (NAS) devices, or desktop systems where some hard drives are used for archival purposes or accessed intermittently, allowing them to enter a low-power state when idle. It helps in reducing electricity bills and minimizing wear-and-tear associated with continuous platter rotation, especially for drives not involved in active system operations.
CAVEATS
hd-idle should be used with caution, especially the -u
option which attempts to unmount drives and can lead to data loss or file system corruption if the drive is in use. Frequent spin-ups/spin-downs can increase the Load/Unload Cycle Count (LCC) attribute in S.M.A.R.T. data, potentially reducing the drive's lifespan, although modern drives are rated for hundreds of thousands to millions of cycles. It is generally not suitable for drives that are constantly accessed or host critical system files (like the root filesystem). Compatibility with USB enclosures can vary; some enclosures may not pass the necessary ATA commands for spin-down effectively, leading to no effect or unexpected behavior.
INSTALLATION
hd-idle is commonly available in the official repositories of most Linux distributions (e.g., apt install hd-idle
on Debian/Ubuntu, dnf install hd-idle
on Fedora/RHEL), making it straightforward to install using the system's package manager.
SERVICE MANAGEMENT
It is often configured to run as a systemd service, allowing it to start automatically at boot and manage its daemon process. A typical setup involves creating a systemd unit file (e.g., hd-idle.service
) to define its execution parameters and dependencies, ensuring it operates reliably in the background.
HISTORY
hd-idle emerged as a dedicated utility to address power management for hard drives on Linux, specifically focusing on automatic spin-down based on inactivity. While tools like hdparm provide the underlying capability to spin down a drive, hd-idle automates this process by continuously monitoring I/O, filling a niche for energy-efficient system configurations. Its development is driven by the need to reduce power consumption and noise in environments with intermittently accessed storage, such as home servers or NAS devices, evolving to handle various drive types and monitoring methods.