From 62ac956836aa78455f310c9d3d1ab7e525d5f43a Mon Sep 17 00:00:00 2001 From: MatMoul Date: Tue, 28 Apr 2026 00:33:27 +0200 Subject: [PATCH] fix: reorder wipe method fallback sequence --- .continue/rules/project.md | 4 ++-- README.md | 12 ++++++++++++ mtm-ddwipe | 33 ++++++++++++++++----------------- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/.continue/rules/project.md b/.continue/rules/project.md index 9b411cb..310d482 100644 --- a/.continue/rules/project.md +++ b/.continue/rules/project.md @@ -17,11 +17,11 @@ description: mtm-ddwipe project conventions - Keep optional tools optional. - Use extra wipe methods only if the command is present. - Use `ddrescue` or `dd_rescue` only after `dd` fails. -- Keep `nvme-cli` and `hdparm` optional. +- Keep `nvme` and `hdparm` optional. - Use `nvme` and `hdparm` only on matching device types. - Do not make new external tools required. - Keep changes minimal and preserve intent. -- Keep `./continue/rules/project.md` aligned and concise. +- Keep this file aligned and concise. - If non-interactive support is added, make it an opt-in safety flag. # Project identity diff --git a/README.md b/README.md index 3f18814..5847a34 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,14 @@ # mtm-ddwipe +Wipe a block device. + +Warning: destructive and irreversible. The target must be a real block device, not mounted, and not in use. + +Usage: +mtm-ddwipe DEVICE + +Options: +- `-h`, `--help` + +Optional tools: `blkdiscard`, `ddrescue`, `dd_rescue`, `nvme`, `hdparm`. + diff --git a/mtm-ddwipe b/mtm-ddwipe index 32d4902..e61511b 100644 --- a/mtm-ddwipe +++ b/mtm-ddwipe @@ -14,9 +14,8 @@ Wipe a block device. Warnings: - Destructive and irreversible. - - Target must not be mounted or in use. - - Optional tools: blkdiscard, ddrescue, dd_rescue, nvme-cli, hdparm. - - nvme and hdparm need matching device types. + - Target must be a real block device, not mounted, and not in use. + - Optional tools: blkdiscard, ddrescue, dd_rescue, nvme, hdparm. - dd fallback may take a long time. Version: ${VERSION} @@ -217,20 +216,6 @@ wipe_dev() { return fi - echo "" - if wipe_with_nvme "$dev"; then - echo "" - log "Device $dev wiped." - return - fi - - echo "" - if wipe_with_hdparm "$dev"; then - echo "" - log "Device $dev wiped." - return - fi - echo "" if wipe_with_dd "$dev"; then echo "" @@ -252,6 +237,20 @@ wipe_dev() { return fi + echo "" + if wipe_with_nvme "$dev"; then + echo "" + log "Device $dev wiped." + return + fi + + echo "" + if wipe_with_hdparm "$dev"; then + echo "" + log "Device $dev wiped." + return + fi + die "Wipe failed. The device may not be fully overwritten." }