RHEL / CentOS – I/O Performance Tests using dd


Linux contains many useful commands. Today, we present a few examples of using the dd command. dd can be used to copying data between files and devices. When dd is copying data, it can report the performance of the copy operation. This allows us to use dd to measure the read or write performance of a device or file system. In addition, based on the options passed to dd, it can be used to measure file system performance with and without a cache.

Measuring Write Performance

To measure write performance, we read from /dev/zero and write to a device (/dev/sdb), partition (/dev/sdb1) or file (/home/testuser/testfile).

Important: When writing to a device (such as /dev/sdb), or partition (/dev/sdb1) the data stored there will be lost. For that reason, you should use care when testing devices or partitions.

Our write test assumes /home/testuser/testfile is on device /dev/sda. It generates 13 gigabytes of data, first with the Linux filesystem cache activated:

# dd if=/dev/zero of=/home/testuser/testfile bs=8k count=102400

Then again with the cache deactivated:
# dd if=/dev/zero of=/home/testuser/testfile bs=8k count=102400 oflag=direct    
 

Measuring Read Performance

Our read test assumes /home/testuser/testfile is on device /dev/sda. To measure read performance, we write to /dev/null and read from our test file. Our read test uses 13 gigabytes of data, first with the cache activated:

# dd if=/home/testuser/testfile of=/dev/null bs=8k count=102400

Then again with the cache deactivated:
# dd if=/home/testuser/testfile of=/dev/null bs=8k count=102400 iflag=direct

Concurrently Measuring Read / Write Performance of all drives

It can be very useful to measure the read and write performance of all drives in a server at the same time. To do this task, we have created a bash shell script which needs to be modified for the server being measured. Click HERE to download the TestIO.sh sample script.

Leave a comment