Skip to content

Instantly share code, notes, and snippets.

@innateessence
Last active June 28, 2024 01:48
Show Gist options
  • Save innateessence/aa4ce00686a63ba384da960c454223b4 to your computer and use it in GitHub Desktop.
Save innateessence/aa4ce00686a63ba384da960c454223b4 to your computer and use it in GitHub Desktop.
Script to verify your storage device is writing bits correctly
#!/usr/bin/env bash
file=${1-zeros}
function write(){
dd if=/dev/zero bs=4M count=1 2> /dev/null > "$file" # Write zeros
}
function verify(){
while IFS= read -r line; do
if [[ "$line" != "00000000" ]]; then
echo "Error: $line"
exit 1
fi
done < "$file"
}
function Main(){
write
verify
echo "All zeros verified successfully!"
}
Main
@innateessence
Copy link
Author

In practice, you'd want to test the entire drive, which would overwrite the partitions.

Wanted to verify something and wrote a couple of quick and dirty scripts for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment