Created
June 21, 2019 17:41
-
-
Save trodemaster/0615778613e7ca05d7f29f0177632821 to your computer and use it in GitHub Desktop.
Script to wipe 2 western digital sata disks at the same time
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
#!/usr/bin/env bash | |
set -euo pipefail | |
IFS=$'\n\t' | |
shopt -s nullglob | |
shopt -s nocaseglob | |
# kill subprocesses if you kill this script | |
handle_sigint() { | |
for proc in $(jobs -p); do | |
kill $proc | |
done | |
} | |
trap handle_sigint 2 | |
# get the disk device names and nuke them | |
for DEVICE in $(lsblk -S | grep WDC | cut -f 1 -d ' '); do | |
{ | |
echo "nuking devicd $DEVICE" | |
lsblk /dev/$DEVICE | |
/usr/bin/time -f "Elapsed time %E" scrub /dev/$DEVICE | |
} & | |
done | |
# wait for nuking to complete | |
for pidz in $(jobs -p); do | |
wait $pidz | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment