How to Benchmark Disk I/O Speed on Linux

Avatar

Jennifer

Dec 7, 2019

On linux, there is a dd command, which is normally used for disk cloning.

However, since it has a status option, we can also use it for the purpose of benchmarking I/O speed.

For example, if we want to run speed test with the following conditions:

  • Write 1024 bytes to the disk at a time
  • Write a million blocks in total
  • The current directory is the place where we want to test

, we can simply run:

dd status=progress bs=1024 count=1000000 if=/dev/zero of=zero 

This command will read the data from /dev/zero and write it to ./zero, and update the latest I/O speed every second. When the operation is completed, it will print out the following result:

1000000+0 records in
1000000+0 records out
1024000000 bytes (1.0 GB, 977 MiB) copied, 3.37318 s, 304 MB/s

Similarly, if we wanna to test the read speed, we first need to create a large file at the location where we want to test:

truncate -s 1G ./example_1g

Then, we simply reverse the input and output files of the previous command:

dd status=progress bs=1024 count=1000000 if=./example_1g of=/etc/null

An example result looks like:

1000000+0 records in
1000000+0 records out
1024000000 bytes (1.0 GB, 977 MiB) copied, 4.85039 s, 211 MB/s

Copyright ©Jennifer