Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Anonym
Tuesday, February 26th, 2008 at 1:36:20pm UTC 

  1. # Configuration of Device, blocksize to read, OS blocksize of /proc/partitions, number of
  2. # cycles after which status is printed and output filename prefix
  3.  
  4. BS="2097152"
  5. OS_BS="1024"
  6. DEVICE="sdb"
  7. SKIPOUT=4
  8. PREFIX="apple_edm"
  9.  
  10.  
  11. # Aquiry of number of blocks via /proc/partitions using ugly sed commands and calculation
  12. # of number of reads to do from the device
  13. BLOCKS="$(grep ${DEVICE}$ /proc/partitions | sed -e 's/[ ]*[0-9]*[ ]*[0-9]*[ ]*//' -e 's/[ ]*[a-zA-Z]*$//')" SKIP=$(( $BS / $OS_BS ))
  14. READS=$(( ( $BLOCKS +1 ) / $SKIP ));
  15.  
  16.  
  17. # Some Counter initialisation
  18. COUNTER=0
  19. OUT=-1;
  20.  
  21. # Output of User information
  22. echo "$BLOCKS blocks in device '$DEVICE' lead to $READS reads of $BS bytes";
  23. echo "" > ${PREFIX}_${DEVICE}; echo "Output goes to ./${PREFIX}_${DEVICE}";
  24.  
  25. echo -n "Reading and checksuming Blocks: "; 
  26.  
  27. # As long as there are blocks left to read
  28. while [ "$COUNTER" -lt "$READS" ]; do
  29.   OUT=$(( $OUT + 1 ));
  30.  
  31.    # If its time to output something, do so
  32.   if [ "$OUT" -eq "$(( $SKIPOUT - 1 ))" ]; then
  33.     echo -n "[$(( $COUNTER - $SKIPOUT + 1 )) - $(( $COUNTER ))] ";
  34.     OUT=-1;
  35.   fi;
  36.  
  37.    # Read and checksum block and put the result in this variable
  38.   SUM=$( dd if=/dev/$DEVICE bs=$BS skip=$COUNTER count=1 2>/dev/null | md5sum );
  39.  
  40.    # Write that to the file
  41.   echo "SUM $SUM READ $COUNTER" >> ${PREFIX}_${DEVICE}; COUNTER=$(( $COUNTER + 1 ));
  42. done
  43.  
  44. # Done

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



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.

comments powered by Disqus
worth-right