Use the dd command to check hard disk I/O performance

Source: Internet
Author: User

Use the dd command to check hard disk I/O performance

How can I use the dd command to test my hard disk performance? In linux, how does one check the read/write speed of a hard disk?

You can use the following command to perform a simple I/O performance test on a Linux or Unix-like operating system.

  • Dd command: it is used to test the Write Performance of hard disk devices in Linux and Unix-like systems.
  • Hparm command: it is used to obtain or set hard disk parameters on a Linux-based system, including testing read performance and cache performance.

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

Linux/UNIX: Use the dd command to create a 1 GB binary

Use the DD command in Linux to test the read/write speed of USB and SSD hard disks.

Brief Introduction to Linux dd commands

Use the dd command to monitor the read/write performance of the hard disk:
  • Open the shell terminal.
  • Or log on to the remote server through ssh.
  • Use the dd command to measure the server throughput (write speed)dd if=/dev/zero of=/tmp/test1.img bs=1G count=1 oflag=dsync
  • Use the dd command to measure server latencydd if=/dev/zero of=/tmp/test2.img bs=512 count=1000 oflag=dsync

 

Understanding dd Command Options

In this example, I will use a RAID-10 (Adaptec 5405Z with SAS SSD) server array running the Ubuntu Linux 14.04 LTS system. 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 syntax ##
  3. dd if=/dev/zero of=/tmp/test1.img bs=1G count=1 oflag=dsync
  4. # Another GNU dd syntax ##
  5. dd if=/dev/zero of=/tmp/testALT.img bs=1G count=1 conv=fdatasync

Output example:

Figure 01 server throughput obtained using the dd command

Please note that in this experiment, we write a G data and we can find that the server throughput is 135 MB/s, where

  • if=/dev/zero(If =/dev/input. file): used to set the input file name read by the dd command.
  • of=/tmp/test1.img(Of =/path/to/output. file): name of the output file written by the dd command to input. file.
  • bs=1G(Bs = block-size): set the size of the block read by the dd command. In this example, 1G is used.
  • count=1(Count = number-of-blocks): number of blocks read by the dd command.
  • oflag=dsync(Oflag = dsync): use synchronous I/O. Do not omit this option. This option can help you remove the impact of caching, so as to present accurate results to you.
  • conv=fdatasyn: This option andoflag=dsyncThe meaning is the same.

In the following example, a total of 1000 write times are written, and 512 bytes are written each time to obtain the delay time of the RAID10 Server:

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

Output example:

  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 depend on the server/application load. Therefore, we recommend that you run the test on a server that has just been restarted and has been in peak time for more accurate measurement. Now you can compare the test results on all your devices.

 

Why is the server throughput and latency so bad?

A low value does not mean you are using poor hardware. It may be caused by the Controller cache of hardware raid 10.

Use the hdparm command to view the read speed of the hard disk cache.

I suggest you run the following command for 2-3 times to check the read performance of the device for reference and mutual comparison:

  1. ### Test the read performance of cached hard disks --/dev/sda ###
  2. hdparm -t /dev/sda1
  3. ##Or ##
  4. hdparm -t /dev/sda

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

  1. # Cache read benchmark --/dev/sda ###
  2. hdparm -T /dev/sda1
  3. ##Or ##
  4. hdparm -T /dev/sda

Or simply combine the two tests:

  1. hdparm -Tt/dev/sda

Output example:

Figure 02: Linux hdparm command used to check hard disk reading and cache Performance

Please note again that due to the cache attribute of file operations, you will always see a high read speed.

 

Run the dd command to test the read speed.

To obtain accurate read test data, first run the following command before the test to set the cache to 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 
Notebook example

Run the following command:

  1. ### Debian system laptop throughput with Cache ###
  2. dd if=/dev/zero of=/tmp/laptop.bin bs=1G count=1 oflag=direct
  3. ### Invalidate cache ###
  4. hdparm -W0 /dev/sda
  5. ### Debian laptop throughput without Cache ###
  6. dd if=/dev/zero of=/tmp/laptop.bin bs=1G count=1 oflag=direct

For more details, please continue to read the highlights on the next page:

  • 1
  • 2
  • Next Page

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.