Skip to content

Instantly share code, notes, and snippets.

@qbi
Forked from someuser89/wipe.sh
Created May 27, 2016 17:59
Show Gist options
  • Save qbi/8848df87f32e8becfaa1b4388afc2ca5 to your computer and use it in GitHub Desktop.
Save qbi/8848df87f32e8becfaa1b4388afc2ca5 to your computer and use it in GitHub Desktop.
#!/bin/sh
which openssl > /dev/null || exit 1
which pv > /dev/null || exit 1
which sudo > /dev/null || exit 1
test -n "$1" || exit 2
disk="$1"
test -b "/dev/$disk" || exit 2
size=$(awk "\$4==\"$disk\"{print \$3}" /proc/partitions) || exit 3
size=$(($size*1024))
nice 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" | sudo dd of="/dev/$disk" bs=4096 || exit 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment