![linux hdparm](https://i-blog.csdnimg.cn/blog_migrate/78a3a054e4324aebaabfe188cca5afc1.png)
linux hdparm
Linux have different tools to manage disk devices and hard disks. hdparm
is one of the popular tools. Hdparm can get information about hard disk, change writing intervals, acoustic management, DMA settings etc.But be cautious while changing settings about the hard disk drive.
Linux有不同的工具来管理磁盘设备和硬盘。 hdparm
是流行的工具之一。 Hdparm可以获取有关硬盘的信息,更改写入间隔,声音管理,DMA设置等,但是在更改硬盘驱动器的设置时请务必谨慎。
句法 (Syntax)
hdparm [options] [device ...]
帮帮我 (Help)
$ hdparm -h
![Help](https://i-blog.csdnimg.cn/blog_migrate/f682c0ffc9cb4020afac9d79f55db51a.png)
显示有关磁盘的信息(Show Information About Disk)
One of the most wanted feature is getting information about the hard disk drive. We will use -I
option and the hard disk drive to get detailed information.
最需要的功能之一是获取有关硬盘驱动器的信息。 我们将使用-I
选项和硬盘驱动器来获取详细信息。
$ hdparm -I /dev/sda
![Show Information About Disk](https://i-blog.csdnimg.cn/blog_migrate/fb5cec7295ce777ee51214f6b8e1d710.png)
We will get a lot of detailed information about the hard disk. Here are some of them
我们将获得许多有关硬盘的详细信息。 这里是其中的一些
- Model Number型号编号
- Serial Number序列号
- Firmware Revision固件修订
- Cylinders, Heads, Sectors气缸,缸盖,扇形
- DMADMA
- Features supported and enabled 支持和启用的功能
测量硬盘设备的读取速度(Measure Hard Disk Device Read Speed)
Hard disk drive speed can be tested with hdparm . We will use -t
option for speed test. This test will only look read speed of the hard disk drive.
硬盘驱动器速度可以使用hdparm进行测试。 我们将使用-t
选项进行速度测试。 该测试将仅查看硬盘驱动器的读取速度。
$ sudo hdparm -t /dev/vdb
![Measure Hard Disk Device Read Speed](https://i-blog.csdnimg.cn/blog_migrate/45cb578852e54f6d601b0e1cef4bdf75.png)
We will get the benchmarks result after 5-10 seconds. We will get information like how much disk read is done and how much time required for this and average read performance in MB/sec
5-10秒后,我们将获得基准测试结果。 我们将获得诸如完成多少磁盘读取以及所需的时间以及平均读取性能(MB /秒)之类的信息。
测量硬盘缓存读取速度 (Measure Hard Disk Cache Read Speed)
Another read hard disk device speed test is reading cache. Reading cache will give more higher performance than reading from disk because only the cached data will be used and tested. We will use -T
option for this benchmark test.
另一个读取硬盘设备速度的测试是读取缓存。 与仅从磁盘读取数据相比,读取缓存将提供更高的性能,因为只有缓存的数据将被使用和测试。 我们将在此基准测试中使用-T
选项。
$ sudo hdparm -T /dev/vdb
![Measure Hard Disk Cache Read Speed](https://i-blog.csdnimg.cn/blog_migrate/b9c18c6d06fd64094c5b656d188a7f74.png)
As we can see from screenshot that reading performance is at 5GB/sec
从屏幕截图可以看出,读取性能为5GB /秒
启用预读(Enable Read Ahead)
To enable read ahead we will use -A1
.
为了启用-A1
读,我们将使用-A1
。
$ sudo hdparm -A1 /dev/vda
请安静 (Silence Please)
Mechanic disk or classical hard disks have some moving parts. There are disks in the hard disk which turns 5400 or 7200 RPM. There are some heads those will write some data by using magnetic areas techniques which will create some noise. Especially in busy systems this noise can be problem for us. We can lower the noise by lowering disk performance.
机械磁盘或经典硬盘具有一些运动部件。 硬盘中的磁盘转速变为5400或7200 RPM。 有些磁头会使用磁区技术写入一些数据,这会产生一些噪音。 特别是在繁忙的系统中,这种噪声对我们来说可能是个问题。 我们可以通过降低磁盘性能来降低噪音。
$ hdparm -M 128 /dev/sda
更改磁盘写入时间 (Change Disk Write Periods)
Another popular issue is hard disk drives writing periods. We can change write intervals with -B
option with the level. Levels can be between and
255
.
另一个流行的问题是硬盘驱动器的写入时间。 我们可以通过级别的-B
选项更改写入间隔。 级别可以介于和
255
。
$ hdparm -B 254 /dev/sda
更改DMA设置 (Change DMA Settings)
DMA gives performance to the hard disk operations. Which will write data into disk drive without need of CPU or other mechanisms. New disk drives all ready this featured enabled but for some older disk drives may not have this feature enabled. We can enable DMA with-d1
DMA可提高硬盘操作的性能。 它将不需要CPU或其他机制将数据写入磁盘驱动器。 新的磁盘驱动器都已准备好启用此功能,但对于某些较旧的磁盘驱动器可能未启用此功能。 我们可以使用-d1
启用DMA
$ hdparm -d1 /dev/sda
翻译自: https://www.poftut.com/hdparm-command-tutorial-with-examples-for-linux/
linux hdparm