Dd command using disk I / O performance test

Dd command using disk I / O performance test

Author:  Vivek Gite  Translator:  LCTT  DongShuaike 

| 2015-08-28 07:30 Comments:  1  Favorite:  6    

How to use the dd command to test the performance of my hard drive? How to detect the hard disk read and write speed in linux operating system?

You can use the following commands for simple I / O performance tests on a Linux or Unix-like operating system.

  • dd command: It was used in Linux and Unix systems written to the hard disk device detects performance.
  • hparm command: it hard to get or set parameters on Linux-based system, including a test read cache performance and properties.

In this tutorial, you will learn how to use the dd command to test hard drive performance.

Dd command to monitor read and write performance of a hard disk:

  • Open a shell terminal.
  • Or log on to a remote server via ssh.
  • Dd command to the server using the measured throughput (writing speed) dd if=/dev/zero of=/tmp/test1.img bs=1G count=1 oflag=dsync
  • Dd command delay measurement server dd if=/dev/zero of=/tmp/test2.img bs=512 count=1000 oflag=dsync

Understand the options dd command

In this example, when I will use the Ubuntu Linux 14.04 LTS system equipped with a RAID-10 (SAS SSD with the Adaptec 5405Z) array of servers to run. The basic syntax is:

  1. dd if=/dev/input.file of=/path/to/output.file bs=block-size count=number-of-blocks oflag=dsync
  2. ## GNU dd语法 ##
  3. dd if=/dev/zero of=/tmp/test1.img bs=1G count=1 oflag=dsync
  4. ##另外一种GNU dd的语法 ##
  5. dd if=/dev/zero of=/tmp/testALT.img bs=1G count=1 conv=fdatasync

Sample output:

Fig 01: the server using the acquired throughput dd command

Fig 01: the server using the acquired throughput dd command

Please note that in this experiment, we write a G can be found, the server's throughput is 135 MB / s, which

  • if=/dev/zero (If = / dev / input.file): used to set the file name dd read command.
  • of=/tmp/test1.img (Of = / path / to / output.file): The output file name written input.file dd command.
  • bs=1G (Bs = block-size): dd block size setting command is read. For example, a G.
  • count=1 (Count = number-of-blocks): The number of block read command dd.
  • oflag=dsync (Oflag = dsync): synchronous I / O. Do not omit this option. This option can help you remove the effects of caching in order to present to you accurate results.
  • conv=fdatasyn: This option and oflag=dsyncthe meaning of the same.

In the following example, we wrote a total of 1000 times to obtain the write delay time of 512 bytes RAID10 server:

  1. dd if=/dev/zero of=/tmp/test2.img bs=512 count=1000 oflag=dsync

Sample output:

  1. 1000+0 records in
  2. 1000+0 records out
  3. 512000 bytes (512 kB) copied, 0.60362 s, 848 kB/s

Note that the server throughput and delay time also depends on the load on the server / application. So I recommend that you have just been rebooted and is in a peak time of the server up to run the test in order to get a more accurate measure. Now you can compare with each other the results of these tests on all your devices.

Why throughput and latency servers are so bad?

Low value does not mean that you are using bad hardware. It could be a hardware controller cache RAID10 caused.

Use hdparm command to view the disk cache read speed.

I suggest that you run the following command 2-3 times to detect the device read performance, as a reference and compared with each other:

  1. ### 有缓存的硬盘读性能测试——/dev/sda ###
  2. hdparm -t /dev/sda1
  3. ## 或者 ##
  4. hdparm -t /dev/sda

Then run the following command to 2-3 times control detection performance cache read:

  1. ## Cache读基准——/dev/sda ###
  2. hdparm -T /dev/sda1
  3. ## 或者 ##
  4. hdparm -T /dev/sda

Or simply to combine the two tests:

  1. hdparm -Tt /dev/sda

Sample output:

Figure 02: Detection hard disk read and cache performance Linux hdparm command

Figure 02: Detection hard disk read and cache performance Linux hdparm command

Note again, due to the operation of the cache properties file, you will always see a high reading speed.

Dd command to test the read speed

In order to obtain an accurate reading test data, run the following command before the first test to set the cache invalid:

  1. flush
  2. echo 3 | sudo tee /proc/sys/vm/drop_caches
  3. time time dd if=/path/to/bigfile of=/dev/null bs=8k

Examples of the notebook

Run the following command:

  1. ### 带有Cache的Debian系统笔记本吞吐率###
  2. dd if=/dev/zero of=/tmp/laptop.bin bs=1G count=1 oflag=direct
  3. ###使cache失效###
  4. hdparm -W0 /dev/sda
  5. ###没有Cache的Debian系统笔记本吞吐率###
  6. dd if=/dev/zero of=/tmp/laptop.bin bs=1G count=1 oflag=direct

Apple's OS X Unix (Macbook pro) example

GNU dd has many more options but OS X/BSD and Unix-like dd command need to run as follows to test real disk I/O and not memory add sync option as follows:

GNU dd command has many other options, but in OS X / BSD and Unix-in, dd command like that need to be detected to perform the following to remove the memory address of a real hard disk I / O performance:

  1. ## 运行这个命令2-3次来获得更好地结果 ###
  2. time sh -c "dd if=/dev/zero of=/tmp/testfile bs=100k count=1k && sync"

Sample output:

  1. 1024+0 records in
  2. 1024+0 records out
  3. 104857600 bytes transferred in 0.165040 secs (635346520 bytes/sec)
  4. real 0m0.241s
  5. user 0m0.004s
  6. sys 0m0.113s

I Macbook Pro's write speed is 635,346,520 bytes (635.347MB / s).

Do not like to use the command line?

You can also use the information based on Linux or disk utility (gnome-disk-utility) on Unix systems the tool to get in. The following figure is on my Fedora Linux v22 VM taken.

Graphical Method

Click on "Activites" or "Super" button to switch between desktop and Activites view. Enter the "Disks"

Figure 03: Open Gnome hard disk tools

Figure 03: Open Gnome hard disk tools

Selected on the left panel of your hard drive, click on the configure button, and then click the "Benchmark partition":

Figure 04: Trial hard disk / partition

Figure 04: Trial hard disk / partition

Finally, click "Start Benchmark ..." button (you may need to enter an administrator user name and password):

Figure 05: The final evaluation results

Figure 05: The final evaluation results

If you want to ask, I recommend what kind of command and the methods used?

  • I recommend using the dd command on all Unix-like systems ( time sh -c "dd if=/dev/zero of=/tmp/testfile bs=100k count=1k && sync)
  • If you are using GNU / Linux, using the dd command ( dd if=/dev/zero of=/tmp/testALT.img bs=1G count=1 conv=fdatasync)
  • Make sure that every time you use, are adjusted count and bs parameters in order to obtain better results.
  • GUI method is only suitable for a desktop system or as Gnome2 Gnome3 of Linux / Unix laptop users.

via: http://www.cyberciti.biz/faq/howto-linux-unix-test-disk-performance-with-dd-command/

Author: Vivek Gite Translator: DongShuaike  proofread: wxy

This article from the  LCTT  original translation, Linux China  is proud

Guess you like

Origin www.cnblogs.com/xuanbjut/p/12074731.html