Guest User

Untitled

a guest
Dec 10th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # ./badb.sh /dev/sdd 0.9
  4. # starts from 90th% block of the device using 4k blocks.
  5.  
  6. DEV=$(basename $1)
  7. BLOCKS=$(cat /proc/partitions| grep $DEV| awk 'NR==1{ print $3 } ')
  8. SIZE=1024
  9. NB=4
  10. BSIZE=$(( SIZE * NB ))
  11.  
  12. echo "total 1k blocks: $BLOCKS"
  13. BLOCKS=$(( BLOCKS / NB - 1 ))
  14. echo "total ${NB}k blocks: $BLOCKS"
  15.  
  16. START=0
  17. if [ -n $2 ]; then
  18. START=$(echo "$BLOCKS * $2"| bc)
  19. START=$(printf "%.0f" $START )
  20. fi
  21. echo "start block: $START"
  22.  
  23. sudo umount ${1}1 || true
  24. sudo badblocks -nsv -b $BSIZE -p 1 -c 32768 -o badblocks-$DEV.txt $1 $BLOCKS $START
Add Comment
Please, Sign In to add comment