Use of dd tool and SSD sequential write performance test

Use the dd tool:

dd is also a disk testing tool that we often use. After installing the system on the Linux server, we want to know whether the reading and writing of the hard disk can meet the needs of the service. If the IO of the hard disk cannot be met, it will be a bottleneck of the service. We can simply use the dd command to test:

Time has a timing function, dd is used for copying, reading from if and writing to of. if=/dev/zero does not generate IO, so it can be used to test pure write speed. In the same way, of=/dev/null does not generate IO and can be used to test pure reading 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 written blocks.

dd test pure write speed:

[root@docker sda]# time dd if=/dev/zero of=/mnt/sda/ddout bs=8k count=1000000
1000000+0 records in
1000000+0 records out
8192000000 bytes (8.2 GB, 7.6 GiB) copied, 43.1081 s, 190 MB/s

real    0m43.110s
user    0m0.207s
sys    0m3.914s

dd test pure reading speed:

[root@docker sda]# time dd if=/mnt/sda/ddout of=/dev/null bs=8k count=1000000
1000000+0 records in
1000000+0 records out
8192000000 bytes (8.2 GB, 7.6 GiB) copied, 1.30322 s, 6.3 GB/s

real    0m1.306s
user    0m0.199s
sys    0m1.102s

dd tests the read and write speed, which is to read the current disk file and then write it to the current disk. To a certain extent, the greater the amount of copying, the longer the reading and writing time, and the more accurate the statistical results will be. However, the test results contain less information and can only be used as a reference. For more read and write modes and test information, you can use the dd command parameters to configure:

Use the three variables conv, iflag and oflag to configure the copy module mode, read mode and write mode of the dd command.

The dd command bypasses the system cache:

如果要规避掉文件系统cache,直接读写,不使用buffer cache,需做这样的设置
iflag=direct,nonblock
oflag=direct,nonblock

Three classic ways to use the dd command:

dd if=/dev/zero of=test bs=64k count=16k is inaccurate. There may be data in the kernel cache that is not synchronized to the disk. Key data should be marked with fsync to prevent key data from being lost;

dd if=/dev/zero of=test bs=64k count=16k conv=fsync is more reliable, but it takes a long time. It will write data and file metadata to the disk before the end of dd;

dd if=/dev/zero of=test bs=64k count=4k oflag=dsync or sync writes to the disk every time it is written. In actual operation, you can hear the sound of the disk and it takes a long time;

SSD performance test:

PCIe-SSD Optane:  dd if=/dev/urandom of=./optane.bin bs=256k count=102400 (write 25GB of random data sequentially) 

M.2-STAT-SSD:  dd if=/dev/urandom of=./m2sata.bin bs=256k count=102400 (write 25GB of random data sequentially) 

M.2-NVMe-SSD:  dd if=/dev/urandom of=./m2nvme.bin bs=256k count=102400 (write 25GB of random data sequentially) 

HDD:  dd if=/dev/urandom of=./sata.bin bs=256k count=102400 (write 25GB of random data sequentially) 

Guess you like

Origin blog.csdn.net/qq_35273918/article/details/132561342