TrumanWong

hdparm

Display and set hard disk parameters

Supplementary instructions

hdparm command provides a command line interface for reading and setting IDE or SCSI hard disk parameters.

grammar

hdparm(options)(parameters)

Options

-a <cache partition>: Set the number of partitions to be pre-stored in the block area when reading files. If the <cache partition> option is not added, the current setting will be displayed;
-A<0 or 1>: Enable or disable the cache function when reading files;
-c<I/O mode>: Set IDE32-bit I/O mode;
-C: Detect the power management mode of IDE hard disk;
-d<0 or 1>: Set the DMA mode of the disk;
-f: Write the data in the memory buffer to the hard disk and clear the buffer;
-g: Display the hard disk’s tracks, heads, sectors and other parameters;
-h: display help;
-i: Displays the hardware specification information of the hard disk. This information is provided by the hard disk itself when booting;
-I: Directly read the hardware specification information provided by the hard disk;
-k<0 or 1>: When resetting the hard disk, retain the setting of the -dmu parameter;
-K<0 or 1>: When resetting the hard disk, retain the settings of the -APSWXZ parameter;
-m<Number of sectors>: Set the number of partitions for multi-partition access on the hard disk;
-n<0 or 1>: Ignore errors that occur when writing to the hard disk;
-p<PIO mode>: Set the PIO mode of the hard disk;
-P <Number of sectors>: Set the number of partitions cached within the hard disk;
-q: Do not display any information on the screen when executing subsequent parameters;
-r<0 or 1>: Set the read and write mode of the hard disk;
-S<time>: Set the waiting time before the hard disk enters power saving mode;
-t;Evaluate the reading efficiency of the hard disk;
-T: Pinggu hard disk cache read efficiency;
-u<0 or 1>: Allow other interrupt requests to be executed at the same time during hard disk access;
-v: Display the related settings of the hard disk;
-w<0 or 1>: Set the hard disk write cache;
-X<transfer mode>: 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: Turn off the automatic power saving function of some Seagate hard drives.

Parameters

Device file: Specify the device file name corresponding to the id driver.

Example

Display the relevant settings of the hard disk:

hdparm /dev/sda
/dev/sda:
IO_support = 0 (default 16-bit)
readonly = 0 (off)
readahead = 256 (on)
geometry = 19457 [number of cylinders]/255 [number of heads]/63 [number of sectors], sectors = 312581808 [number of total sectors], start = 0 [number of starting sectors]

```shell

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

```shell
hdparm -g /dev/sda
/dev/sda:
geometry = 19457 [number of cylinders]/255 [number of heads]/63 [number of sectors], sectors = 312581808 [number of total sectors], start = 0 [number of starting sectors]

Test the reading speed of the hard disk:

hdparm -T /dev/sda
/dev/sda:
  Timing cached reads: 4684 MB in 2.00 seconds = 2342.92 MB/sec

Test the read speed of the hard disk cache:

hdparm -T /dev/xvda
/dev/xvda:
Timing cached reads: 11154 MB in 1.98 seconds = 5633.44 MB/sec

Detect the power management mode of the hard drive:

hdparm -C /dev/sda
/dev/sda:
drive state is: standby [power saving mode]

Query and set the number of sectors for multi-sector access of the hard disk to improve the access efficiency of the hard disk:

hdparm -m /dev/sda
hdparm -m #The parameter value is an integer value such as 8 /dev/sda

Attachment: How to repair hard drive bad sectors

Check: smartctl -l selftest /dev/sda
Uninstall: umount /dev/sda*
Fix: badblocks /dev/sda