When working with physical storage devices in a Linux environment, system administrators occasionally need to delve beneath the filesystem layer and interact directly with the hardware controller of a hard drive. The hdparm command is a powerful, low-level utility designed to query and configure SATA and IDE hard disk drives. It allows you to view detailed factory specifications, test physical read speeds without filesystem caching, and toggle advanced hardware features like acoustic management and power states.
Warning: hdparm interacts directly with drive firmware. Executing the wrong configuration commands can corrupt data or physically damage older drives. Always double-check device paths.
Querying Hard Drive Information
Before making any changes, you can use hdparm to pull the factory identification data from a connected drive. You must run these commands as root (or use sudo), and you must know the block device path (e.g., /dev/sda).
sudo hdparm -I /dev/sda
The -I (uppercase i) flag instructs the drive to report its identity directly from its onboard controller. The terminal will output a massive block of text, including the exact Model Number, Firmware Revision, Serial Number, supported features (like S.M.A.R.T. and Advanced Power Management), and current security status.
Testing Physical Read Speeds
If you suspect a hard drive is failing or underperforming, you can use hdparm to perform a raw benchmark test. This test bypasses the Linux kernel’s file caching system to measure the true physical read speed of the disk platters (or flash memory).
sudo hdparm -tT /dev/sda
- -T (Timing cached reads): Tests how fast the system can read data directly from the Linux buffer cache without accessing the physical disk.
- -t (Timing buffered disk reads): Tests the actual, sustained read speed of the physical drive hardware.
Configuring Drive Settings
hdparm can also alter the drive’s operating parameters. For example, many enterprise hard drives support Advanced Power Management (APM). You can instruct the drive to aggressively spin down to save power, or you can force it to run at maximum performance to eliminate spin-up latency.
To view the current APM value (which ranges from 1 to 255):
sudo hdparm -B /dev/sda
To force the drive into maximum performance mode (disabling power management), you set the value to 255:
sudo hdparm -B 255 /dev/sda
Note: Settings applied by hdparm are generally wiped when the system reboots. To make them permanent, administrators typically script the hdparm command into systemd startup routines.