in Linux

How to test disk performance in Linux

A lot of performance issues can be caused by poor disk performance. Here’s how to test the read and write performance on a Linux system using dd.

1. Write a file 2x the size of the RAM to make sure we get the real write rate. In this example the RAM of the server is 1 GB so I’m writing a 2 GB file (8KB * 250000 = 2GB). You can adjust the number of blocks to make it suitable for the amount of RAM in your system .

time sh -c "dd if=/dev/zero of=ddfile bs=8k count=250000 && sync"

2. Write a new file equal to the amount of RAM in the system to flush out the data cached with last action (8KB * 125000 = 1GB).

dd if=/dev/zero of=ddfile2 bs=8K count=125000

3. Test the read speed

time dd if=ddfile of=/dev/null bs=8k