Created
October 29, 2012 05:25
-
-
Save sennajox/3971730 to your computer and use it in GitHub Desktop.
a simple script for testing disk...
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
#!/bin/bash | |
if [ $# -lt 1 ]; then | |
echo "usage:$0 dev" | |
exit | |
fi | |
dev="$1" | |
echo "it will rw the dev:$dev, are you sure?[Y/n]" | |
read cmd | |
case "$cmd" in | |
y|Y|Yes|yes) | |
;; | |
*) | |
exit 1 | |
;; | |
esac | |
input="./time.input" | |
output="./time.output" | |
# write time into a temp file | |
while [ 1 ]; | |
do | |
time=`date +%s` | |
echo "$time""k" > "$input" | |
for((i=1;i<=250;i++)); | |
do | |
echo "0" >> "$input" | |
done | |
# write | |
dd if="$input" of=$dev bs=512 count=1 oflag=direct | |
# read | |
dd if=$dev of="$output" bs=512 count=1 iflag=direct | |
diff "$input" "$output" | |
ret=$? | |
if [ $ret -ne 0 ]; then | |
echo "It\'s different" | |
fi | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment