Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to use the dd command to test the read and write speed of Linux disks

Shulou Source: shulou.com Published: 2022-06-01 16:23:29 10月04日 Update

This article mainly introduces "how to use dd command to test the read and write speed of Linux disk", in daily operation, I believe many people have doubts on how to use dd command to test the read and write speed of Linux disk, Xiaobian consulted all kinds of information, sorted out simple and easy to use operation method, hope to answer "how to use dd command to test the read and write speed of Linux disk" doubts helpful! Next, please follow the small series to learn together!

In order to test the read and write speed of Linux disk, you can use dd command, dd command is a very useful command, can be used for file copy, the following small series will give you an introduction to how to use dd command to test the read and write speed of Linux disk.

First, get familiar with two special equipment:

(1)/dev/null: Recycle bin, bottomless pit.

(2)/dev/zero: generates characters.

2. Test disk write ability

The code is as follows:

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

Because/dev//zero is a pseudo-device, it only generates empty character streams and does not generate IO for it, so IO is concentrated in the of file, which is only used for writing, so this command is equivalent to testing the disk's write ability. Adding oflag=direct at the end of the command skips the memory cache, adding oflag=sync skips the hdd cache.

3. Test disk reading ability

The code is as follows:

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

Because/dev/sdb is a physical partition, reads to it will generate IO,/dev/null is a pseudo-device, equivalent to a black hole, of to this device will not generate IO, so the IO of this command only occurs on/dev/sdb, which is equivalent to testing the read ability of the disk. Ctrl+C stops the test.

4. Test simultaneous reading and writing ability

The code is as follows:

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

Under this command, one is a physical partition and one is an actual file. Reading and writing to them will generate IO (read to/dev/sdb and write to/testrw.dbf). Assuming they are all on a disk, this command is equivalent to testing the simultaneous read and write ability of the disk.

At this point, the study on "how to use dd command to test the read and write speed of Linux disk" is over, hoping to solve everyone's doubts. Theory and practice can better match to help everyone learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!

Tags: Commands tests disks speed capabilities files devices learning code at the same time more physics caching help practical special next two memory recycle bin Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple vpn Xiaomi Shulou Information Redmi