fix: reorder wipe method fallback sequence

This commit is contained in:
2026-04-28 00:33:27 +02:00
parent 07c210164a
commit 62ac956836
3 changed files with 30 additions and 19 deletions
+2 -2
View File
@@ -17,11 +17,11 @@ description: mtm-ddwipe project conventions
- Keep optional tools optional. - Keep optional tools optional.
- Use extra wipe methods only if the command is present. - Use extra wipe methods only if the command is present.
- Use `ddrescue` or `dd_rescue` only after `dd` fails. - 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. - Use `nvme` and `hdparm` only on matching device types.
- Do not make new external tools required. - Do not make new external tools required.
- Keep changes minimal and preserve intent. - 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. - If non-interactive support is added, make it an opt-in safety flag.
# Project identity # Project identity
+12
View File
@@ -1,2 +1,14 @@
# mtm-ddwipe # 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`.
+16 -17
View File
@@ -14,9 +14,8 @@ Wipe a block device.
Warnings: Warnings:
- Destructive and irreversible. - Destructive and irreversible.
- Target must not be mounted or in use. - Target must be a real block device, not mounted, and not in use.
- Optional tools: blkdiscard, ddrescue, dd_rescue, nvme-cli, hdparm. - Optional tools: blkdiscard, ddrescue, dd_rescue, nvme, hdparm.
- nvme and hdparm need matching device types.
- dd fallback may take a long time. - dd fallback may take a long time.
Version: ${VERSION} Version: ${VERSION}
@@ -217,20 +216,6 @@ wipe_dev() {
return return
fi 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 "" echo ""
if wipe_with_dd "$dev"; then if wipe_with_dd "$dev"; then
echo "" echo ""
@@ -252,6 +237,20 @@ wipe_dev() {
return return
fi 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." die "Wipe failed. The device may not be fully overwritten."
} }