Redo backend installer logic to support BIOS/MBR boot on older devices and switch to GRUB2

This commit is contained in:
2026-02-09 15:02:14 +01:00
parent b37fc8d060
commit e8a2f7aaa9
7 changed files with 187 additions and 202 deletions

View File

@@ -54,8 +54,13 @@ def get_total_memory() -> int:
return 0
def is_uefi():
return os.path.exists("/sys/firmware/efi")
def calculate_auto_partitions(disk_device):
disk_size = 0
uefi = is_uefi()
try:
# Get disk size in bytes
result = subprocess.run(
@@ -83,16 +88,21 @@ def calculate_auto_partitions(disk_device):
disk_mb = disk_size / (1024 * 1024)
# Defaults
efi_size = 2 * 1024 * 1024 * 1024
efi_size = 1024 * 1024 * 1024 if uefi else 0
swap_size = ram_size + (2 * 1024 * 1024 * 1024)
min_root_size = 10 * 1024 * 1024 * 1024 # 10GB
# Cap swap for auto-calc if disk is small
if disk_size < 100 * 1024**3:
swap_size = min(swap_size, 4 * 1024**3)
total_required = efi_size + swap_size + min_root_size
use_swap = True
if disk_size < total_required:
efi_size = 1 * 1024 * 1024 * 1024
if uefi:
efi_size = 512 * 1024 * 1024
use_swap = False
swap_size = 0
if disk_size < (efi_size + min_root_size):
@@ -101,26 +111,28 @@ def calculate_auto_partitions(disk_device):
root_size = disk_size - efi_size - swap_size
partitions = [
{
partitions = []
if uefi:
partitions.append({
"type": "partition",
"name": "EFI System",
"filesystem": "vfat",
"mount_point": "/boot",
"mount_point": "/boot/efi",
"size": f"{efi_size / (1024**3):.1f} GB",
"bytes": efi_size,
"style_class": "part-efi",
},
{
"type": "partition",
"name": "Root",
"filesystem": "ext4",
"mount_point": "/",
"size": f"{root_size / (1024**3):.1f} GB",
"bytes": root_size,
"style_class": "part-root",
},
]
})
partitions.append({
"type": "partition",
"name": "Root",
"filesystem": "ext4",
"mount_point": "/",
"size": f"{root_size / (1024**3):.1f} GB",
"bytes": root_size,
"style_class": "part-root",
})
if use_swap:
partitions.append(