Explanation of dd command instances in CentOS

Source: Internet
Author: User

Explanation of dd command instances in CentOS

When talking about the dd commands in linux, many technical bloggers are familiar with the usage. Today I will share with you several methods to test the hard disk read/write speed.

When we have no suitable hard disk I/O testing tool at hand, dd is our best choice. Let's take a closer look at the four methods of line and plane. Where is the difference?

Dd bs = 1 M count = 128 if =/dev/zero of = test

Dd bs = 1 M count = 128 if =/dev/zero of = test_01; sync

Dd bs = 1 M count = 128 if =/dev/zero of = test_02 conv = fdatasync

Dd bs = 1 mcount = 128 if =/dev/zero of = test_03 oflag = dsync

Did you think of it? Here: the difference lies in the processing method of writing cache in memory.

# ---------------------- Graphic analysis is as follows ----------------------------#

First:

Dd bs = 4 M count = 1024 if =/dev/zero of = test

No parameters are added. The default dd method does not include the "sync" command. That is to say, before the dd command is completed, the system did not actually write the file to the disk. Therefore, the above command simply reads the mb data into the memory buffer (write cache [write cache]). So what you get is a super fast speed. In fact, dd only gives you the read speed, and the system does not actually write data to the disk until dd is complete, but you cannot see this speed. So if this speed is fast, don't be happy first. Haha

Second:

Dd bs = 4 M count = 1024 if =/dev/zero of = test_01

It is exactly the same as in previous 1. Only two independent commands are separated by semicolons. When the sync command is ready to write data to the disk, the previous dd command has displayed the incorrect "write speed" value on the screen. So you still cannot get the real write speed.

Third:

Dd bs = 4 M count = 1024 if =/dev/zero of = test_02 conv = fdatasync


After this parameter is added, the dd command will actually execute a "sync" operation until the end, so what you get at this time is the time required to read the M data to the memory and write it to the disk. The calculated time is more realistic.

Fourth:

Dd bs = 4 M count = 1024 if =/dev/zero of = test_03 oflag = dsync


After this parameter is added, dd performs synchronous write operations every time it is executed. That is to say, this command writes the 1 M to the disk every time it reads the 1 M, and then reads the following 1 M, repeating 128 times. This may be the slowest way, because write cache is basically not used ).

Which of the following is the most useful:

Dd bs = 4 M count = 1024 if =/dev/zero of = test_02conv = fdatasync

Because this method is the closest to the actual operation of the computer, the data tested has the most reference value.

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.