Skip to content

Instantly share code, notes, and snippets.

@kraftwerk28
Last active November 7, 2024 18:35
Show Gist options
  • Save kraftwerk28/a6e63ae138a337fd2454ef5d88bec5b3 to your computer and use it in GitHub Desktop.
Save kraftwerk28/a6e63ae138a337fd2454ef5d88bec5b3 to your computer and use it in GitHub Desktop.
Disk benchmarking using dd
#!/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