From a5d012dac31f5b707dd74986267f600bd454de4b Mon Sep 17 00:00:00 2001 From: Papoteur Date: Sat, 3 Jan 2026 11:03:11 +0100 Subject: Use dd for erasing MBR --- backend/raw_write.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'backend') diff --git a/backend/raw_write.py b/backend/raw_write.py index 9a340b0..2a9f126 100755 --- a/backend/raw_write.py +++ b/backend/raw_write.py @@ -35,7 +35,7 @@ import logging import os import sys import time -from subprocess import Popen, PIPE +from subprocess import run, Popen, PIPE class Dumper(object): @@ -203,8 +203,13 @@ class Dumper(object): if order == b"1": logging.debug("Erasing MBR") # First erase MBR and partition table , if any - # execute(["dd", "if=/dev/zero", "of=%s" % device_path, "bs=512", "count=1"]) - self._do_write("/dev/zero", target, 512, False, 0, 0) + p = run(["dd", "if=/dev/zero", "of=%s" % target, "bs=512", "count=1"], capture_output=True) + if p.returncode != 0: + print(stderr) + self.return_message = _("Writing error.") + logging.error(self.return_message) + self.return_state = False + return p = Popen(["fdisk", target], stdin=PIPE, stderr=PIPE) # commands: # n : new -- cgit v1.2.1