https://github.com/hesam-zahiri/secureerease
https://github.com/hesam-zahiri/secureerease
bash disk disk-eraser hdd linux secureerase shell ssd
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/hesam-zahiri/secureerease
- Owner: hesam-zahiri
- Created: 2023-12-14T21:34:23.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-14T21:48:43.000Z (over 1 year ago)
- Last Synced: 2025-01-08T23:03:10.631Z (4 months ago)
- Topics: bash, disk, disk-eraser, hdd, linux, secureerase, shell, ssd
- Language: Shell
- Homepage: https://github.com/hesam-zahiri
- Size: 9.77 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SecureErase
- This Bash script, named "SecureErase," provides a secure method for permanently erasing data from specified external storage devices. The script prompts the user to enter the target devices, checks their existence, skips erasing the root device (/dev/sda) for safety, and securely wipes the selected devices using random data with a block size of 4 megabytes. Users with superuser privileges should execute the script, exercising caution as it irreversibly deletes data from the specified devices.
## code:
```bash
#!/bin/bash# Function to check device existence
check_device() {
if [ ! -e "$1" ]; then
echo "Device $1 does not exist."
return 1
fi
}# Function to securely erase a device
secure_erase() {
echo "Erasing $1..."
dd if=/dev/urandom of="$1" bs=4M status=progress
echo "Finished erasing $1."
}# Check if the script is run with superuser privileges
if [ "$EUID" -ne 0 ]; then
echo "Please run this script as root (sudo)."
exit 1
fi# Prompt the user for the target devices
read -p "Enter the target devices (e.g., /dev/sdX /dev/sdY): " target_devices# Iterate through the space-separated list of target devices
for device in $target_devices; do
# Check if the device exists
check_device "$device" || continue# Avoid erasing important devices
if [ "$device" == "/dev/sda" ]; then
echo "Skipping erasure of the root device (/dev/sda)."
continue
fi# Overwrite with random data
secure_erase "$device"
done
```## Installation:
```
git clone https://github.com/hesam-zahiri/SecureErease.git
```## How to use:
```bash
cd SecureErease
```
```bash
sudo bash SecureErase.sh
```## Attention!!
- The deleted data is not recoverable.