Skip to content

Using FIO for Disk Speed Testing in Linux Shell

Introduction

FIO (Flexible I/O Tester) is a popular open-source tool for benchmarking and testing storage devices, including hard drives, solid-state drives (SSDs), and network storage. In this article, we will explore how to use FIO for disk speed testing in the Linux shell.

Installing FIO

To install FIO on your Linux system, you can use the package manager for your distribution. Here are the installation commands for some popular Linux distributions:

  • Ubuntu/Debian: sudo apt-get install fio
  • Red Hat/CentOS: sudo yum install fio
  • Fedora: sudo dnf install fio
  • Arch Linux: sudo pacman -S fio

Basic FIO Command

The basic FIO command for disk speed testing is:

fio --name=job_name --filename=/dev/sdX --rw=read --bs=4k --size=1G --numjobs=1 --iodepth=1 --runtime=60 --group_reporting

Let's break down the options used in this command:

  • --filename=/dev/sdX: Specifies the device file of the disk to be tested. Replace X with the actual device letter (e.g., sda, sdb, etc.).
  • --rw=read: Specifies the type of I/O operation to perform. In this case, we're testing read performance. Other options include write, randread, randwrite, and rw.
  • --bs=4k: Specifies the block size used for the I/O operations. In this case, we're using a block size of 4KB. Other common block sizes include 512B, 1KB, and 8KB.
  • --size=1G: Specifies the total size of the I/O operations. In this case, we're testing with a total size of 1GB.
  • --numjobs=1: Specifies the number of concurrent I/O jobs to run. In this case, we're running a single job.
  • --iodepth=1: Specifies the I/O depth, which is the number of outstanding I/O operations. In this case, we're using an I/O depth of 1.
  • --runtime=60: Specifies the runtime of the test in seconds. In this case, we're running the test for 60 seconds.
  • --group_reporting: Enables group reporting, which allows FIO to report aggregated results for multiple jobs.

Interpreting FIO Results

When you run the FIO command, it will display a summary of the results, including:

  • read: The average read bandwidth in MB/s
  • write: The average write bandwidth in MB/s
  • iops: The average number of I/O operations per second
  • lat: The average latency in milliseconds

You can also use the --output option to specify a file where FIO will write the detailed results.

Advanced FIO Options

FIO provides many advanced options for customizing the test. Here are a few examples:

  • --randrepeat: Enables random repeat testing, which repeats the test with different random data.
  • --norandommap: Disables the use of a random map for the test.
  • --sync: Enables synchronous I/O operations.
  • --direct: Enables direct I/O operations.
  • --buffered: Enables buffered I/O operations.

You can use these options to customize the test to suit your specific needs.

HDD Tests

Here are some examples of FIO commands for testing HDD performance:

Sequential Read

fio --name=job_name --filename=/dev/sdX --rw=read --bs=4k --size=1G --numjobs=1 --iodepth=1 --runtime=60 --group_reporting

Sequential Write

fio --name=job_name --filename=/dev/sdX --rw=write --bs=4k --size=1G --numjobs=1 --iodepth=1 --runtime=60 --group_reporting

Random Read

fio --name=job_name --filename=/dev/sdX --rw=randread --bs=4k --size=1G --numjobs=1 --iodepth=1 --runtime=60 --group_reporting

Random Write

fio --name=job_name --filename=/dev/sdX --rw=randwrite --bs=4k --size=1G --numjobs=1 --iodepth=1 --runtime=60 --group_reporting

SSD Tests

Here are some examples of FIO commands for testing SSD performance:

Sequential Read

fio --name=job_name --filename=/dev/nvme0n1 --rw=read --bs=4k --size=1G --numjobs=1 --iodepth

SSD Tests (continued)

Sequential Read

fio --name=job_name --filename=/dev/nvme0n1 --rw=read --bs=4k --size=1G --numjobs=1 --iodepth=1 --runtime=60 --group_reporting

Sequential Write

fio --name=job_name --filename=/dev/nvme0n1 --rw=write --bs=4k --size=1G --numjobs=1 --iodepth=1 --runtime=60 --group_reporting

Random Read

fio --name=job_name --filename=/dev/nvme0n1 --rw=randread --bs=4k --size=1G --numjobs=1 --iodepth=1 --runtime=60 --group_reporting

Random Write

fio --name=job_name --filename=/dev/nvme0n1 --rw=randwrite --bs=4k --size=1G --numjobs=1 --iodepth=1 --runtime=60 --group_reporting

Note:

  • Replace /dev/sdX with the actual device file of the HDD you want to test.
  • Replace /dev/nvme0n1 with the actual device file of the SSD you want to test.
  • Adjust the --size option to test a larger or smaller amount of data.
  • Adjust the --runtime option to test for a longer or shorter period of time.
  • Use the --output option to specify a file where FIO will write the detailed results.

Conclusion

FIO is a powerful tool for disk speed testing in Linux. By using the basic FIO command and customizing the options to suit your needs, you can get a detailed understanding of your disk's performance. Remember to interpret the results carefully and use the advanced options to customize the test as needed.

The content provided is generated with the help of artificial intelligence (AI) and may contain inaccuracies or outdated information due to the limitations of AI. While I strive to review and validate the content, some errors or inaccuracies may still be present in the final output. Please use this content as a general guide only and verify any critical information through reputable sources before relying on it. I appreciate your understanding and feedback in helping us improve the accuracy and quality of our AI-generated content."