How to test disk speed with dd on a linux machine

Testing the disk speed on a linux machine is quite simple. Just use the dd command: 

To use the dd command to measure disk speed, you’ll need the following flags:

  • if: input file. In this case the disk you’re testing (eg. /dev/zero)
  • of: outputfile. A file to read the output of the test. Can be any format for textfiles.
  • bs: sets the if and of sizes to bytes
  • count: number of blocks (1  ➡  1 block of 1G is copied)
  • oflag: we’re gonna use it to avoid the buffer cache. It makes stuff faster.

Now just combine these tasty ingredients flags into one command:

$ dd if=/dev/zero of=/root/testfile bs=1G count=1 oflag=direct

You’ll get a bunch of lines, after you execute this command. The most important is a line that looks like 32.474 s, 32.1 MB/s.

It means the actual disk speed was 32.1 MB/s.