-
-
Save qbi/8848df87f32e8becfaa1b4388afc2ca5 to your computer and use it in GitHub Desktop.
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/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