Created
June 3, 2016 09:40
-
-
Save imrehg/ea89be2ab55183120c0151a70bb1e3f9 to your computer and use it in GitHub Desktop.
Disk eraser script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# From http://unix.stackexchange.com/questions/72216/fast-way-to-randomize-hd | |
DISK="/dev/sda" | |
SIZE=`fdisk -l | grep "${DISK}" | awk '{print $5}'` | |
echo "Erasing ${DISK} (size ${SIZE} bytes)" | |
read -p "Are you sure? " -n 1 -r | |
echo # (optional) move to a new line | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
echo "OOOh!" | |
openssl enc -aes-256-ctr -pass pass:"$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64)" -nosalt </dev/zero \ | |
| pv --progress --eta --rate --bytes --size ${SIZE} \ | |
| dd of=${DISK} bs=2M | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment