Screen Shot 2019-01-05 at 17.29.36.png dd command, that is pretty much guaranteed to be pre-installed on your Linux or Unix server, can be used to quickly get an understanding of the I/O capability of available storage.
Although there are specialised file processing and I/O benchmarks, you may not always have the time or permission to install additional packages. That’s why using is one of the easiest ways to understand the storage you’re working with.
In this example, I’m creating a 1GB file using a fairly large block size of 512KB:
That’s a pretty impressive throughput! If the filesystem we’re testing this on is hosted on a single disk, it must be an SSD one. Similar results may be achieved using a software RAID from HDDs.
If you apply logic and reverse the if and of parameters from the previous example, you will arrive at the following dd command testing the speed of reading from ./test file:
If you try running it though, you’ll have 2 problems.
Problem 1: you get an error if you attempt direct I/O (oflag=direct) with a virtual device like /dev/zero:
Problem 2: even if we remove the oflag=direct, results seem to be too good to be true:
Slightly better I/O for reading is always expected, but such a dramatic improvement is usually false. As you may have guessed, we get such high numbers because of I/O caching that OS cleverly applies when working with files.
Caching is done in such a way that kernel would cache I/O as long as it has unused memory. As soon as some process needs memory though, the kernel would release it by dropping some clean caches
So for the correct read speed test with dd, we need to disable I/O caching using this command line :
… and then re-run the same dd command again:
That’s better! 509MB/s read throughput is in line with the 356MB/s write throughput.