Advertising
- Anonym
- Tuesday, February 26th, 2008 at 6:36:20am MST
- # 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
advertising
Update the Post
Either update this post and resubmit it with changes, or make a new post.
You may also comment on this post.
Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.