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:
Let's break down the options used in this command:¶
--filename=/dev/sdX: Specifies the device file of the disk to be tested. ReplaceXwith 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 includewrite,randread,randwrite, andrw.--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/swrite: The average write bandwidth in MB/siops: The average number of I/O operations per secondlat: 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
Sequential Write
Random Read
Random Write
SSD Tests¶
Here are some examples of FIO commands for testing SSD performance:
Sequential Read
SSD Tests (continued)
Sequential Read
Sequential Write
Random Read
Random Write
Note:¶
- Replace
/dev/sdXwith the actual device file of the HDD you want to test. - Replace
/dev/nvme0n1with the actual device file of the SSD you want to test. - Adjust the
--sizeoption to test a larger or smaller amount of data. - Adjust the
--runtimeoption to test for a longer or shorter period of time. - Use the
--outputoption 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.