Using Linux commands dd test disk read and write speed

is a very useful dd command Linux / UNIX under, is to copy a file with the specified block size, and the designated conversion simultaneous copies.

General dd command syntax is as follows:

dd if=path/to/input_file of=/path/to/output_file bs=block_size count=number_of_blocks

1, the test disk write capability

time dd if=/dev/zero of=/testw.dbf bs=4k count=100000

Because the / dev // zero is a pseudo device, it generates a null character stream, it will not produce IO, therefore, IO will be concentrated in the of file, of the file for writing only, so this command is equivalent to test disk and writing. Oflag end of the command is added is skipped = direct memory cache, adding oflag = sync skips hdd cache.
2, the test disk reading ability

time dd if=/dev/sdb of=/dev/null bs=4k

Because the / dev / sdb is a physical partition, it generates read IO, / dev / null is a dummy device corresponds to a black hole, the apparatus of the IO does not produce, so this only occurs in the IO command / on dev / sdb, also equivalent to reading proficiency test disk. (Ctrl + c to terminate the test)

3, while the literacy test

time dd if=/dev/sdb of=/testrw.dbf bs=4k

In this command, a physical partitions, a is the actual file, they will have to read and write IO (on / dev / sdb is read, to write /testrw.dbf), assuming they are in a disk, this command is equivalent to test the disk while reading and writing skills.

4, write performance test pure

dd if=/dev/zero of=test bs=8k count=10000 oflag=direct

5, read performance test pure

dd if=test of=/dev/null bs=8k count=10000 iflag=direct

 

Note : dd can only provide a rough test results, and continuous I / O rather than random I / O, in theory, the larger the file size, the more accurate the test results. Meanwhile, iflag / oflag provides direct mode, the direct mode is a write request directly to the package I / O command issued to the disk, a non-direct mode, data is written only to the cache system is considered I / O success, determined by the operating system when data in the cache is written to disk.

 

About Command

Main options (In terms of the end where the specified number is multiplied by the corresponding number of the following characters: b = 512, c = 1, k = 1024, w = 2, xm = number m): 

Copy the code

if = file enter a file name, the default is standard input. 
of = file output file name, the default output is standard. 
ibs = bytes bytes read into bytes (i.e., a block size of bytes bytes). 
obs = bytes bytes bytes of write-once (i.e., a block size of bytes bytes). 
bs = bytes and set the size of the block is read bytes, and can replace ibs obs. 
cbs = bytes bytes bytes conversion, i.e. conversion buffer size. 
skip skip = blocks from beginning of the input block file before starting copying blocks. 
seek = blocks skipped blocks from the beginning of the output file before starting copying blocks. (Usually only when the output file is valid only when the disk or tape).
count = blocks copy only blocks block, the block size is equal to the number of bytes specified by ibs. 
conv = conversion [, conversion ...] conversion parameter specified file. 
iflag = FLAGS FLAGS designated read mode, see "the FLAGS Parameter Description"
oflag = FLAGS write the specified manner FLAGS, see "FLAGS Parameter Description"

Copy the code

conv conversion parameters:

Copy the code

ascii convert EBCDIC to ASCII. 
ebcdic convert ASCII to EBCDIC. 
ibm convert ASCII to alternate EBCDIC. 
converting the block length of each line cbs recording, the shortage is filled with spaces. 
unblock the length of the every row, and the gap is filled with spaces cbs. 
lcase to uppercase characters converted to lowercase characters. 
ucase to lowercase characters converted to uppercase. 
Each swab exchange input byte. 
noerror not stop error. 
notrunc not truncate the output file.
each input sync block is filled into ibs bytes, less than some empty (the NUL) character filled.  

Copy the code

FLAGS Parameter Description:

Copy the code

append -append  mode  (makes  sense  only  for output; conv=notrunc sug-gested)

direct IO direct mode read and write data;
directory fail unless a directory to read and write;
the IO read data synchronous dsync;
sync as above, but for metadata
fullblock              堆积满block(accumulate full blocks of input )(iflag only);
nonblock non-blocking read and write data IO mode
noatime do not update access time to read and write data

Copy the code

Published 130 original articles · won praise 105 · Views 200,000 +

Guess you like

Origin blog.csdn.net/THMAIL/article/details/103892139