This HDparm cheatsheet is your go-to resource for optimizing hard drive performance. It includes commands for adjusting readahead, power management settings, drive speeds, and more, helping you fine-tune your disk operations for optimal efficiency and reliability.
Get/set the drive look-ahead flag (0/1)
Get/set bus state (0 == off, 1 == on, 2 == tristate)
Set Advanced Power Management setting (1-255)
Get/set IDE 32-bit IO setting
Check drive power mode status
Enable/disable drive defect management
Flush buffer cache for device on exit
Display terse usage information
Read temperature from drive (Hitachi only)
Display drive identification
Detailed/current information directly from drive
Get/set Western DIgital "Idle3" timeout for a WDC "Green" drive (DANGEROUS)
Get/set keep_settings_over_reset flag (0/1)
Set drive keep_features_over_reset flag (0/1)
Set drive doorlock (0/1) (removable harddisks only)
Get/set multiple sector count
Get/set acoustic management (0-254, 128: quiet, 254: fast)
Get/set ignore-write-errors flag (0/1)
Get/set max visible number of sectors (HPA) (VERY DANGEROUS)
Set PIO mode on IDE interface chipset (0,1,2,3,4,...)
Change next setting quietly
Get/set DMA queue_depth (if supported)
Get/set device readonly flag (DANGEROUS to set)
Get/set device write-read-verify flag
Set power-up in standby flag (0/1) (DANGEROUS)
Set standby (spindown) timeout
Perform device read timings
Perform cache read timings
Get/set unmaskirq flag (0/1)
Use defaults; same as -acdgkmur for IDE drives
Display program version and exit immediately
Perform device reset (DANGEROUS)
Get/set drive write-caching flag (0/1)
Set IDE xfer mode (DANGEROUS)
Put drive in standby mode
Disable Seagate auto-powersaving mode
Perform device read timings
Perform cache read timings
Check drive power mode status
hdparm -C /dev/sda 2> /dev/null|grep state
Freeze/lock current device configuration until next power cycle
hdparm --dco-freeze /dev/sdb
Read/dump device configuration identify data
hdparm --dco-identify /dev/sdb
Reset device configuration back to factory defaults
hdparm --dco-restore /dev/sdb
Use DCO to set maximum addressable sectors
hdparm --dco-setmax /dev/sdb
Use O_DIRECT to bypass page cache for timings
Crash system with a "stuck DRQ" error (VERY DANGEROUS)
hdparm --drq-hsm-error /dev/sdb
Create a file without writing data to disk
hdparm --fallocate /dev/sdb
Show device extents (and fragmentation) for a file
Download firmware file to drive (EXTREMELY DANGEROUS)
hdparm --fwdownload /dev/sdb
Download firmware using min-size segments (EXTREMELY DANGEROUS)
hdparm --fwdownload-mode3 /dev/sdb
Download firmware using max-size segments (EXTREMELY DANGEROUS)
hdparm --fwdownload-mode3-max /dev/sdb
Download firmware using a single segment (EXTREMELY DANGEROUS)
hdparm --fwdownload-mode7 /dev/sdb
Download firmware using mode E (min-size segments) (EXTREMELY DANGEROUS)
hdparm --fwdownload-modee /dev/sdb
Download firmware using mode E (max-size segments) (EXTREMELY DANGEROUS)
hdparm --fwdownload-modee-max /dev/sdb
Idle drive immediately
hdparm --idle-immediate /dev/sdb
Idle immediately and unload heads
hdparm --idle-unload /dev/sdb
Write raw binary identify data to the specfied file
hdparm --Iraw filename /dev/sdb
Read identify data from stdin as ASCII hex
Write identify data to stdout as ASCII hex
hdparm --Istdout /dev/sdb
Deliberately corrupt a sector directly on the media (VERY DANGEROUS)
hdparm --make-bad-sector /dev/sdb
use with -t, to begin timings at given offset (in GiB) from start of drive
Use 12-byte (instead of 16-byte) SAT commands when possible
hdparm --prefer-ata12 /dev/sdb
Read and dump (in hex) a sector directly from the media
hdparm --read-sector /dev/sdb
Alias for the --write-sector option (VERY DANGEROUS)
hdparm --repair-sector /dev/sdb
Block sanitize-freeze-lock command until next power cycle
hdparm --sanitize-antifreeze-lock /dev/sdb
Start block erase operation
hdparm --sanitize-block-erase /dev/sdb
Change the internal encryption keys that used for used
hdparm --sanitize-crypto-scramble /dev/sdb
Lock drive's sanitize features until next power cycle
hdparm --sanitize-freeze-lock /dev/sdb
Overwrite the internal media with constant PATTERN
hdparm --sanitize-overwrite PATTERN /dev/sdb
Number of overwrite passes from 0 to 7, default 0 means 16 passes
hdparm --sanitize-overwrite-passes COUNT /dev/sdb
Show sanitize status information
hdparm --sanitize-status /dev/sdb
Display help for ATA security commands
hdparm --security-help /dev/sdb
Change logical sector size of drive
hdparm --set-sector-size /dev/sdb
Tell SSD firmware to discard unneeded data sectors:
hdparm --trim-sector-ranges /dev/sdb
Same as above, but reads lba:count pairs from stdin
hdparm --trim-sector-ranges-stdin /dev/sdb
Display extra diagnostics from some commands
hdparm --verbose /dev/sdb
Repair/overwrite a (possibly bad) sector directly on the media (VERY DANGEROUS)
hdparm --write-sector /dev/sdb