Explain in detail the use of hdparm hard disk detection tool in Linux system

Time:2021-9-26

Under Linux, you can use hdparm tool to view the relevant information of the hard disk or measure the speed, optimize and modify the relevant parameter settings of the hard disk. I mainly use this tool to test the hard disk speed.

hdparm(hard disk parameters)
Function Description: display and set the parameters of the hard disk.

Syntax:

Copy code

The code is as follows:

Hdparm [- cfghiiqttvyyz] [- a < cache partition >] [- a < 0 or 1 >] [- C] [- d < 0 or 1 >] [- K < 0 or 1 >] [- K < 0 or 1 >] [- M < number of partitions >] [- n < 0 or</p>

Parameter Description:

-A < cache partition > set the number of partitions stored in the block area in advance when reading the file. If the < cache partition > option is not added, the current setting will be displayed.
-A < 0 or 1 > enables or disables the cache function when reading files.
-C set ide32-bit I / O mode.
-C detects 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 magnetic track, magnetic head, magnetic area and other parameters of the hard disk.
-H displays help.
-I displays the hardware specification information of the hard disk, which is provided by the hard disk itself when it is powered on.
-I directly read the hardware specification information provided by the hard disk.
-When k < 0 or 1 > resets the hard disk, keep the setting of – DMU parameter.
-When k < 0 or 1 > resets the hard disk, keep the setting of – apswxz parameter.
-M < number of partitions > sets the number of partitions accessed by multiple partitions of the hard disk.
-N < 0 or 1 > ignore errors that occur when writing to the hard disk.
-P sets the PIO mode of the hard disk.
-P < number of extents > set the number of partitions cached inside the hard disk.
-Q when executing subsequent parameters, no information is displayed on the screen.
-R < 0 or 1 > set the read-write mode of the hard disk.
-S < time > set the waiting time before the hard disk enters the power saving mode.
-T evaluate the reading efficiency of the hard disk.
-Read efficiency of T Pinggu hard disk cache.
-U < 0 or 1 > allow other interrupt requests to be executed simultaneously during hard disk access.
-V displays the relevant settings of the hard disk.
-W < 0 or 1 > set the write cache of the hard disk.
-X < transmission mode > set the transmission mode of the hard disk.
-Y put the IDE hard disk into power saving mode.
-Y puts the IDE hard disk into sleep mode.
-Z turn off the automatic power saving feature of some Seagate hard drives.

Examples of common parameters of hdparm:

1. Display the relevant settings of the hard disk:

Copy code

The code is as follows:

[ [email protected] ~]# hdparm /dev/sda</p>

2. Displays the number of cylinders, heads, and sectors of the hard disk:

Copy code

The code is as follows:

[ [email protected] ~]# hdparm -g /dev/sda</p>

3. Test the read speed of the hard disk:

Copy code

The code is as follows:

[[email protected] ~]# hdparm -t /dev/xvda</p>
<p>
/dev/xvda:</p>
<p>Timing buffered disk reads: 422 MB in 3.01 seconds = 140.20 MB/sec</p>
<p>[[email protected] ~]# hdparm -t /dev/xvda</p>
<p>/dev/xvda:</p>
<p>Timing buffered disk reads: 408 MB in 3.01 seconds = 135.59 MB/sec</p>
<p>[[email protected] ~]# hdparm -t /dev/xvda</p>
<p>/dev/xvda:</p>
<p>Timing buffered disk reads: 416 MB in 3.01 seconds = 138.24 MB/sec

4. Test the read speed of the hard disk cache:

Copy code

The code is as follows:

[[email protected] ~]# hdparm -T /dev/xvda</p>
<p>
/dev/xvda:</p>
<p>Timing cached reads: 11154 MB in 1.98 seconds = 5633.44 MB/sec</p>
<p>[[email protected] ~]# hdparm -T /dev/xvda</p>
<p>/dev/xvda:</p>
<p>Timing cached reads: 10064 MB in 1.98 seconds = 5077.92 MB/sec</p>
<p>[[email protected] ~]# hdparm -T /dev/xvda</p>
<p>/dev/xvda:</p>
<p>Timing cached reads: 10600 MB in 1.98 seconds = 5351.73 MB/sec

 

5. Detect the power management mode of the hard disk:

Copy code

The code is as follows:

[[email protected] ~]# hdparm -C /dev/sda</p>
<p>
/dev/sda:</p>
<p>
Drive state is: standby

6. Query and set the number of sectors accessed by multiple sectors of the hard disk to improve the access efficiency of the hard disk:

Copy code

The code is as follows:

[[email protected] ~]# hdparm -m /dev/sda</p>
<p>
[ [email protected] ~]#The value of hdparm – M parameter is an integer value, such as 8 / dev / SDA

Attachment: hard disk bad track repair method

Check:

Copy code

The code is as follows:

smartctl -l selftest /dev/sda

Uninstall:

Copy code

The code is as follows:

umount /dev/sda*

Repair:

Copy code

The code is as follows:

badblocks /dev/sda

Recommended Today

Supervisor

Supervisor [note] Supervisor – H view supervisor command help Supervisorctl – H view supervisorctl command help Supervisorctl help view the action command of supervisorctl Supervisorctl help any action to view the use of this action 1. Introduction Supervisor is a process control system. Generally speaking, it can monitor your process. If the process exits abnormally, […]