From 916e999777ecdab646e32c7ba4939f45f1bcc0e2 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Fri, 29 Nov 2024 15:08:22 -0600 Subject: adding wipedisk --- wipedisk | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 wipedisk (limited to 'wipedisk') diff --git a/wipedisk b/wipedisk new file mode 100644 index 0000000..0c08c72 --- /dev/null +++ b/wipedisk @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# Craig Jennings +# identify disk and erase + +all_disk_ids=( $(ls /dev/disk/by-id/) ) +echo ""; echo "Select the disk id to use. All data will be erased." +select disk_id in "${all_disk_ids[@]}"; do + # ensure valid selection + if [[ -n $disk_id ]]; then + selection=$disk_id + break + else + echo "Invalid. Try again." + fi +done + +# Confirm the selected disk +read -p "Confirm: '$selection' [y/n]? " choice +if [[ "$choice" != "y" ]]; then + echo "Exiting..." + exit 1 +fi + +DISK="/dev/disk/by-id/$selection" +echo ""; echo "### Erasing Disk" +blkdiscard -f "${DISK}" || true # discard all sectors on flash-based storage +sgdisk --zap-all "${DISK}" # clear the disk + +echo "" +echo "Disk erased." \ No newline at end of file -- cgit v1.2.3