Add scripterase-zfs.sh which does fulla / metadata erase and verification

This commit is contained in:
2026-09-05 12:02:31 +03:00
parent 2d6c410489
commit 2bd6159b05
2 changed files with 235 additions and 0 deletions
+29
View File
@@ -4,6 +4,35 @@
a device as a ZFS vdev. It is intended for decommissioning or repurposing a
device after it has been cleanly removed from its pool.
## Unified Eraser
`erase-zfs.sh` is the recommended entry point. It performs a full-device wipe
by default and uses 10 overwrite passes. Select `--metadata` when only the
partition tables and ZFS vdev labels should be overwritten.
```bash
chmod +x erase-zfs.sh
sudo ./erase-zfs.sh /dev/sdX
sudo ./erase-zfs.sh --metadata /dev/sdX
sudo ./erase-zfs.sh --passes 3 /dev/sdX
sudo ./erase-zfs.sh --source random --verify /dev/sdX
```
`--wipe` explicitly selects the default full-device mode. `--source zeroes`
is the default, while `--source random` uses `/dev/urandom`. `--passes` accepts
a positive integer and defaults to 10. `--verify` runs after wiping and checks
`wipefs` signatures, readable ZFS labels through `zdb -l`, and ZFS pool
discovery. A full zero wipe additionally compares every readable byte against
`/dev/zero`. Random data cannot be byte-for-byte checked after it is written,
so its verification is limited to the metadata and ZFS recovery checks. The
verifier marks unavailable or ambiguous ZFS discovery as a failure rather than
declaring the wipe successful.
Pool discovery searches the target device's parent directory. Any reported
pool may use a neighboring device, so inspect its vdev paths before treating
the result as evidence about the erased target. A failed verification exits
with a nonzero status and leaves all evidence in place for investigation.
## What It Erases
The script performs 10 overwrite passes over the first 4 MiB and the last