aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPapoteur <papoteur@mageia.org>2026-01-03 11:03:11 +0100
committerPapoteur <papoteur@mageia.org>2026-01-03 12:18:10 +0100
commita5d012dac31f5b707dd74986267f600bd454de4b (patch)
treebb2fb2e777ad3febc86e3e4a964a3544ef68dc0e
parent02d5220b7e0091e6f08692afd8c3bd962c897be2 (diff)
downloadisodumper-a5d012dac31f5b707dd74986267f600bd454de4b.tar
isodumper-a5d012dac31f5b707dd74986267f600bd454de4b.tar.gz
isodumper-a5d012dac31f5b707dd74986267f600bd454de4b.tar.bz2
isodumper-a5d012dac31f5b707dd74986267f600bd454de4b.tar.xz
isodumper-a5d012dac31f5b707dd74986267f600bd454de4b.zip
Use dd for erasing MBR
-rwxr-xr-xbackend/raw_write.py11
1 files changed, 8 insertions, 3 deletions
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