Last active
August 17, 2017 19:48
-
-
Save joeljacobs/424d07afafd710c4f4e6628074427c75 to your computer and use it in GitHub Desktop.
This file contains 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
filldisk(){ | |
DISKNUM=$2 | |
if [[ ! $2 =~ [0-9] ]]; then echo must specify disk num as 2nd arg;return 1;fi | |
SKIP="${3:-0}" | |
BS="${4:-4}" | |
SIZE=$(( (2 * 1024 *1024) - ($SKIP * 1024) )) | |
gnumfmt --format=%.3f --to=iec --from=iec ${SIZE}M\ | |
case $1 in | |
random) | |
SOURCE='/usr/local/Cellar/openssl/1.0.2k/bin/openssl enc -aes-128-cbc -pass pass:$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64) -nosalt < /dev/zero' | |
;; | |
zeros) | |
SOURCE='dd if=/dev/zero' | |
;; | |
*) | |
echo 'Must specify "random" or "zeros" as first arg.' | |
return 1 | |
esac | |
eval $SOURCE\ | |
|pv --progress --eta --rate --bytes --size ${SIZE}m\ | |
|dd of=/dev/rdisk$DISKNUM bs=${BS}m seek=$((($SKIP * 1024)/$BS)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment