Last active
June 28, 2024 01:48
-
-
Save innateessence/aa4ce00686a63ba384da960c454223b4 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-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 |
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.