MrRockchip

HDD Secure Erase (Low Level)

Jan 3rd, 2016
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. === Low Level Secure Erase of HDD (helps to wipe data and fix bad blocks) ===
  2.  
  3. !!!VERY IMPORTANT!!! Double check the path to hard drive which you want to wipe,
  4. otherwise your data will be fucked up. Be very careful, use at your own risk!!!
  5.  
  6. This script requires pv (for monitoring the progress) and openssl (for fast random number generation)
  7. In my case - Ubuntu LiveCD 14.10 (Utopic) - openssl was already preinstalled,
  8. but I had download the latest pv package from Launchpad: (couldnt install through apt-get)
  9. http://launchpad.net/ubuntu/utopic/amd64/pv/
  10.  
  11. Create script.sh , copy-paste the text below (and edit it, to add passes and insert your drive letter)
  12. and make this script executable by running chmod. Then go to sudo su - of course you need to be root
  13.  
  14. P.S. "|| true" is needed, so that script will not quit after "ran out of space" warning
  15. (happens at the end of pass, when "dd" already erased your disk and just can't write more)
  16.  
  17. --------------------------------------------------------------------------------------
  18. echo "PASS 1: dd if=<(openssl enc -aes-256-ctr -pass pass:\"$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64)\" -nosalt < /dev/zero) iflag=nocache bs=4096 | pv | dd of=/dev/sdXXXXX oflag=direct bs=4096 || true"
  19. dd if=<(openssl enc -aes-256-ctr -pass pass:"$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64)" -nosalt < /dev/zero) iflag=nocache bs=4096 | pv | dd of=/dev/sdXXXXX oflag=direct bs=4096 || true
  20. echo "PASS 2: dd if=<(openssl enc -aes-256-ctr -pass pass:\"$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64)\" -nosalt < /dev/zero) iflag=nocache bs=4096 | pv | dd of=/dev/sdXXXXX oflag=direct bs=4096 || true"
  21. dd if=<(openssl enc -aes-256-ctr -pass pass:"$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64)" -nosalt < /dev/zero) iflag=nocache bs=4096 | pv | dd of=/dev/sdXXXXX oflag=direct bs=4096 || true
  22. echo "PASS 3: dd if=/dev/zero iflag=nocache bs=4096 | pv | dd of=/dev/sdXXXXX oflag=direct bs=4096 || true"
  23. dd if=/dev/zero iflag=nocache bs=4096 | pv | dd of=/dev/sdXXXXX oflag=direct bs=4096 || true
Add Comment
Please, Sign In to add comment