Last active
June 28, 2024 01:48
-
-
Save innateessence/9ede443c2af67f0b4e8a14849c9815c1 to your computer and use it in GitHub Desktop.
Script to verify your storage device is writing bits correctly
This file contains 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/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.