Skip to content

Instantly share code, notes, and snippets.

@innateessence
Last active June 28, 2024 01:48
Show Gist options
  • Save innateessence/9ede443c2af67f0b4e8a14849c9815c1 to your computer and use it in GitHub Desktop.
Save innateessence/9ede443c2af67f0b4e8a14849c9815c1 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-ones}
function write(){
dd if=/dev/zero bs=4M count=1 2> /dev/null | tr "\0" "\377" > "$file" # write ones
}
function verify(){
while IFS= read -r line; do
if [[ "$line" != "11111111" ]]; then
echo "Error: $line"
exit 1
fi
done < "$file"
}
function Main(){
write
verify
echo "All ones 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