Skip to content

Instantly share code, notes, and snippets.

@djfm
Created November 23, 2023 20:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djfm/502d6015580a3a2a038eecbab56929e8 to your computer and use it in GitHub Desktop.
Save djfm/502d6015580a3a2a038eecbab56929e8 to your computer and use it in GitHub Desktop.
Try to saturate a hard-disk to check its capacity using standard Linux commands
#!/bin/env bash
target="$1"
if ! [ -d "$target" ]; then
echo "Usage: $0 <directory>"
exit 1
fi
#supposed capacity of the disk in GB
num_tbs=32000
gs=4
(("count = $num_tbs / $gs"))
for i in $(seq 1 "$count"); do
of=$(printf "file-%05d" "$i")
file="$target/$of"
echo "writing ${gs}G to $file..."
dd if=/dev/random of="$file" bs="$gs"G count=1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment