From 56984f622f9e40c4820b084bc30e878b9ecb94b8 Mon Sep 17 00:00:00 2001 From: theanonymousexyz Date: Fri, 18 Mar 2022 18:07:46 +0100 Subject: [PATCH] Move erase-disk.sh to https://github.com/theanonymousexyz/archived-scripts --- scripts/.local/bin/erase-disk.sh | 67 -------------------------------- 1 file changed, 67 deletions(-) delete mode 100755 scripts/.local/bin/erase-disk.sh diff --git a/scripts/.local/bin/erase-disk.sh b/scripts/.local/bin/erase-disk.sh deleted file mode 100755 index bc68279..0000000 --- a/scripts/.local/bin/erase-disk.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env dash -# USAGE: erase-disk.sh -# Must be run as root - -usage() { - echo "Usage: erase-disk.sh PASSES DEVICE" - echo "Securely erase DEVICE with PASSES passes" - echo - echo "Flags:" - echo " -h, --help \t\tDisplay this help message" - echo " -c, --crypt-prep \tPrepare DEVICE for encryption" - echo - echo "Options (must come after flags):" - echo " DEVICE \t\tThe device to erase" - echo " PASSES \t\tHow many times to erase DEVICE" - echo - echo "This script will securely erase a disk device with the specified amount" - echo "of passes (rounds). It does so by overwriting the specified device with" - echo "random data on the first pass, and with zeroes on the other passes." - echo "Due to the nature of disk device access permissions, the script must" - echo "be run as root." - echo - echo "erase-disk.sh is licensed under The Unlicense." -} - -CRYPT=0 - -[ "$1" = "-h" -o "$1" = "--help" ] && usage && exit 0 -[ "$1" = "-c" -o "$1" = "--crypt-prep" ] && CRYPT=1 && shift - -if [ $# -lt 2 ]; then - echo "=> ERROR: Not enough options!" - echo - usage - exit 1 -elif [ $# -gt 2 ]; then - echo "=> ERROR: Too many options!" - echo - usage - exit 1 -elif [ $(id -u) -ne 0 ]; then - echo "=> ERROR: Must run as root!" - echo - usage - exit 1 -fi - -echo "=> Securely erasing the disk device $2" -i=1 - -while [ $i -le $1 ]; do - [ $i -eq 1 ] && if="/dev/urandom" || if="/dev/zero" - [ $CRYPT -eq 1 -a $i -eq $1 ] && if="/dev/urandom" - - echo "\n -> Begin pass $i with $if" - dd if="$if" of="$2" status="progress" - - echo "\n -> Syncing I/O" - sync - - i=$(( i + 1 )) -done - -echo -n "\n=> Done! $2 securely erased" -[ $CRYPT -eq 1 ] && echo -n " and prepared for encryption" -echo "." -