Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to test the read and write speed of linux disk with dd command

Shulou Source: shulou.com Published: 2022-06-01 12:16:21 10月03日 Update

This article mainly explains "how to use the dd command to test the linux disk read and write speed", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "how to use the dd command to test the linux disk read and write speed" bar!

1. Familiarize yourself with two special devices:

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

(2) / dev/zero: generates characters.

2. Test disk writing 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 an empty character stream and does not generate IO for it, so IO is concentrated in of files and of files are only used for writing, so this command is equivalent to testing disk write ability. Adding oflag=direct at the end of the command skips the memory cache, and adding oflag=sync skips the hdd cache.

3. Test disk read ability

The code is as follows:

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

Because / dev/sdb is a physical partition, reading it will result that IO,/dev/null is a pseudo device, which is equivalent to a black hole, and of to this device will not generate IO, so the IO of this command only occurs on / dev/sdb, which is also equivalent to testing the read ability of the disk. (Ctrl+c terminates the test)

4. Test the ability to read and write at the same time

The code is as follows:

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

Under this command, one is the physical partition and the other is the actual file, and IO is generated for both reading and writing to them (read to / dev/sdb and write to / testrw.dbf). Assuming they are all on the same disk, this command is equivalent to testing the disk's read and write ability at the same time.

Thank you for your reading, the above is the content of "how to use dd command to test linux disk read and write speed". After the study of this article, I believe you have a deeper understanding of how to use dd command to test linux disk read and write speed, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Test disk command capability speed device code file learning content at the same time physics cache special two memory recycle bin characters actually Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Technology Shulou Information Shulou Tech Info Linux