Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/disk/filesystem.py
diff options
context:
space:
mode:
authorAnton Hvornum <anton.feeds@gmail.com>2021-11-11 10:10:12 +0000
committerAnton Hvornum <anton.feeds@gmail.com>2021-11-11 10:10:12 +0000
commit610e161d449918b1ed5cb64ee17ab378d323b9c9 (patch)
treea6d332734a261081843ec8c30f24abb9ac4e4385 /archinstall/lib/disk/filesystem.py
parente3e62039f9c4cbbb6f604c838cd3cd8032150565 (diff)
Removed legacy code related to disk wiping. Also added in partprobe in strategic places (not sure this is enough, will have to test)
Diffstat (limited to 'archinstall/lib/disk/filesystem.py')
-rw-r--r--archinstall/lib/disk/filesystem.py23
1 files changed, 7 insertions, 16 deletions
diff --git a/archinstall/lib/disk/filesystem.py b/archinstall/lib/disk/filesystem.py
index 84b11c05..61a789a1 100644
--- a/archinstall/lib/disk/filesystem.py
+++ b/archinstall/lib/disk/filesystem.py
@@ -20,22 +20,6 @@ class Filesystem:
self.mode = mode
def __enter__(self, *args, **kwargs):
- if self.blockdevice.keep_partitions is False:
- log(f'Wiping {self.blockdevice} by using partition format {self.mode}', level=logging.DEBUG)
- if self.mode == GPT:
- if self.parted_mklabel(self.blockdevice.device, "gpt"):
- self.blockdevice.flush_cache()
- return self
- else:
- raise DiskError('Problem setting the disk label type to GPT:', f'/usr/bin/parted -s {self.blockdevice.device} mklabel gpt')
- elif self.mode == MBR:
- if self.parted_mklabel(self.blockdevice.device, "msdos"):
- return self
- else:
- raise DiskError('Problem setting the disk label type to msdos:', f'/usr/bin/parted -s {self.blockdevice.device} mklabel msdos')
- else:
- raise DiskError(f'Unknown mode selected to format in: {self.mode}')
-
# TODO: partition_table_type is hardcoded to GPT at the moment. This has to be changed.
elif self.mode == self.blockdevice.partition_table_type:
log(f'Kept partition format {self.mode} for {self.blockdevice}', level=logging.DEBUG)
@@ -74,6 +58,8 @@ class Filesystem:
if not self.parted_mklabel(self.blockdevice.device, "msdos"):
raise KeyError(f"Could not create a MSDOS label on {self}")
+ self.blockdevice.flush_cache()
+
# We then iterate the partitions in order
for partition in layout.get('partitions', []):
# We don't want to re-add an existing partition (those containing a UUID already)
@@ -132,6 +118,9 @@ class Filesystem:
if partition.target_mountpoint == mountpoint or partition.mountpoint == mountpoint:
return partition
+ def partprobe(self):
+ SysCommand(f'bash -c "partprobe"')
+
def raw_parted(self, string: str):
if (cmd_handle := SysCommand(f'/usr/bin/parted -s {string}')).exit_code != 0:
log(f"Parted ended with a bad exit code: {cmd_handle}", level=logging.ERROR, fg="red")
@@ -146,6 +135,7 @@ class Filesystem:
:type string: str
"""
if (parted_handle := self.raw_parted(string)).exit_code == 0:
+ self.partprobe()
return True
else:
raise DiskError(f"Parted failed to add a partition: {parted_handle}")
@@ -199,4 +189,5 @@ class Filesystem:
SysCommand(f'bash -c "umount {device}?"')
except:
pass
+ self.partprobe()
return self.raw_parted(f'{device} mklabel {disk_label}').exit_code == 0