Linux uses the DD command to test hard disk read and write speeds

Source: Internet
Author: User

>linux Server installed the system, want to know whether the hard disk read and write to meet the needs of the service, if not meet the hard disk IO is a bottleneck of the service. So we need to test the hard disk read and write speed, testing a lot of methods, the following is the use of Linux with the DD command to test the read and write speed of the hard disk.

Time has a timing function, DD is used for copying, read from If, write to of. If=/dev/zero does not produce IO, so it can be used to test write speed. Similarly of=/dev/null does not produce IO and can be used to test the read speed. BS is the size of each read or write, that is, the size of a block, and count is the number of read and write blocks.

Write speed of the disk on which the/data directory resides:

[[Email protected] ~]# time DD If=/dev/zero of=/var/test bs=8k count=1000000
1000000+0 Records in
1000000+0 Records out
8192000000 bytes (8.2 GB) copied, 52.5749 seconds, 156 MB/s

Real 0m55.841s
User 0m0.507s
SYS 0m15.706s

# #红色部分是因为使用了time命令才显示的, so the time command is required to calculate when the replication takes.

The/data directory contains the disk read-only speed:

[[Email protected] ~]# time DD if=/var/test of=/dev/null bs=8k count=1000000
1000000+0 Records in
1000000+0 Records out
8192000000 bytes (8.2 GB) copied, 49.0088 seconds, 167 MB/s

Real 0m49.025s
User 0m0.559s
SYS 0m6.383s

Test read/write speed:

[[Email protected] ~]# time DD if=/var/test of=/tmp/test bs=8k count=1000000
125000+0 Records in
125000+0 Records out
8192000000 bytes (8.2 GB) copied, 129.239 seconds, 63.4 MB/s

Real 2m9.251s
User 0m0.114s
SYS 0m21.494s

Looks like the test results are good, hey

Note: Theoretically, the greater the amount of replication, the more accurate the test results.

The normal test may be more than one side of the test, it may take a lot of times to find the average, this test results in normal redirection is not effective after Google a bit in the following way to redirect to a file

DD If=/dev/zero of=/var/test bs=8k count=1000000 2>> Info

The result of this test is in the info file.

Hdparm test Drive Read and write speed

Installation: Yum Install Hdparm

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 number >][-n < 0 or 1 >][-p <pio mode >][-p < partition number >][-r < 0 or 1 >][-s < time >][-u < 0 or 1 ;] [-W < 0 or 1 ;] [-X < transfer mode;] [Device]

补充说明:hdparm可检测,显示与设定IDE或SCSI硬盘的参数。

参  数:
  -a<快取分区>   设定读取文件时,预先存入块区的分区数,若不加上<快取分区>选项,则显示目前的设定。
  -A<01>   启动或关闭读取文件时的快取功能。
  -c<I/O模式>   设定IDE32位I/O模式。
  -C   检测IDE硬盘的电源管理模式。
  -d<01>   设定磁盘的DMA模式。
  -f   将内存缓冲区的数据写入硬盘,并清楚缓冲区。
  -g   显示硬盘的磁轨,磁头,磁区等参数。
  -h   显示帮助。
  -i   显示硬盘的硬件规格信息,这些信息是在开机时由硬盘本身所提供。
  -I   直接读取硬盘所提供的硬件规格信息。
  -k<01>   重设硬盘时,保留-dmu参数的设定。
  -K<01>   重设硬盘时,保留-APSWXZ参数的设定。
  -m<磁区数>   设定硬盘多重分区存取的分区数。
  -n<01>   忽略硬盘写入时所发生的错误。
  -p<PIO模式>   设定硬盘的PIO模式。
  -P<磁区数>   设定硬盘内部快取的分区数。
  -q   在执行后续的参数时,不在屏幕上显示任何信息。
  -r<01>   设定硬盘的读写模式。
  -S<时间>   设定硬盘进入省电模式前的等待时间。
  -t   评估硬盘的读取效率。
  -T  评估硬盘快取的读取效率。
  -u<01>   在硬盘存取时,允许其他中断要求同时执行。
  -v   显示硬盘的相关设定。
  -W<01>   设定硬盘的写入快取。
  -X<传输模式>   设定硬盘的传输模式。
  -y   使IDE硬盘进入省电模式。
  -Y   使IDE硬盘进入睡眠模式。
  -Z   关闭某些Seagate硬盘的自动省电功能。

To test the read speed of the hard drive:

Normal disk test:

# hdparm -t /dev/sda
/dev/sda:
 Timing buffered disk reads: 316 MB in  3.02 seconds = 104.71MB/sec

# hdparm -T /dev/sda
/dev/sda:
 Timing cached reads:  19328 MB in  1.99 seconds = 9691.24MB/sec

RAID0 Test (two disks):

# hdparm -t /dev/sdb
/dev/sdb:
 Timing buffered disk reads: 622 MB in  3.01 seconds = 206.89MB/sec

# hdparm -T /dev/sdb1
/dev/sdb1:
 Timing cached reads:  19632 MB in  1.99 seconds = 9844.20MB/sec

RAID0 Test (three disks):

# hdparm -t /dev/sdb
/dev/sdb:
 Timing buffered disk reads: 846 MB in  3.00 seconds = 281.54MB/sec


# hdparm -T /dev/sdb
/dev/sdb:
 Timing cached reads:  18412 MB in  1.99 seconds = 9229.67MB/sec

RAID0 test (four plates)

/dev/sdb:
 Timing cached reads:  19608 MB in  1.99 seconds = 9832.76MB/sec

 Timing buffered disk reads: 860 MB in  3.00 seconds = 286.35MB/sec

In addition arid card test speed, each time will be warned:

HDIO_DRIVE_CMD(null) (waitfor flush complete) failed: Inappropriate ioctl fordevice

Reference test speed Method: Time Cp-a data2 data2


This article is from "Rain" blog, be sure to keep this source http://gushiren.blog.51cto.com/3392832/1691877

Linux uses the DD command to test hard disk read and write speeds

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.