Last active
November 7, 2024 18:35
-
-
Save kraftwerk28/a6e63ae138a337fd2454ef5d88bec5b3 to your computer and use it in GitHub Desktop.
Disk benchmarking using dd
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
#!/usr/bin/bash | |
set -eo pipefail | |
if [[ $1 =~ (-h|--help) ]]; then | |
echo "Usage: $0 [file on mounted drive]" | |
exit 1 | |
fi | |
tmpfile=${1:-$(mktemp)} | |
echo "I/O with $tmpfile will be performed..." | |
echo | |
echo "Write:" | |
dd if=/dev/zero of=$tmpfile bs=1M count=1024 conv=fdatasync,notrunc status=progress | |
echo 3 | sudo tee /proc/sys/vm/drop_caches > /dev/null | |
echo | |
echo "Read:" | |
dd if=$tmpfile of=/dev/null bs=1M count=1024 status=progress | |
echo | |
echo "Cached read:" | |
dd if=$tmpfile of=/dev/null bs=1M count=1024 status=progress |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment