This article describes how to use the dd command to test the disk read/write speed in linux. For more information, see
1. familiarize yourself with two special devices:
(1)/dev/null: Recycle Bin and bottomless pit.
(2)/dev/zero: generate characters.
2. test the disk write capability
Copy codeThe code is as follows:
Time dd if =/dev/zero of =/testw. dbf bs = 4 k count = 100000
Because/dev // zero is a pseudo device, it only produces a null compaction stream and does not generate IO for it. Therefore, IO is concentrated in the of file, and the of file is only used for writing, therefore, this command is equivalent to testing the disk write capability. Adding oflag = direct at the end of the command will skip the memory cache, and adding oflag = sync will skip the hdd cache.
3. test the disk read capability
Copy codeThe code is as follows:
Time dd if =/dev/sdb of =/dev/null bs = 4 k
Because/dev/sdb is a physical partition, reading it will generate IO,/dev/null is a pseudo device, which is equivalent to a black hole, of this device will not generate IO, so, the IO of this command only occurs on/dev/sdb, which is equivalent to testing the disk's read capability. (Ctrl + c terminate the test)
4. test the simultaneous read/write capability
Copy codeThe code is as follows:
Time dd if =/dev/sdb of =/testrw. dbf bs = 4 k
In this command, one is a physical partition, and the other is an actual file. IO will be generated for reading and writing them (for/dev/sdb, read, for/testrw. dbf is write). if they are all in one disk, this command is equivalent to testing the disk's simultaneous read/write capability.