aboutsummaryrefslogtreecommitdiffstats
path: root/backend/raw_write.py
diff options
context:
space:
mode:
Diffstat (limited to 'backend/raw_write.py')
-rwxr-xr-xbackend/raw_write.py43
1 files changed, 35 insertions, 8 deletions
diff --git a/backend/raw_write.py b/backend/raw_write.py
index d46fe1e..fe21046 100755
--- a/backend/raw_write.py
+++ b/backend/raw_write.py
@@ -198,9 +198,16 @@ class Dumper(object):
return False
return True
- def _do_persistence(self, target, label, key):
+ def _do_persistence(self, target, label, key, fs_type):
logging.debug("Start doing persistence partition")
p = Popen(["fdisk", target], stdin=PIPE, stderr=PIPE)
+ # commands:
+ # n : new
+ # p : primary partition
+ # 3 : partition number (1-4)
+ # default first sector
+ # default last sector
+ # w : write and quit
outs, errs = p.communicate(input=b"n\np\n3\n\n\nw\n")
working = True
while working:
@@ -250,15 +257,35 @@ class Dumper(object):
logging.debug("New partition created")
self._progress = 25
- # Wait for propagation of the info of new partition table
- if not self.udev_wait("creating a new partition table"):
- return
+ ## Wait for propagation of the info of new partition table
+ #if not self.udev_wait("creating a new partition table"):
+ #logging.error("Timeout")
+ #self.return_state = False
+ #self.finished.set()
+ #return
if key == "":
# example mkfs.ext4 -L mgalive-persist /dev/sdf3
- self.return_message = _("Persistent partition added. Formatting...")
- process = Popen(
- ["mkfs.ext4", "-q", "-F", "-L", label, target + "3"], stderr=PIPE
- )
+ self.return_message = _("Additional partition added. Formatting...")
+ path = target + "3"
+ # Format partition according to the fs_type specified
+ fs_type = fs_type.lower()
+ if fs_type == "fat32":
+ cmd = ["mkdosfs", "-F", "32", "-n", label.upper()[:11], path]
+ elif fs_type == "exfat":
+ cmd = ["mkfs.exfat", "-n", label.upper()[:11], path]
+ elif fs_type == "ntfs":
+ cmd = ["mkntfs", "-f", "-L", label, path]
+ elif fs_type == "ext4":
+ cmd = [
+ "mkfs.ext4",
+ "-q",
+ "-F",
+ "-L",
+ label,
+ path,
+ ]
+ logging.info(f"Executing {' '.join(cmd)}")
+ process = Popen(cmd, stderr=PIPE)
outs, errs = process.communicate()
working = True
while working: