Skip to content

What is hdparm Linux command?

The hdparm command in Linux is used to control and monitor hard disk drive (HDD) operations. It allows users to view and modify various parameters and settings of the HDD, such as enabling or disabling features like power management and write caching. By utilizing hdparm, users can optimize the performance and functionality of their hard drives within a Linux system.

hdparm Syntax:

Terminal window
hdparm [options] [device]

hdparm Options:

OptionDescription
-aGet/set sectors to transfer
-AEnable/disable IDE features
-bSet bus state
-BSet Advanced Power Management feature
-cEnable/disable 32-bit I/O support
-CCheck IDE power mode
-dEnable/disable using_dma
-DSet drive read-lookahead flag (usually ON)
-eSet cd-rom speed
-fFlush disk cache
-FFlush buffer cache for device on SCSI devices
-gDisplay drive geometry
-hDisplay terse usage information
-Hread temperature from drive
-IDisplay detailed current IDE info
-kGet/set keep_settings_over_reset flag (0/1)
-KSet drive keep features over reset (0/1)
-LLock device door
-mGet/set multiple sector count
-MGet/set automatic acoustic management (0-254, 128: quiet, 254: performance)
-nGet/set ignore write errors flag
-NGet/set max visible number of sectors
-pSet PIO mode on IDE interface lines
-PSet drive prefetch count
-qChange the rx/tx queues in IDE driver or stand-alone Control FSW`s
-QSet SATA NCQ mode (on
-rGet/set device readonly flag
-RRegister an Applications Power Management (APM) level
-sSave configuration for device
-SSet standby (spindown) timeout
-TPerform device read timings
-uGet/set interrupt-unmask flag
-UDisable/enable the UPS feature
-vDisplay minor version number
-VDisplay identify information, serial number
-wGet timing for IDE taskfile resets
-WPerform device reset (DANGEROUS)
-xPerform low-level formatting on device
-XSet IDE xfer mode (DANGEROUS)
-yForce an IDE drive to immediately enter the low power consumption standby mode
-YForce an IDE drive to enter the working power mode

Parameters:

ParameterDescription
deviceThe device to perform actions on, like /dev/sda or /dev/hda

hdparm Command Usage Examples:

Display Information about a Specific Drive

Terminal window
hdparm -I /dev/sda

This command displays detailed information about the drive /dev/sda

Measure Disk Read Speed

Terminal window
hdparm -t /dev/sda

This command measures the buffer read speed of the disk /dev/sda

Change Advanced Power Management Feature

Terminal window
hdparm -B 128 /dev/sda

This command sets the Advanced Power Management feature on the disk /dev/sda to a value of 128

Disable Automatic Acoustic Management

Terminal window
hdparm -M 253 /dev/sda

This command disables Automatic Acoustic Management on the disk /dev/sda by setting it to 253

Secure Erase a Disk

Terminal window
hdparm --security-set-pass mypassword /dev/sda
hdparm --security-erase mypassword /dev/sda

This pair of commands sets a password “mypassword” and performs a secure erase on the disk /dev/sda

How do I set the spin-down timeout for a hard disk using hdparm in Linux?

To set the spin-down timeout for a hard disk in Linux using hdparm, execute the following command:

Terminal window
hdparm -S <value> /dev/sdX

How can I check the current advanced power management setting of a disk with hdparm in Linux?

To check the current advanced power management setting of a disk in Linux using hdparm, use the following command:

Terminal window
hdparm -B /dev/sdX

How do I enable write-caching on a hard disk using hdparm in Linux?

To enable write-caching on a hard disk in Linux with hdparm, run the following command:

Terminal window
hdparm -W1 /dev/sdX

How can I get information about a hard disk’s capabilities using hdparm in Linux?

To retrieve information about a hard disk’s capabilities in Linux with hdparm, run the following command:

Terminal window
hdparm -I /dev/sdX

How do I disable read-ahead buffering on a disk using hdparm in Linux?

To disable read-ahead buffering on a disk in Linux using hdparm, execute the following command:

Terminal window
hdparm -a0 /dev/sdX

How can I perform a secure erase on a disk using hdparm in Linux?

To perform a secure erase on a disk in Linux using hdparm, run the following command (Note: this operation irreversibly erases all data on the disk):

Terminal window
hdparm --security-erase NULL /dev/sdX

How do I display the usage information for hdparm in Linux?

To display the usage information for hdparm in Linux, simply run the command with the --help option:

Terminal window
hdparm --help

How can I run a read speed test on a disk using hdparm in Linux?

To perform a read speed test on a disk in Linux using hdparm, use the following command:

Terminal window
hdparm -t /dev/sdX

Applications of the hdparm command

  • Displaying information about a hard disk
  • Checking disk capabilities and features
  • Testing disk performance
  • Changing disk settings
  • Improving disk performance
  • Setting Advanced Power Management (APM) levels
  • Setting DMA mode
  • Enabling or disabling read/write caching
  • Using Secure Erase functionality
  • Benchmarking disk performance