Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This script is trying to produce the same stats as CrystalDiskMark for Windows using fio.
#!/bin/bash -eu
# This script is trying to produce the same stats as CrystalDiskMark for Windows
# using fio.
# If you specify the raw disk (like /dev/sdc) the all it's content will be removed!
# The script should not run longer than 20 minutes
TMP_FILE=${TMP_FILE:-/tmp/$(basename $0).tmp}
UNATTENDED=${UNATTENDED:-0}
if [ "$#" -ne 1 ]; then
echo -e "\nYou need to specify at least one parameter"
echo -e "For example: $0 /dev/sdg\n"
exit 1
fi
DEV=$1
if [ "${UNATTENDED}" = 0 ]; then
cat << EOF
!!! Everything will be removed form ${DEV} !!!
$(lsblk --output NAME,MODEL,MODEL | grep $(basename ${DEV}))
Press ENTER to continue...
EOF
read A
fi
fio --runtime=2m --filename=${DEV} --stonewall --ioengine=libaio --direct=1 --gtod_reduce=1 --eta-newline=10 --output-format=json --size=1G --output=${TMP_FILE} \
--name=SeqQ32T1_read --bs=512k --iodepth=32 --numjobs=1 --rw=read \
--name=SeqQ32T1_write --bs=512k --iodepth=32 --numjobs=1 --rw=write \
--name=4kQ8T8_read --bs=4k --iodepth=8 --numjobs=8 --rw=randread --group_reporting=1 \
--name=4kQ8T8_write --bs=4k --iodepth=8 --numjobs=8 --rw=randwrite --group_reporting=1 \
--name=4kQ32T1_read --bs=4k --iodepth=32 --numjobs=1 --rw=randread \
--name=4kQ32T1_write --bs=4k --iodepth=32 --numjobs=1 --rw=randwrite \
--name=4kQ1T1_read --bs=4k --iodepth=1 --numjobs=1 --rw=randread \
--name=4kQ1T1_write --bs=4k --iodepth=1 --numjobs=1 --rw=randwrite
echo -e "\n\n"
(
echo -e "Test Write MB/s | Read MB/s\n---------------"
jq -r '.jobs[] | .jobname + ": " + (.write.bw_bytes/1024/1024|tostring) + " MB/s | " + (.read.bw_bytes/1024/1024|tostring) + " MB/s" ' ${TMP_FILE} | sed 's/\.\(....\)[^ ]*/.\1/'
) | column -t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.