# Configuration of Device, blocksize to read, OS blocksize of /proc/partitions, number of # cycles after which status is printed and output filename prefix BS="2097152" OS_BS="1024" DEVICE="sdb" SKIPOUT=4 PREFIX="apple_edm" # Aquiry of number of blocks via /proc/partitions using ugly sed commands and calculation # of number of reads to do from the device BLOCKS="$(grep ${DEVICE}$ /proc/partitions | sed -e 's/[ ]*[0-9]*[ ]*[0-9]*[ ]*//' -e 's/[ ]*[a-zA-Z]*$//')" SKIP=$(( $BS / $OS_BS )) READS=$(( ( $BLOCKS +1 ) / $SKIP )); # Some Counter initialisation COUNTER=0 OUT=-1; # Output of User information echo "$BLOCKS blocks in device '$DEVICE' lead to $READS reads of $BS bytes"; echo "" > ${PREFIX}_${DEVICE}; echo "Output goes to ./${PREFIX}_${DEVICE}"; echo -n "Reading and checksuming Blocks: "; # As long as there are blocks left to read while [ "$COUNTER" -lt "$READS" ]; do OUT=$(( $OUT + 1 )); # If its time to output something, do so if [ "$OUT" -eq "$(( $SKIPOUT - 1 ))" ]; then echo -n "[$(( $COUNTER - $SKIPOUT + 1 )) - $(( $COUNTER ))] "; OUT=-1; fi; # Read and checksum block and put the result in this variable SUM=$( dd if=/dev/$DEVICE bs=$BS skip=$COUNTER count=1 2>/dev/null | md5sum ); # Write that to the file echo "SUM $SUM READ $COUNTER" >> ${PREFIX}_${DEVICE}; COUNTER=$(( $COUNTER + 1 )); done # Done