Google has provided a fantastic guide on how to use fio to benchmark persistent disk performance: Benchmarking persistent disk performance on a Linux VM
I’ve used it a few times and while it certainly does the job, I needed a script that would do (almost) everything automatically in order to cut my time commitment each time I needed to run it on a new system. Before you use my script, please head over to Google’s documentation and make sure you understand what we’re doing.
First, let’s go over the workflow. I won’t paste the code itself here, as it will probably change over time. I do have code comments that should help you understand where we’re doing at each step, so reference those and let me know if I’ve missed anything!
- Clear the screen to give us a clean slate while running the script
- Set colors for the console output
- Make sure we’re running the script as root (for the install of fio). This is not necessary to RUN the tool. If you’d like to comment out this line, you may do so, ensuring that you’ve already got fio installed.
- Check if fio is installed and install it if it’s missing
- Double check that the installation was successful and exit if it was not.
- Prompt user to input the directory path where fio will store the test and log files.
- Fio will then check if the path exists and create the directory is not currently present on the system.
- Check available space on the storage device.
- We want to use enough space to properly test the drive, but not so much that we exceed the drive capacity. If you have very large drives, you may elect to manually set this value, but for most systems, this should work. Drives with less than 16GB available will not be able to use this script.
- Run fio!
- I’m using the variables defined in the Google documentation, with some customizations in order for the script to properly execute (FILE_SIZE and TEST_DIR).
- Fio will execute with 16 threads for the IOPS tests.
- While running, if you open a second connection to the host, you will see the test files and a log file named “fio_output.txt”. You may tail this file while the tests are running or simply access it when the tests are done.
- The tests will take approximately 1 minute per test. Go grab a cup of coffee and check the log when you’re back
To access the latest version of the script, please head over to Flatiron Code.
You may also simply run the curl command below:
curl https://code.flatironnetworks.com/rfauls/robfauls.com-scripts/raw/branch/main/Linux/Debian/Testing/fio-testdiskspeed.sh --output disktest.sh
While I love sharing the things that I’ve learned over time, I could use a hand, both with content ideas and help getting that content out to people. If you’ve got any ideas on what I should post up or would like to submit content that you think others will find useful, holler at me and we can start making “cool stuff” together!