#!/bin/bash # Check if the script is run as root if [ "$EUID" -ne 0 ]; then echo "This script must be run as root or with sudo." exit 1 fi # Check if a device name was provided as an argument if [ $# -ne 1 ]; then echo "Usage: $0 " exit 1 fi device="$1" # Use blkdiscard to discard all data on the drive blkdiscard -f "$device" # Check the exit status of the blkdiscard command if [ $? -eq 0 ]; then echo "Drive $device has been set to a blank state." else echo "Failed to set the drive $device to a blank state." exit 1 fi dd if=/dev/zero of="$device" bs=512 count=1 exit 0