How to Benchmark Linux Disk Performance Using fio (Flexible I/O Tester)

Why Not Just Use dd?

Many system administrators attempt to test disk speed by running a simple dd command to write a large file. However, dd is a sequential, single-threaded tool that does not accurately reflect how modern databases and applications read and write data. fio (Flexible I/O Tester) is the industry standard for benchmarking storage. It simulates real-world workloads, allowing you to test random reads, concurrent threads, and specific queue depths to find the true IOPS (Input/Output Operations Per Second) of your storage arrays.

Step 1: Install fio

The fio tool is heavily utilized in enterprise environments and is readily available in standard package managers.

On Debian/Ubuntu systems:

sudo apt update && sudo apt install fio -y

On RHEL/CentOS systems (requires EPEL):

sudo yum install epel-release -y

sudo yum install fio -y

Step 2: Prepare a Testing Directory

You should run the benchmark in a directory located on the specific partition or disk you want to test. Navigate to that directory (for example, a newly mounted SSD):

cd /mnt/fast-storage

Warning: Avoid running write tests directly on raw block devices (e.g., /dev/sdb) unless they are entirely empty, as fio will destroy any existing filesystem. Always test against a mounted directory instead.

Step 3: Run a Random Read IOPS Test

The most common metric for database performance is Random Read IOPS. Run the following command to simulate 4 concurrent threads constantly requesting small (4K) blocks of data randomly across a 2 Gigabyte test file:

fio --name=random-read --ioengine=libaio --rw=randread --bs=4k --size=2G --numjobs=4 --iodepth=32 --direct=1

  • --ioengine=libaio: Uses the asynchronous Linux I/O engine.
  • --direct=1: Bypasses the OS RAM cache, testing the physical disk.
  • --iodepth=32: Keeps 32 requests in the queue at all times.

Step 4: Run a Random Write Test

To test how the disk handles random writes (critical for logging and transactional databases), simply change the --rw parameter to randwrite:

fio --name=random-write --ioengine=libaio --rw=randwrite --bs=4k --size=2G --numjobs=4 --iodepth=32 --direct=1

Step 5: Analyze the Output

When the test finishes, fio dumps a large amount of statistical data. Look for the line that starts with read: or write: depending on your test.

You will see a metric like IOPS=45.2k, BW=177MiB/s (185MB/s). The IOPS value is the most important number for random performance, while BW (Bandwidth) is more relevant for sequential reads/writes (like video streaming). You should document these numbers as a baseline to ensure your storage array is performing optimally.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.