Advertisement
zefie

wipe dying disk

Jan 15th, 2018
443
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.71 KB | None | 0 0
  1. #!/bin/bash
  2. DISK="/dev/disk/by-id/ata-WDC_WD20NMVW-59AV3S3_WD-WXQ1EA4F4HS2"
  3. MAX_SECTORS=$(hdparm -I ${DISK} | grep sectors | grep LBA48 | rev | cut -d' ' -f1 | rev)
  4. JUMP=64
  5. LAST=$(cat last)
  6.  
  7. while [ ${LAST} -lt ${MAX_SECTORS} ]; do
  8.         if [ $(expr ${LAST} + ${JUMP}) -lt ${MAX_SECTORS} ]; then
  9.                 DIFF=${JUMP}
  10.         else
  11.                 DIFF=${MAX_SECTORS} - ${LAST}
  12.         fi
  13.         RANGEEND=$(expr ${LAST} + ${DIFF})
  14.  
  15.         for i in $(seq ${LAST} ${RANGEEND}); do
  16.                 hdparm --yes-i-know-what-i-am-doing --write-sector ${i} ${DISK} 2>&1 | grep "sector" | awk '{printf "%s\r", $0}'
  17.         done;
  18.         LAST=$(expr ${LAST} + ${DIFF} + 1)
  19.         echo -n ${LAST} > last
  20. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement