Add nwipe with report generation with custom logos etc
This commit is contained in:
+119
@@ -0,0 +1,119 @@
|
||||
# config/binary - options for live-build(7), binary stage
|
||||
|
||||
# Set image type
|
||||
LB_IMAGE_TYPE="iso-hybrid"
|
||||
|
||||
# Set image filesystem
|
||||
LB_BINARY_FILESYSTEM="fat32"
|
||||
|
||||
# Set apt/aptitude generic indices
|
||||
LB_APT_INDICES="true"
|
||||
|
||||
# Set boot parameters
|
||||
LB_BOOTAPPEND_LIVE="boot=live components username=eraser hostname=ep-eraser"
|
||||
|
||||
# Set boot parameters
|
||||
LB_BOOTAPPEND_INSTALL=""
|
||||
|
||||
# Set boot parameters
|
||||
LB_BOOTAPPEND_LIVE_FAILSAFE="boot=live components memtest noapic noapm nodma nomce nosmp nosplash vga=788"
|
||||
|
||||
# Set BIOS bootloader
|
||||
LB_BOOTLOADER_BIOS="syslinux"
|
||||
|
||||
# Set EFI bootloader
|
||||
LB_BOOTLOADER_EFI="grub-efi"
|
||||
|
||||
# Set bootloaders
|
||||
LB_BOOTLOADERS=""
|
||||
|
||||
# Set checksums
|
||||
LB_CHECKSUMS="sha256"
|
||||
|
||||
# Set compression
|
||||
LB_COMPRESSION="none"
|
||||
|
||||
# Support dm-verity on rootfs
|
||||
LB_DM_VERITY=""
|
||||
|
||||
# Support FEC on dm-verity rootfs
|
||||
LB_DM_VERITY_FEC_ROOTS=""
|
||||
|
||||
# Set sign script for roothash for dm-verity rootfs
|
||||
LB_DM_VERITY_SIGN=""
|
||||
|
||||
# Set zsync
|
||||
LB_ZSYNC="false"
|
||||
|
||||
# Control if we build binary images chrooted
|
||||
# NEVER, *EVER*, *E*V*E*R* SET THIS OPTION to false.
|
||||
LB_BUILD_WITH_CHROOT="true"
|
||||
|
||||
# Set debian-installer
|
||||
LB_DEBIAN_INSTALLER="none"
|
||||
|
||||
# Set debian-installer suite
|
||||
LB_DEBIAN_INSTALLER_DISTRIBUTION="trixie"
|
||||
|
||||
# Set debian-installer preseed filename/url
|
||||
LB_DEBIAN_INSTALLER_PRESEEDFILE=""
|
||||
|
||||
# Toggle use of GUI debian-installer
|
||||
LB_DEBIAN_INSTALLER_GUI="true"
|
||||
|
||||
# Set hdd label
|
||||
LB_HDD_LABEL="DEBIAN_LIVE"
|
||||
|
||||
# Set hdd filesystem size
|
||||
LB_HDD_SIZE="auto"
|
||||
|
||||
# Set start of partition for the hdd target for BIOSes that expect a specific boot partition start (e.g. "63s"). If empty, use optimal layout.
|
||||
LB_HDD_PARTITION_START=""
|
||||
|
||||
# Set iso author
|
||||
LB_ISO_APPLICATION="EP Eraser"
|
||||
|
||||
# Set iso preparer
|
||||
LB_ISO_PREPARER="live-build @LB_VERSION@; https://salsa.debian.org/live-team/live-build"
|
||||
|
||||
# Set iso publisher
|
||||
LB_ISO_PUBLISHER="EP Eraser Project"
|
||||
|
||||
# Set iso volume (max 32 chars)
|
||||
LB_ISO_VOLUME="EP_ERASER"
|
||||
|
||||
# Set jffs2 eraseblock size
|
||||
LB_JFFS2_ERASEBLOCK=""
|
||||
|
||||
# Set memtest
|
||||
LB_MEMTEST="none"
|
||||
|
||||
# Set loadlin
|
||||
LB_LOADLIN="false"
|
||||
|
||||
# Set win32-loader
|
||||
LB_WIN32_LOADER="false"
|
||||
|
||||
# Set net tarball
|
||||
LB_NET_TARBALL="true"
|
||||
|
||||
# Set onie
|
||||
LB_ONIE="false"
|
||||
|
||||
# Set onie additional kernel cmdline options
|
||||
LB_ONIE_KERNEL_CMDLINE=""
|
||||
|
||||
# Set inclusion of firmware packages in debian-installer
|
||||
LB_FIRMWARE_BINARY="true"
|
||||
|
||||
# Set inclusion of firmware packages in the live image
|
||||
LB_FIRMWARE_CHROOT="true"
|
||||
|
||||
# Set swap file path
|
||||
LB_SWAP_FILE_PATH=""
|
||||
|
||||
# Set swap file size
|
||||
LB_SWAP_FILE_SIZE="512"
|
||||
|
||||
# Enable/disable UEFI secure boot support
|
||||
LB_UEFI_SECURE_BOOT="auto"
|
||||
@@ -0,0 +1,76 @@
|
||||
# config/bootstrap - options for live-build(7), bootstrap stage
|
||||
|
||||
# Select architecture to use
|
||||
LB_ARCHITECTURE="amd64"
|
||||
|
||||
# Select distribution to use
|
||||
LB_DISTRIBUTION="trixie"
|
||||
|
||||
# Select parent distribution to use
|
||||
LB_PARENT_DISTRIBUTION=""
|
||||
|
||||
# Select distribution to use in the chroot
|
||||
LB_DISTRIBUTION_CHROOT="trixie"
|
||||
|
||||
# Select parent distribution to use in the chroot
|
||||
LB_PARENT_DISTRIBUTION_CHROOT="trixie"
|
||||
|
||||
# Select distribution to use in the final image
|
||||
LB_DISTRIBUTION_BINARY="trixie"
|
||||
|
||||
# Select parent distribution to use in the final image
|
||||
LB_PARENT_DISTRIBUTION_BINARY="trixie"
|
||||
|
||||
# Select parent distribution for debian-installer to use
|
||||
LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION="trixie"
|
||||
|
||||
# Select archive areas to use
|
||||
LB_ARCHIVE_AREAS="main contrib non-free-firmware"
|
||||
|
||||
# Select parent archive areas to use
|
||||
LB_PARENT_ARCHIVE_AREAS="main contrib non-free-firmware"
|
||||
|
||||
# Set parent mirror to bootstrap from
|
||||
LB_PARENT_MIRROR_BOOTSTRAP="http://deb.debian.org/debian/"
|
||||
|
||||
# Set parent mirror to fetch packages from
|
||||
LB_PARENT_MIRROR_CHROOT="http://deb.debian.org/debian/"
|
||||
|
||||
# Set security parent mirror to fetch packages from
|
||||
LB_PARENT_MIRROR_CHROOT_SECURITY="http://security.debian.org/"
|
||||
|
||||
# Set parent mirror which ends up in the image
|
||||
LB_PARENT_MIRROR_BINARY="http://deb.debian.org/debian/"
|
||||
|
||||
# Set security parent mirror which ends up in the image
|
||||
LB_PARENT_MIRROR_BINARY_SECURITY="http://security.debian.org/"
|
||||
|
||||
# Set debian-installer parent mirror
|
||||
LB_PARENT_MIRROR_DEBIAN_INSTALLER="http://deb.debian.org/debian/"
|
||||
|
||||
# Set mirror to bootstrap from
|
||||
LB_MIRROR_BOOTSTRAP="http://deb.debian.org/debian/"
|
||||
|
||||
# Set mirror to fetch packages from
|
||||
LB_MIRROR_CHROOT="http://deb.debian.org/debian/"
|
||||
|
||||
# Set security mirror to fetch packages from
|
||||
LB_MIRROR_CHROOT_SECURITY="http://security.debian.org/"
|
||||
|
||||
# Set mirror which ends up in the image
|
||||
LB_MIRROR_BINARY="http://deb.debian.org/debian/"
|
||||
|
||||
# Set security mirror which ends up in the image
|
||||
LB_MIRROR_BINARY_SECURITY="http://security.debian.org/"
|
||||
|
||||
# Set debian-installer mirror
|
||||
LB_MIRROR_DEBIAN_INSTALLER="http://deb.debian.org/debian/"
|
||||
|
||||
# Set architectures to use foreign bootstrap
|
||||
LB_BOOTSTRAP_QEMU_ARCHITECTURE=""
|
||||
|
||||
# Set packages to exclude during foreign bootstrap
|
||||
LB_BOOTSTRAP_QEMU_EXCLUDE=""
|
||||
|
||||
# Set static qemu binary for foreign bootstrap
|
||||
LB_BOOTSTRAP_QEMU_STATIC=""
|
||||
@@ -0,0 +1,37 @@
|
||||
# config/chroot - options for live-build(7), chroot stage
|
||||
|
||||
# Set chroot filesystem
|
||||
LB_CHROOT_FILESYSTEM="squashfs"
|
||||
|
||||
# Set chroot squashfs compression level
|
||||
LB_CHROOT_SQUASHFS_COMPRESSION_LEVEL=""
|
||||
|
||||
# Set chroot squashfs compression type
|
||||
LB_CHROOT_SQUASHFS_COMPRESSION_TYPE=""
|
||||
|
||||
# Set union filesystem
|
||||
LB_UNION_FILESYSTEM="overlay"
|
||||
|
||||
# Set interactive build
|
||||
LB_INTERACTIVE="false"
|
||||
|
||||
# Set keyring packages
|
||||
LB_KEYRING_PACKAGES="debian-archive-keyring"
|
||||
|
||||
# Set kernel flavour to use (with arch)
|
||||
LB_LINUX_FLAVOURS_WITH_ARCH="amd64"
|
||||
|
||||
# Set kernel packages to use
|
||||
LB_LINUX_PACKAGES="linux-image"
|
||||
|
||||
# Enable security updates
|
||||
LB_SECURITY="true"
|
||||
|
||||
# Enable updates updates
|
||||
LB_UPDATES="true"
|
||||
|
||||
# Enable backports updates
|
||||
LB_BACKPORTS="false"
|
||||
|
||||
# Enable proposed updates
|
||||
LB_PROPOSED_UPDATES="false"
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
# config/common - common options for live-build(7)
|
||||
|
||||
# Version of live-build used to build config (config format version)
|
||||
LB_CONFIGURATION_VERSION="20250505+deb13u1"
|
||||
|
||||
# Set package manager
|
||||
LB_APT="apt"
|
||||
|
||||
# Set proxy for HTTP connections
|
||||
LB_APT_HTTP_PROXY=""
|
||||
|
||||
# Set apt/aptitude pipeline depth
|
||||
LB_APT_PIPELINE=""
|
||||
|
||||
# Set apt/aptitude recommends
|
||||
LB_APT_RECOMMENDS="false"
|
||||
|
||||
# Set apt/aptitude security
|
||||
LB_APT_SECURE="true"
|
||||
|
||||
# Set apt/aptitude source entries in sources.list
|
||||
LB_APT_SOURCE_ARCHIVES="true"
|
||||
|
||||
# Control cache
|
||||
LB_CACHE="true"
|
||||
|
||||
# Control if downloaded package indices should be cached
|
||||
LB_CACHE_INDICES="false"
|
||||
|
||||
# Control if downloaded packages files should be cached
|
||||
LB_CACHE_PACKAGES="true"
|
||||
|
||||
# Control if completed stages should be cached
|
||||
LB_CACHE_STAGES="bootstrap"
|
||||
|
||||
# Set debconf(1) frontend to use
|
||||
LB_DEBCONF_FRONTEND="noninteractive"
|
||||
|
||||
# Set debconf(1) priority to use
|
||||
LB_DEBCONF_PRIORITY="critical"
|
||||
|
||||
# Set initramfs hook
|
||||
LB_INITRAMFS="live-boot"
|
||||
|
||||
# Set initramfs compression
|
||||
LB_INITRAMFS_COMPRESSION="gzip"
|
||||
|
||||
# Set init system
|
||||
LB_INITSYSTEM="systemd"
|
||||
|
||||
# Set distribution mode
|
||||
LB_MODE="debian"
|
||||
|
||||
# Set system type
|
||||
LB_SYSTEM="live"
|
||||
|
||||
# Set base name of the image
|
||||
LB_IMAGE_NAME="ep-eraser"
|
||||
|
||||
# Set options to use with apt
|
||||
APT_OPTIONS="--yes -o Acquire::Retries=5"
|
||||
|
||||
# Set options to use with aptitude
|
||||
APTITUDE_OPTIONS="--assume-yes -o Acquire::Retries=5"
|
||||
|
||||
# Set options to use with debootstrap
|
||||
DEBOOTSTRAP_OPTIONS=""
|
||||
|
||||
# Set script to use with debootstrap
|
||||
DEBOOTSTRAP_SCRIPT=""
|
||||
|
||||
# Set options to use with gzip
|
||||
GZIP_OPTIONS="-6 --rsyncable"
|
||||
|
||||
# Enable UTC timestamps
|
||||
LB_UTC_TIME="false"
|
||||
|
||||
# live-build options
|
||||
|
||||
# Enable breakpoints
|
||||
# If set here, overrides the command line option
|
||||
#_BREAKPOINTS="false"
|
||||
|
||||
# Enable debug
|
||||
# If set here, overrides the command line option
|
||||
#_DEBUG="false"
|
||||
|
||||
# Enable color
|
||||
# If set here, overrides the command line option
|
||||
#_COLOR="auto"
|
||||
|
||||
# Enable force
|
||||
# If set here, overrides the command line option
|
||||
#_FORCE="false"
|
||||
|
||||
# Enable quiet
|
||||
# If set here, overrides the command line option
|
||||
#_QUIET="false"
|
||||
|
||||
# Enable verbose
|
||||
# If set here, overrides the command line option
|
||||
#_VERBOSE="false"
|
||||
@@ -0,0 +1 @@
|
||||
/usr/share/live/build/hooks/live/0010-disable-kexec-tools.hook.chroot
|
||||
@@ -0,0 +1 @@
|
||||
/usr/share/live/build/hooks/live/0050-disable-sysvinit-tmpfs.hook.chroot
|
||||
@@ -0,0 +1 @@
|
||||
/usr/share/live/build/hooks/normal/1000-create-mtab-symlink.hook.chroot
|
||||
@@ -0,0 +1 @@
|
||||
/usr/share/live/build/hooks/normal/1010-enable-cryptsetup.hook.chroot
|
||||
@@ -0,0 +1 @@
|
||||
/usr/share/live/build/hooks/normal/1020-create-locales-files.hook.chroot
|
||||
@@ -0,0 +1 @@
|
||||
/usr/share/live/build/hooks/normal/5000-update-apt-file-cache.hook.chroot
|
||||
@@ -0,0 +1 @@
|
||||
/usr/share/live/build/hooks/normal/5010-update-apt-xapian-index.hook.chroot
|
||||
@@ -0,0 +1 @@
|
||||
/usr/share/live/build/hooks/normal/5020-update-glx-alternative.hook.chroot
|
||||
@@ -0,0 +1 @@
|
||||
/usr/share/live/build/hooks/normal/5030-update-plocate-database.hook.chroot
|
||||
@@ -0,0 +1 @@
|
||||
/usr/share/live/build/hooks/normal/5040-update-nvidia-alternative.hook.chroot
|
||||
@@ -0,0 +1 @@
|
||||
/usr/share/live/build/hooks/normal/5050-dracut.hook.chroot
|
||||
@@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
version=0.42
|
||||
archive_sha256=0E38474495CC6C86043A1DE0460CF0DC009AD68E079EE23D71569E80E55CD2E6
|
||||
build_packages="autoconf automake autopoint build-essential gettext libconfig++-dev libconfig-dev libncurses-dev libparted-dev libtool libuuid-dev pkg-config wget"
|
||||
work_dir=$(mktemp -d)
|
||||
|
||||
cleanup() {
|
||||
rm -rf "$work_dir"
|
||||
apt-get purge --yes $build_packages
|
||||
apt-get autoremove --yes
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
apt-get update
|
||||
apt-get install --yes ca-certificates
|
||||
apt-get install --yes --no-install-recommends $build_packages
|
||||
wget --quiet --output-document="$work_dir/nwipe.tar.gz" "https://github.com/martijnvanbrummelen/nwipe/archive/refs/tags/v$version.tar.gz"
|
||||
printf '%s %s\n' "$archive_sha256" "$work_dir/nwipe.tar.gz" | sha256sum --check --status
|
||||
tar --extract --gzip --file="$work_dir/nwipe.tar.gz" --directory="$work_dir"
|
||||
cd "$work_dir/nwipe-$version"
|
||||
./autogen.sh
|
||||
./configure --prefix=/usr/local
|
||||
make --jobs="$(nproc)"
|
||||
make install
|
||||
@@ -0,0 +1 @@
|
||||
/usr/share/live/build/hooks/normal/8000-remove-adjtime-configuration.hook.chroot
|
||||
@@ -0,0 +1 @@
|
||||
/usr/share/live/build/hooks/normal/8010-remove-backup-files.hook.chroot
|
||||
@@ -0,0 +1 @@
|
||||
/usr/share/live/build/hooks/normal/8020-remove-dbus-machine-id.hook.chroot
|
||||
@@ -0,0 +1 @@
|
||||
/usr/share/live/build/hooks/normal/8030-truncate-log-files.hook.chroot
|
||||
@@ -0,0 +1 @@
|
||||
/usr/share/live/build/hooks/normal/8040-remove-mdadm-configuration.hook.chroot
|
||||
@@ -0,0 +1 @@
|
||||
/usr/share/live/build/hooks/normal/8050-remove-openssh-server-host-keys.hook.chroot
|
||||
@@ -0,0 +1 @@
|
||||
/usr/share/live/build/hooks/normal/8060-remove-systemd-machine-id.hook.chroot
|
||||
@@ -0,0 +1 @@
|
||||
/usr/share/live/build/hooks/normal/8070-remove-temporary-files.hook.chroot
|
||||
@@ -0,0 +1 @@
|
||||
/usr/share/live/build/hooks/normal/8080-reproducible-glibc.hook.chroot
|
||||
@@ -0,0 +1 @@
|
||||
/usr/share/live/build/hooks/normal/8090-remove-ssl-cert-snakeoil.hook.chroot
|
||||
@@ -0,0 +1 @@
|
||||
/usr/share/live/build/hooks/normal/8100-remove-udev-persistent-cd-rules.hook.chroot
|
||||
@@ -0,0 +1 @@
|
||||
/usr/share/live/build/hooks/normal/8110-remove-udev-persistent-net-rules.hook.chroot
|
||||
@@ -0,0 +1 @@
|
||||
/usr/share/live/build/hooks/normal/9000-remove-gnome-icon-cache.hook.chroot
|
||||
@@ -0,0 +1 @@
|
||||
/usr/share/live/build/hooks/normal/9010-remove-python-pyc.hook.chroot
|
||||
@@ -0,0 +1 @@
|
||||
/usr/share/live/build/hooks/normal/9020-remove-man-cache.hook.chroot
|
||||
@@ -1,19 +1,19 @@
|
||||
[Unit]
|
||||
Description=EP Eraser console
|
||||
After=local-fs.target systemd-udev-settle.service
|
||||
Wants=systemd-udev-settle.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/local/sbin/ep-eraser
|
||||
StandardInput=tty
|
||||
StandardOutput=tty
|
||||
StandardError=tty
|
||||
TTYPath=/dev/tty1
|
||||
TTYReset=yes
|
||||
TTYVHangup=yes
|
||||
TTYVTDisallocate=yes
|
||||
Restart=no
|
||||
|
||||
[Install]
|
||||
[Unit]
|
||||
Description=EP Eraser console
|
||||
After=local-fs.target systemd-udev-settle.service
|
||||
Wants=systemd-udev-settle.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/local/sbin/ep-eraser
|
||||
StandardInput=tty
|
||||
StandardOutput=tty
|
||||
StandardError=tty
|
||||
TTYPath=/dev/tty1
|
||||
TTYReset=yes
|
||||
TTYVHangup=yes
|
||||
TTYVTDisallocate=yes
|
||||
Restart=no
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,107 +1,128 @@
|
||||
#!/usr/bin/env bash
|
||||
set -Eeuo pipefail
|
||||
|
||||
LOG=/var/log/ep-eraser.log
|
||||
exec > >(tee -a "$LOG") 2>&1
|
||||
|
||||
die() { printf '\nERROR: %s\n' "$*" >&2; read -r -p 'Press Enter to return to the menu...' _; }
|
||||
|
||||
mounted() {
|
||||
findmnt -rn -S "$1" >/dev/null 2>&1 && return 0
|
||||
lsblk -nrpo NAME,MOUNTPOINTS "$1" | awk 'NF > 1 && $2 != "" { found=1 } END { exit !found }'
|
||||
}
|
||||
|
||||
is_live_device() {
|
||||
local live parent
|
||||
live=$(findmnt -rn -o SOURCE /run/live/medium 2>/dev/null || true)
|
||||
[ -n "$live" ] || return 1
|
||||
parent=$(lsblk -dnro PKNAME "$live" 2>/dev/null || true)
|
||||
[ -n "$parent" ] && [ "$1" = "/dev/$parent" ]
|
||||
}
|
||||
|
||||
disk_info() {
|
||||
lsblk -dnpo NAME,TYPE,SIZE,MODEL,SERIAL,TRAN | awk '$2 == "disk" { print }'
|
||||
}
|
||||
|
||||
choose_disk() {
|
||||
mapfile -t disks < <(lsblk -dnpo NAME,TYPE | awk '$2 == "disk" { print $1 }')
|
||||
[ "${#disks[@]}" -gt 0 ] || { die 'No whole disks were detected.'; return 1; }
|
||||
printf '\nDetected disks:\n\n'
|
||||
printf '%-4s %-18s %-10s %-24s %-16s %s\n' '#' DEVICE SIZE MODEL SERIAL TRAN
|
||||
disk_info | nl -w2 -s' '
|
||||
printf '\nEnter the number shown above, or q to quit: '
|
||||
read -r choice
|
||||
[ "$choice" = q ] && exit 0
|
||||
[[ "$choice" =~ ^[0-9]+$ ]] || { die 'Invalid selection.'; return 1; }
|
||||
target=${disks[$((choice - 1))]:-}
|
||||
[ -n "$target" ] || { die 'Invalid selection.'; return 1; }
|
||||
}
|
||||
|
||||
validate_target() {
|
||||
[ -b "$target" ] || { die 'Selected path is not a block device.'; return 1; }
|
||||
[ "$(lsblk -dnro TYPE "$target")" = disk ] || { die 'Only whole disks may be erased.'; return 1; }
|
||||
[ "$(lsblk -dnro RO "$target")" = 0 ] || { die 'The disk is read-only.'; return 1; }
|
||||
mounted "$target" && { die 'The disk or one of its partitions is mounted.'; return 1; }
|
||||
is_live_device "$target" && { die 'The live boot device cannot be erased.'; return 1; }
|
||||
}
|
||||
|
||||
confirm() {
|
||||
local info
|
||||
info=$(lsblk -dnpo NAME,SIZE,MODEL,SERIAL "$target")
|
||||
printf '\nTARGET: %s\n%s\n\nThis permanently destroys all data. Type ERASE to continue: ' "$target" "$info"
|
||||
read -r answer
|
||||
[ "$answer" = ERASE ] || { printf 'Cancelled.\n'; return 1; }
|
||||
}
|
||||
|
||||
erase_ssd() {
|
||||
printf '\nSSD/NVMe erase options:\n1) Secure discard (blkdiscard --secure)\n2) NVMe sanitize (NVMe only)\n3) Cancel\nChoose: '
|
||||
read -r method
|
||||
case "$method" in
|
||||
1)
|
||||
blkdiscard --secure --force "$target" || { die 'Secure discard failed; no data was overwritten.'; return 1; }
|
||||
;;
|
||||
2)
|
||||
[[ "$target" == /dev/nvme*n* ]] || { die 'NVMe sanitize requires an NVMe namespace.'; return 1; }
|
||||
nvme sanitize "$target" -a 2 || { die 'NVMe sanitize failed.'; return 1; }
|
||||
nvme sanitize-log "$target" -H || true
|
||||
;;
|
||||
*) printf 'Cancelled.\n'; return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
erase_hdd() {
|
||||
printf '\nHDD erase uses three random overwrite passes plus a zero pass. Continue? [yes/no]: '
|
||||
read -r answer
|
||||
[ "$answer" = yes ] || { printf 'Cancelled.\n'; return 1; }
|
||||
shred --verbose --iterations=3 --zero --force "$target"
|
||||
}
|
||||
|
||||
verify() {
|
||||
printf '\nFinal device state:\n'
|
||||
lsblk -dnpo NAME,TYPE,SIZE,MODEL,SERIAL "$target"
|
||||
printf 'Erase command completed. Verification is limited to command/device status.\n'
|
||||
}
|
||||
|
||||
main() {
|
||||
[ "$(id -u)" -eq 0 ] || { echo 'This tool must run as root.' >&2; exit 1; }
|
||||
printf '\nEP ERASER - destructive disk sanitization\n==========================================\n'
|
||||
while true; do
|
||||
choose_disk || continue
|
||||
validate_target || continue
|
||||
rotational=$(lsblk -dnro ROTA "$target")
|
||||
if [ "$rotational" = 1 ]; then
|
||||
operation=HDD
|
||||
else
|
||||
operation=SSD/NVMe
|
||||
fi
|
||||
printf '\nDetected media type: %s\n' "$operation"
|
||||
confirm || continue
|
||||
if [ "$operation" = HDD ]; then erase_hdd; else erase_ssd; fi
|
||||
verify
|
||||
printf '\nPress Enter to return to the disk menu, or type q to quit: '
|
||||
read -r answer
|
||||
[ "$answer" = q ] && exit 0
|
||||
done
|
||||
}
|
||||
|
||||
#!/usr/bin/env bash
|
||||
set -Eeuo pipefail
|
||||
|
||||
LOG=/var/log/ep-eraser.log
|
||||
exec > >(tee -a "$LOG") 2>&1
|
||||
|
||||
die() { printf '\nERROR: %s\n' "$*" >&2; read -r -p 'Press Enter to return to the menu...' _; }
|
||||
|
||||
mounted() {
|
||||
findmnt -rn -S "$1" >/dev/null 2>&1 && return 0
|
||||
lsblk -nrpo NAME,MOUNTPOINTS "$1" | awk 'NF > 1 && $2 != "" { found=1 } END { exit !found }'
|
||||
}
|
||||
|
||||
is_live_device() {
|
||||
local live parent
|
||||
live=$(findmnt -rn -o SOURCE /run/live/medium 2>/dev/null || true)
|
||||
[ -n "$live" ] || return 1
|
||||
parent=$(lsblk -dnro PKNAME "$live" 2>/dev/null || true)
|
||||
[ -n "$parent" ] && [ "$1" = "/dev/$parent" ]
|
||||
}
|
||||
|
||||
disk_info() {
|
||||
lsblk -dnpo NAME,TYPE,SIZE,MODEL,SERIAL,TRAN | awk '$2 == "disk" { print }'
|
||||
}
|
||||
|
||||
choose_disk() {
|
||||
mapfile -t disks < <(lsblk -dnpo NAME,TYPE | awk '$2 == "disk" { print $1 }')
|
||||
[ "${#disks[@]}" -gt 0 ] || { die 'No whole disks were detected.'; return 1; }
|
||||
printf '\nDetected disks:\n\n'
|
||||
printf '%-4s %-18s %-10s %-24s %-16s %s\n' '#' DEVICE SIZE MODEL SERIAL TRAN
|
||||
disk_info | nl -w2 -s' '
|
||||
printf '\nEnter the number shown above, or q to quit: '
|
||||
read -r choice
|
||||
[ "$choice" = q ] && exit 0
|
||||
[[ "$choice" =~ ^[0-9]+$ ]] || { die 'Invalid selection.'; return 1; }
|
||||
target=${disks[$((choice - 1))]:-}
|
||||
[ -n "$target" ] || { die 'Invalid selection.'; return 1; }
|
||||
}
|
||||
|
||||
validate_target() {
|
||||
[ -b "$target" ] || { die 'Selected path is not a block device.'; return 1; }
|
||||
[ "$(lsblk -dnro TYPE "$target")" = disk ] || { die 'Only whole disks may be erased.'; return 1; }
|
||||
[ "$(lsblk -dnro RO "$target")" = 0 ] || { die 'The disk is read-only.'; return 1; }
|
||||
mounted "$target" && { die 'The disk or one of its partitions is mounted.'; return 1; }
|
||||
is_live_device "$target" && { die 'The live boot device cannot be erased.'; return 1; }
|
||||
}
|
||||
|
||||
confirm() {
|
||||
local info
|
||||
info=$(lsblk -dnpo NAME,SIZE,MODEL,SERIAL "$target")
|
||||
printf '\nTARGET: %s\n%s\n\nThis permanently destroys all data. Type ERASE to continue: ' "$target" "$info"
|
||||
read -r answer
|
||||
[ "$answer" = ERASE ] || { printf 'Cancelled.\n'; return 1; }
|
||||
}
|
||||
|
||||
erase_ssd() {
|
||||
printf '\nSSD/NVMe erase options:\n1) Secure discard (blkdiscard --secure)\n2) NVMe sanitize (NVMe only)\n3) Cancel\nChoose: '
|
||||
read -r method
|
||||
case "$method" in
|
||||
1)
|
||||
blkdiscard --secure --force "$target" || { die 'Secure discard failed; no data was overwritten.'; return 1; }
|
||||
;;
|
||||
2)
|
||||
[[ "$target" == /dev/nvme*n* ]] || { die 'NVMe sanitize requires an NVMe namespace.'; return 1; }
|
||||
nvme sanitize "$target" -a 2 || { die 'NVMe sanitize failed.'; return 1; }
|
||||
nvme sanitize-log "$target" -H || true
|
||||
;;
|
||||
*) printf 'Cancelled.\n'; return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
erase_hdd() {
|
||||
printf '\nHDD erase uses three random overwrite passes plus a zero pass. Continue? [yes/no]: '
|
||||
read -r answer
|
||||
[ "$answer" = yes ] || { printf 'Cancelled.\n'; return 1; }
|
||||
shred --verbose --iterations=3 --zero --force "$target"
|
||||
}
|
||||
|
||||
verify() {
|
||||
printf '\nFinal device state:\n'
|
||||
lsblk -dnpo NAME,TYPE,SIZE,MODEL,SERIAL "$target"
|
||||
printf 'Erase command completed. Verification is limited to command/device status.\n'
|
||||
}
|
||||
|
||||
run_ep_eraser() {
|
||||
while true; do
|
||||
choose_disk || continue
|
||||
validate_target || continue
|
||||
rotational=$(lsblk -dnro ROTA "$target")
|
||||
if [ "$rotational" = 1 ]; then
|
||||
operation=HDD
|
||||
else
|
||||
operation=SSD/NVMe
|
||||
fi
|
||||
printf '\nDetected media type: %s\n' "$operation"
|
||||
confirm || continue
|
||||
if [ "$operation" = HDD ]; then erase_hdd; else erase_ssd; fi
|
||||
verify
|
||||
printf '\nPress Enter to return to the disk menu, or type q to quit: '
|
||||
read -r answer
|
||||
[ "$answer" = q ] && exit 0
|
||||
done
|
||||
}
|
||||
|
||||
run_nwipe() {
|
||||
local report_dir=/var/log/ep-eraser/reports
|
||||
mkdir -p /etc/nwipe
|
||||
mkdir -p "$report_dir"
|
||||
cd /etc/nwipe
|
||||
nwipe --PDFreportpath="$report_dir" </dev/tty >/dev/tty 2>&1
|
||||
}
|
||||
|
||||
main() {
|
||||
[ "$(id -u)" -eq 0 ] || { echo 'This tool must run as root.' >&2; exit 1; }
|
||||
while true; do
|
||||
printf '\nEP ERASER - disk sanitization tools\n===================================\n'
|
||||
printf '1) EP Eraser (device-specific)\n2) nwipe (interactive)\nq) Quit\nChoose a tool: '
|
||||
read -r choice
|
||||
case "$choice" in
|
||||
1) run_ep_eraser ;;
|
||||
2) run_nwipe ;;
|
||||
q) exit 0 ;;
|
||||
*) die 'Invalid selection.' ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,8 +1,11 @@
|
||||
bash
|
||||
coreutils
|
||||
hdparm
|
||||
nvme-cli
|
||||
parted
|
||||
smartmontools
|
||||
util-linux
|
||||
bash
|
||||
coreutils
|
||||
hdparm
|
||||
libconfig11
|
||||
libncurses6
|
||||
libparted2t64
|
||||
nvme-cli
|
||||
parted
|
||||
smartmontools
|
||||
util-linux
|
||||
whiptail
|
||||
@@ -0,0 +1,4 @@
|
||||
live-boot
|
||||
live-config
|
||||
live-config-systemd
|
||||
systemd-sysv
|
||||
@@ -0,0 +1,7 @@
|
||||
# config/source - options for live-build(7), source stage
|
||||
|
||||
# Set source option
|
||||
LB_SOURCE="false"
|
||||
|
||||
# Set image type
|
||||
LB_SOURCE_IMAGES="tar"
|
||||
Reference in New Issue
Block a user