Location>code7788 >text

Linux system test disk IO speed - fio use

Popularity:532 ℃/2025-03-05 10:58:52

******* Very important, very useful, very awesome scripts for testing disk io speed in Linux
1 Installation tool library
Install fio

First, you need to install fio. The installation method may vary in different Linux distributions.
Fio can be used directly through command line parameters, or it can be used to define complex test scenarios through configuration files.

Click to view the code
Debian/Ubuntu
 
sudo apt-get update
sudo apt-get install fio


CentOS/RHEL

sudo yum install epel-release
sudo yum install fio


  1. Create a MakeFile file and execute the following script directly by making command. Very fast.
    Very good.
Click to view the code
# Define variables
 FIO_CMD = fio
 #Change the device here
 FILENAME = /dev/nvme1n1p2

 DIRECT = 0
 #Random read randread write randwrite mixed read and write randrw
 RW = randrw
 #Block size is 4KB
 BS = 1024k
 #Change the test size here
 SIZE = 100G
 NUMJOBS = 64
 #Modify the run time here
 RUNTIME = 60
 #Summarize the results of all jobs
 GROUP_REPORTING = 1
 NAME = test
 #Name file with timestamp
 LOG_FILE = LOG_FILE = fio_test_$(shell date +%Y%m%d_%H%M%S).log

 # Define the fio command
 FIO_ARGS = --filename=$(FILENAME) \
            --direct=$(DIRECT) \
            --rw=$(RW) \
            --bs=$(BS) \
            --size=$(SIZE) \
            --numjobs=$(NUMJOBS) \
            --runtime=$(RUNTIME) \
            --group_reporting=$(GROUP_REPORTING) \
            --name=$(NAME) \
            --status-interval=1

 # Default target
 all: test

 # Run the fio test and save the output to the log file
 test:
	 @echo "Running fio test..."
	 $(FIO_CMD) $(FIO_ARGS) | tee $(LOG_FILE) #Save logs and display them in real time
	 @echo "Test completed. Log saved to $(LOG_FILE)."

 # Clean the log files
 clean:
	 @echo "Cleaning up..."
	 rm -f $(LOG_FILE)



 .PHONY: all test clean help