Last active
October 8, 2022 15:04
-
-
Save tanasecosminromeo/f9445901b24de37680f5db6ab8677370 to your computer and use it in GitHub Desktop.
HDD Speed Check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $# -eq 0 ] | |
then | |
echo "Usage ./test-hdd.sh /mounted-path-of-hdd [size-in-Mb]" | |
exit; | |
fi | |
actualDisk=$(df $1 | grep dev | cut --d ' ' -f1) | |
#echo Running hdparm -Tt $actualDisk | |
#result=$(hdparm -Tt $actualDisk) | |
testHDD () { | |
write=$(dd if=/dev/zero of=$1/tempfile bs=1M count=$2 2>&1) | |
write=$(echo ${write##*s,}) | |
readWcache=$(dd if=$1/tempfile of=/dev/null bs=1M count=$2 2>&1) | |
readWcache=$(echo ${readWcache##*s,}) | |
/sbin/sysctl -w vm.drop_caches=3 > /dev/null | |
readNOcache=$(dd if=$1/tempfile of=/dev/null bs=1M count=$2 2>&1) | |
readNOcache=$(echo ${readNOcache##*s,}) | |
rm -rf $1/tempfile 2>&1 | |
echo -e "$2Mb\t$write\t$readWcache\t$readNOcache" | |
} | |
echo "Testing $1 (${actualDisk})" | |
echo -e "Size\tWrite Speed\tReadWcache\tReadNOcache" | |
if [ -z "$2" ] | |
then | |
testHDD $1 1 | |
testHDD $1 32 | |
testHDD $1 128 | |
testHDD $1 512 | |
else | |
testHDD $1 $2 | |
fi | |
#echo Running fio on $1/test-fio | |
#fio --name=fiotest --filename=$1/test-fio --size=50Mb --rw=randread --bs=8K --direct=1 --numjobs=8 --ioengine=libaio --iodepth=32 --group_reporting --runtime=60 --startdelay=60 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why
Test different speed of devices / adaptors for a Raspberry Pi 4
Example results
HDD USB3
SSD USB3
SDCard
Test specific 10Mb on SDCard