Linux hdparm Command
The Linux hdparm command is used to display and set hard disk parameters.
hdparm can detect, display, and set parameters for IDE or SCSI hard disks.
Syntax
hdparm [-CfghiIqtTvyYZ][-a <cache partition>][-A <0 or 1>][-c <I/O mode>][-d <0 or 1>][-k <0 or 1>][-K <0 or 1>][-m <partition count>][-n <0 or 1>][-p <PIO mode>][-P <partition count>][-r <0 or 1>][-S <time>][-u <0 or 1>][-W <0 or 1>][-X <transfer mode>][device]
Parameter Description:
-a<cache partition> Sets the number of cache partitions for reading files. If the <cache partition> option is not added, it displays the current setting.
-A<0 or 1> Enables or disables the cache function for reading files.
-c<I/O mode> Sets the IDE 32-bit I/O mode.
-C Detects the power management mode of the IDE hard disk.
-d<0 or 1> Sets the DMA mode of the disk.
-f Writes data from the memory buffer to the hard disk and clears the buffer.
-g Displays the track, head, and sector parameters of the hard disk.
-h Displays help.
-i Displays the hardware specification information of the hard disk, provided by the disk itself at boot time.
-I Directly reads the hardware specification information provided by the hard disk.
-k<0 or 1> Resets the hard disk while preserving the settings of the -dmu parameters.
-K<0 or 1> Resets the hard disk while preserving the settings of the -APSWXZ parameters.
-m<sector count> Sets the number of partitions for multi-sector access on the hard disk.
-n<0 or 1> Ignores errors that occur during disk writing.
-p<PIO mode> Sets the PIO mode of the hard disk.
-P<sector count> Sets the number of partitions for internal cache on the hard disk.
-q Executes subsequent parameters without displaying any information on the screen.
-r<0 or 1> Sets the read/write mode of the hard disk.
-S<time> Sets the wait time before the hard disk enters power-saving mode.
-t Evaluates the read efficiency of the hard disk.
-T Evaluates the read efficiency of the hard disk cache.
-u<0 or 1> Allows other interrupt requests to be executed simultaneously during disk access.
-v Displays the related settings of the hard disk.
-W<0 or 1> Turns off/on the write cache of the disk. Each disk has read and write caches. Sometimes the efficiency of turning off the disk write cache is higher than turning it on, so the former is chosen.
-X<transfer mode> Sets the transfer mode of the hard disk.
-y Puts the IDE hard disk into power-saving mode.
-Y Puts the IDE hard disk into sleep mode.
-Z Turns off the automatic power-saving function of certain Seagate hard disks.
Examples
Display the related settings of the hard disk:
# hdparm /dev/sda
/dev/sda:
IO_support = 0 (default 16-bit)
readonly = 0 (off)
readahead = 256 (on)
geometry = 19929 [cylinders] / 255 [heads] / 63 [sectors], sectors = 320173056 [total sectors], start = 0 [starting sector]
Display the cylinders, heads, and sectors of the hard disk:
# hdparm -g /dev/sda
/dev/sda:
geometry = 19929 [cylinders] / 255 [heads] / 63 [sectors], sectors = 320173056 [total sectors], start = 0 [starting sector]
Evaluate the read efficiency of the hard disk:
hdparm -t /dev/sda
/dev/sda:
Timing buffered disk reads: 166 MB in 3.03 seconds = 54.85 MB/sec
[[email protected] ~]# hdparm -t /dev/sda
/dev/sda:
Timing buffered disk reads: 160 MB in 3.01 seconds = 53.11 MB/sec
[[email protected] ~]# hdparm -t /dev/sda
/dev/sda:
Timing buffered disk reads: 166 MB in 3.00 seconds = 55.31 MB/sec