dotfiles/scripts/.local/bin/erase-disk.sh

20 lines
356 B
Bash
Raw Normal View History

2022-02-24 12:07:09 +00:00
#!/bin/dash
# USAGE: erase-disk.sh <passes> <device>
# Must be run as root
echo "# Securely erasing the disk device $2"
i=1
while [ $i -le $1 ]; do
[ $i -eq 1 ] && if="/dev/urandom" || if="/dev/zero"
echo "\n- Begin pass $i with $if"
dd if="$if" of="$2" status="progress"
echo "- Syncing I/O"
sync
i=$(( i + 1 ))
done