Skip to content

Instantly share code, notes, and snippets.

@trodemaster
Created June 21, 2019 17:41
Show Gist options
  • Save trodemaster/0615778613e7ca05d7f29f0177632821 to your computer and use it in GitHub Desktop.
Save trodemaster/0615778613e7ca05d7f29f0177632821 to your computer and use it in GitHub Desktop.
Script to wipe 2 western digital sata disks at the same time
#!/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