Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Linux hdparm command

Linux hdparm command

Linux Command Reference Linux Command Reference

The Linux hdparm command is used to display and set hard disk parameters.

hdparm can detect, display, and set the parameters of IDE or SCSI hard disks.

Syntax



hdparm [-CfghiIqtTvyYZ][-a <快取分区>][-A <0或1>][-c ][-d <0或1>][-k <0或1>][-K <0或1>][-m <分区数>][-n <0或1>][-p ][-P <分区数>][-r <0或1>][-S <时间>][-u <0或1>][-W <0或1>][-X <传输模式>][设备]

Parameter Description:

  • -a Sets the number of sectors pre-stored into the block area when reading files; if not added, option, the current setting is displayed.
  • -A<0 or 1> Enable or disable the cache function when reading files.
  • -c Set the IDE 32-bit I/O mode.
  • -C Check the power management mode of the IDE hard disk.
  • -d<0 or 1> Set the DMA mode of the disk.
  • -f Write data from the memory buffer to the hard disk and clear the buffer.
  • -g Display parameters such as tracks, heads, and sectors of the hard disk.
  • -h Display help.
  • -i Display hardware specification information of the hard disk, which is provided by the hard disk itself at boot time.
  • -I Directly read the hardware specification information provided by the hard disk.
  • -k<0 or 1> When resetting the hard disk, retain the -dmu parameter settings.
  • -K<0 or 1> When resetting the hard disk, retain the -APSWXZ parameter settings.
  • -m Set the number of sectors for multiple sector access on the hard disk.
  • -n<0 or 1> Ignore errors that occur when writing to the hard disk.
  • -p Set the PIO mode of the hard disk.
  • -P Set the number of sectors for the hard disk's internal cache.
  • -q Do not display any information on the screen when executing subsequent parameters.
  • -r<0 or 1> Set the read/write mode of the hard disk.
  • -S
  • -t Evaluate the read efficiency of the hard disk.
  • -T Evaluate the read efficiency of the hard disk cache.
  • -u<0 or 1> Allow other interrupt requests to execute simultaneously during hard disk access.
  • -v Display the related settings of the hard disk.
  • -W<0 or 1> Disable/enable the disk write cache. Every disk has a read cache and a write cache; sometimes disabling the disk write cache is more efficient than enabling it, so of course we choose the former.
  • -X Set the transfer mode of the hard disk.
  • -y Put the IDE hard disk into power-saving mode.
  • -Y Put the IDE hard disk into sleep mode.
  • -Z Disable the automatic power-saving feature of some Seagate hard disks.

Example

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[柱面数]/255[磁头数]/63[扇区数], sectors = 320173056[总扇区数], start = 0[起始扇区数]

Display the number of cylinders, heads, and sectors of the hard disk



# hdparm -g /dev/sda

 /dev/sda:

 geometry = 19929[柱面数]/255[磁头数]/63[扇区数], sectors = 320173056[总扇区数], start = 0[起始扇区数]

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

 [root@linuxso.com ~]# hdparm -t /dev/sda

 /dev/sda:

 Timing buffered disk reads: 160 MB in 3.01 seconds = 53.11 MB/sec

 [root@linuxso.com ~]# hdparm -t /dev/sda

 /dev/sda:

 Timing buffered disk reads: 166 MB in 3.00 seconds = 55.31 MB/sec

Linux Command Reference Linux Command Reference