Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # ./badb.sh /dev/sdd 0.9
- # starts from 90th% block of the device using 4k blocks.
- DEV=$(basename $1)
- BLOCKS=$(cat /proc/partitions| grep $DEV| awk 'NR==1{ print $3 } ')
- SIZE=1024
- NB=4
- BSIZE=$(( SIZE * NB ))
- echo "total 1k blocks: $BLOCKS"
- BLOCKS=$(( BLOCKS / NB - 1 ))
- echo "total ${NB}k blocks: $BLOCKS"
- START=0
- if [ -n $2 ]; then
- START=$(echo "$BLOCKS * $2"| bc)
- START=$(printf "%.0f" $START )
- fi
- echo "start block: $START"
- sudo umount ${1}1 || true
- sudo badblocks -nsv -b $BSIZE -p 1 -c 32768 -o badblocks-$DEV.txt $1 $BLOCKS $START
Add Comment
Please, Sign In to add comment