Advertisement
markruff

secure erase

Dec 28th, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.96 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. #
  3. # This is dangerous!!
  4. #
  5. # Seriously!
  6. #
  7. # Use hdparam to securely erase a hard drive... yes. all gone.
  8. #
  9. # Author: Mark Ruff
  10. # Date: ??
  11. #
  12. # Revision: 29 Dec 2015
  13. #           Uses command line arg to get device to erase
  14. #
  15. # Seriously - be careful. Like chmod a-x just to be safe
  16.  
  17.  
  18. # check command line arg - should only be one. the block device to erase
  19. if [ $# -ne 1 ]
  20. then
  21.   echo "please supply a device to secure erase: /dev/xxx"
  22.   exit 1
  23. elif ! [ -b $1 ]
  24. then
  25.   echo "$1 is not a block device"
  26.   exit 2
  27. fi
  28.  
  29. # check we really want to do this!
  30. echo "Are you sure you want to completely erase $1? (yes|no): "
  31. read RESPONSE
  32.  
  33. if [ $RESPONSE != "yes" ]
  34. then
  35.   echo "Phew..."
  36.   exit 10
  37. fi
  38.  
  39. echo "Are you REALLY sure you want to do this?! (YES|no): "
  40. read RESPONSE
  41.  
  42. if [ $RESPONSE != "YES" ]
  43. then
  44.   echo "That was close..."
  45.   exit 11
  46. fi
  47.  
  48. # secure erase o.O
  49. sudo hdparm --user-master u --security-set-pass p $1
  50. sudo hdparm --user-master u --security-erase-enhanced p $1 &
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement