You are right. Here is a new version with a call to 'sync' (and an 'exit' after a corrupted write):

#!/bin/sh

DEVICE=/dev/sdaX

while true
do
    counter=`expr $counter + 1`
    md5=`cat /dev/urandom | tee $DEVICE | md5sum`
    sync
    if [ "$md5" = "`cat $DEVICE | md5sum`" ]
    then
        echo $counter successful iterations
    else
        echo iteration $counter was corrupted
        exit
    fi
done

Reply via email to