Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/disk
diff options
context:
space:
mode:
Diffstat (limited to 'archinstall/lib/disk')
-rw-r--r--archinstall/lib/disk/filesystem.py17
-rw-r--r--archinstall/lib/disk/partition.py26
-rw-r--r--archinstall/lib/disk/user_guides.py8
3 files changed, 34 insertions, 17 deletions
diff --git a/archinstall/lib/disk/filesystem.py b/archinstall/lib/disk/filesystem.py
index 2eb1864d..fe7be498 100644
--- a/archinstall/lib/disk/filesystem.py
+++ b/archinstall/lib/disk/filesystem.py
@@ -33,12 +33,18 @@ class Filesystem:
return True
def partuuid_to_index(self, uuid):
- output = json.loads(SysCommand(f"lsblk --json -o+PARTUUID {self.blockdevice.device}").decode('UTF-8'))
+ for i in range(10):
+ self.partprobe()
+ output = json.loads(SysCommand(f"lsblk --json -o+PARTUUID {self.blockdevice.device}").decode('UTF-8'))
+
+ for device in output['blockdevices']:
+ for index, partition in enumerate(device['children']):
+ if (partuuid := partition.get('partuuid', None)) and partuuid.lower() == uuid:
+ return index
+
+ time.sleep(1)
- for device in output['blockdevices']:
- for index, partition in enumerate(device['children']):
- if partition['partuuid'].lower() == uuid:
- return index
+ raise DiskError(f"Failed to convert PARTUUID {uuid} to a partition index number on blockdevice {self.blockdevice.device}")
def load_layout(self, layout :dict):
from ..luks import luks2
@@ -105,6 +111,7 @@ class Filesystem:
partition['device_instance'].format(partition['filesystem']['format'], options=partition.get('options', []))
if partition.get('boot', False):
+ log(f"Marking partition {partition['device_instance']} as bootable.")
self.set(self.partuuid_to_index(partition['device_instance'].uuid), 'boot on')
def find_partition(self, mountpoint):
diff --git a/archinstall/lib/disk/partition.py b/archinstall/lib/disk/partition.py
index 3630a6f4..faa0838f 100644
--- a/archinstall/lib/disk/partition.py
+++ b/archinstall/lib/disk/partition.py
@@ -147,14 +147,17 @@ class Partition:
This is more reliable than relying on /dev/disk/by-partuuid as
it doesn't seam to be able to detect md raid partitions.
"""
+ for i in range(10):
+ self.partprobe()
- partuuid_struct = SysCommand(f'lsblk -J -o+PARTUUID {self.path}')
- if not partuuid_struct.exit_code == 0:
- raise DiskError(f"Could not get PARTUUID for {self.path}: {partuuid_struct}")
+ partuuid_struct = SysCommand(f'lsblk -J -o+PARTUUID {self.path}')
+ if partuuid_struct.exit_code == 0:
+ if partition_information := next(iter(json.loads(partuuid_struct.decode('UTF-8'))['blockdevices']), None):
+ return partition_information.get('partuuid', None)
- for partition in json.loads(partuuid_struct.decode('UTF-8'))['blockdevices']:
- return partition.get('partuuid', None)
- return None
+ time.sleep(1)
+
+ raise DiskError(f"Could not get PARTUUID for {self.path} using 'lsblk -J -o+PARTUUID {self.path}'")
@property
def encrypted(self):
@@ -177,6 +180,9 @@ class Partition:
# raise DiskError(f'Could not find appropriate parent for encrypted partition {self}')
return self.path
+ def partprobe(self):
+ SysCommand(f'bash -c "partprobe"')
+
def detect_inner_filesystem(self, password):
log(f'Trying to detect inner filesystem format on {self} (This might take a while)', level=logging.INFO)
from ..luks import luks2
@@ -315,9 +321,13 @@ class Partition:
try:
if options:
- SysCommand(f"/usr/bin/mount -o {options} {self.path} {target}")
+ mnt_handle = SysCommand(f"/usr/bin/mount -o {options} {self.path} {target}")
else:
- SysCommand(f"/usr/bin/mount {self.path} {target}")
+ mnt_handle = SysCommand(f"/usr/bin/mount {self.path} {target}")
+
+ # TODO: Should be redundant to check for exit_code
+ if mnt_handle.exit_code != 0:
+ raise DiskError(f"Could not mount {self.path} to {target} using options {options}")
except SysCallError as err:
raise err
diff --git a/archinstall/lib/disk/user_guides.py b/archinstall/lib/disk/user_guides.py
index a70a82db..e9332b7b 100644
--- a/archinstall/lib/disk/user_guides.py
+++ b/archinstall/lib/disk/user_guides.py
@@ -23,7 +23,7 @@ def suggest_single_disk_layout(block_device, default_filesystem=None):
layout[block_device.path]['partitions'].append({
# Boot
"type" : "primary",
- "start" : "1MiB",
+ "start" : "5MiB",
"size" : "513MiB",
"boot" : True,
"encrypted" : False,
@@ -36,7 +36,7 @@ def suggest_single_disk_layout(block_device, default_filesystem=None):
layout[block_device.path]['partitions'].append({
# Root
"type" : "primary",
- "start" : "513MiB",
+ "start" : "518MiB",
"encrypted" : False,
"format" : True,
"size" : "100%" if (using_subvolumes or block_device.size < MIN_SIZE_TO_ALLOW_HOME_PART) else f"{min(block_device.size, 20)*1024}MiB",
@@ -115,7 +115,7 @@ def suggest_multi_disk_layout(block_devices, default_filesystem=None):
layout[root_device.path]['partitions'].append({
# Boot
"type" : "primary",
- "start" : "1MiB",
+ "start" : "5MiB",
"size" : "513MiB",
"boot" : True,
"encrypted" : False,
@@ -128,7 +128,7 @@ def suggest_multi_disk_layout(block_devices, default_filesystem=None):
layout[root_device.path]['partitions'].append({
# Root
"type" : "primary",
- "start" : "513MiB",
+ "start" : "518MiB",
"encrypted" : False,
"format" : True,
"size" : "100%",