Fix UEFI boot by mounting efivarfs and forcing systemd-boot install
This commit is contained in:
@@ -76,7 +76,7 @@ def run_command(cmd, check=True):
|
|||||||
@contextmanager
|
@contextmanager
|
||||||
def mount_pseudo_fs(mount_root):
|
def mount_pseudo_fs(mount_root):
|
||||||
"""
|
"""
|
||||||
Context manager to bind mount /dev, /proc, and /sys into mount_root.
|
Context manager to bind mount /dev, /proc, /sys, and efivarfs into mount_root.
|
||||||
"""
|
"""
|
||||||
logger.info(f"Mounting pseudo-filesystems to {mount_root}...")
|
logger.info(f"Mounting pseudo-filesystems to {mount_root}...")
|
||||||
mounts = ["dev", "proc", "sys"]
|
mounts = ["dev", "proc", "sys"]
|
||||||
@@ -88,6 +88,18 @@ def mount_pseudo_fs(mount_root):
|
|||||||
os.makedirs(target, exist_ok=True)
|
os.makedirs(target, exist_ok=True)
|
||||||
run_command(["mount", "--bind", f"/{fs}", target])
|
run_command(["mount", "--bind", f"/{fs}", target])
|
||||||
mounted_paths.append(target)
|
mounted_paths.append(target)
|
||||||
|
|
||||||
|
# Mount efivarfs if it exists on the host
|
||||||
|
efivars_path = "/sys/firmware/efi/efivars"
|
||||||
|
if os.path.exists(efivars_path):
|
||||||
|
target = os.path.join(mount_root, "sys/firmware/efi/efivars")
|
||||||
|
os.makedirs(target, exist_ok=True)
|
||||||
|
try:
|
||||||
|
run_command(["mount", "-t", "efivarfs", "efivarfs", target])
|
||||||
|
mounted_paths.append(target)
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(f"Failed to mount efivarfs: {e}")
|
||||||
|
|
||||||
yield
|
yield
|
||||||
finally:
|
finally:
|
||||||
logger.info(f"Unmounting pseudo-filesystems from {mount_root}...")
|
logger.info(f"Unmounting pseudo-filesystems from {mount_root}...")
|
||||||
@@ -111,6 +123,7 @@ def install_minimal_os(mount_root, releasever="43"):
|
|||||||
"coreutils",
|
"coreutils",
|
||||||
"kernel",
|
"kernel",
|
||||||
"systemd",
|
"systemd",
|
||||||
|
"systemd-boot-unsigned",
|
||||||
"dnf",
|
"dnf",
|
||||||
"efibootmgr",
|
"efibootmgr",
|
||||||
"passwd",
|
"passwd",
|
||||||
@@ -212,9 +225,12 @@ UUID={efi_uuid} /boot vfat defaults 0 2
|
|||||||
with open(os.path.join(mount_root, "etc/kernel/cmdline"), "w") as f:
|
with open(os.path.join(mount_root, "etc/kernel/cmdline"), "w") as f:
|
||||||
f.write(f"root=UUID={root_uuid} rw quiet\n")
|
f.write(f"root=UUID={root_uuid} rw quiet\n")
|
||||||
|
|
||||||
|
# Set kernel layout to BLS for systemd-boot
|
||||||
|
with open(os.path.join(mount_root, "etc/kernel/layout"), "w") as f:
|
||||||
|
f.write("bls\n")
|
||||||
|
|
||||||
# Install systemd-boot to the ESP (mounted at /boot)
|
# Install systemd-boot to the ESP (mounted at /boot)
|
||||||
# Use --path=/boot to be explicit, though standard behavior usually finds it.
|
run_command(["chroot", mount_root, "bootctl", "install", "--path=/boot", "--force"])
|
||||||
run_command(["chroot", mount_root, "bootctl", "install", "--path=/boot"])
|
|
||||||
|
|
||||||
# Add kernel entries
|
# Add kernel entries
|
||||||
modules_dir = os.path.join(mount_root, "lib/modules")
|
modules_dir = os.path.join(mount_root, "lib/modules")
|
||||||
@@ -241,5 +257,8 @@ UUID={efi_uuid} /boot vfat defaults 0 2
|
|||||||
|
|
||||||
run_command(cmd)
|
run_command(cmd)
|
||||||
|
|
||||||
|
# Ensure all data is synced to disk
|
||||||
|
run_command(["sync"])
|
||||||
|
|
||||||
logger.info("System configuration complete.")
|
logger.info("System configuration complete.")
|
||||||
log_os_install("CONFIGURE", "complete", "systemd-boot and user configured successfully")
|
log_os_install("CONFIGURE", "complete", "systemd-boot and user configured successfully")
|
||||||
|
|||||||
45
log
Normal file
45
log
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
[2026-02-05 13:43:32] [SESSION_START] [installer] Iridium Installer started - Session: 70aaf88c - Mode: PRODUCTION
|
||||||
|
[2026-02-05 13:43:34] [NAVIGATION_NEXT] [installer] Session: 70aaf88c - Page: welcome - Mode: PRODUCTION
|
||||||
|
[2026-02-05 13:43:36] [NAVIGATION_NEXT] [installer] Session: 70aaf88c - Page: storage - Mode: PRODUCTION
|
||||||
|
[2026-02-05 13:43:36] [SELECTION] [installer] Session: 70aaf88c - Selected disk: /dev/vda
|
||||||
|
[2026-02-05 13:43:37] [NAVIGATION_NEXT] [installer] Session: 70aaf88c - Page: install_mode - Mode: PRODUCTION
|
||||||
|
[2026-02-05 13:43:37] [SELECTION] [installer] Session: 70aaf88c - Install mode: automatic
|
||||||
|
[2026-02-05 13:43:38] [NAVIGATION_NEXT] [installer] Session: 70aaf88c - Page: modules - Mode: PRODUCTION
|
||||||
|
[2026-02-05 13:43:38] [SELECTION] [installer] Session: 70aaf88c - Selected modules: []
|
||||||
|
[2026-02-05 13:43:45] [NAVIGATION_NEXT] [installer] Session: 70aaf88c - Page: user - Mode: PRODUCTION
|
||||||
|
[2026-02-05 13:43:45] [SELECTION] [installer] Session: 70aaf88c - User: admin, Hostname: iridium, Sudo: False
|
||||||
|
[2026-02-05 13:43:46] [NAVIGATION_NEXT] [installer] Session: 70aaf88c - Page: summary - Mode: PRODUCTION
|
||||||
|
[2026-02-05 13:43:46] [INSTALL_START] [installer] Session: 70aaf88c - Disk: /dev/vda - Mode: automatic - Modules: [] - Mock: False
|
||||||
|
[2026-02-05 13:43:46] [INSTALL_PROGRESS] [installer] Session: 70aaf88c - Starting partitioning on /dev/vda
|
||||||
|
[2026-02-05 13:43:46] [INFO] [iridium_installer] Starting auto-partitioning on /dev/vda
|
||||||
|
[2026-02-05 13:43:46] [INFO] [disk] DISK_PARTITION_start: Disk: /dev/vda
|
||||||
|
[2026-02-05 13:43:46] [INFO] [iridium_installer] Ensuring all partitions on /dev/vda are unmounted...
|
||||||
|
[2026-02-05 13:43:46] [INFO] [iridium_installer] Running command: lsblk -nlo NAME,MOUNTPOINT /dev/vda
|
||||||
|
[2026-02-05 13:43:46] [INFO] [iridium_installer] vda
|
||||||
|
[2026-02-05 13:43:46] [INFO] [iridium_installer] vda1
|
||||||
|
[2026-02-05 13:43:46] [INFO] [iridium_installer] vda2
|
||||||
|
[2026-02-05 13:43:46] [INFO] [iridium_installer] Running command: lsblk -lpno NAME,MOUNTPOINT /dev/vda
|
||||||
|
[2026-02-05 13:43:46] [INFO] [iridium_installer] /dev/vda
|
||||||
|
[2026-02-05 13:43:46] [INFO] [iridium_installer] /dev/vda1
|
||||||
|
[2026-02-05 13:43:46] [INFO] [iridium_installer] /dev/vda2
|
||||||
|
[2026-02-05 13:43:46] [INFO] [iridium_installer] Running command: blockdev --getsize64 /dev/vda
|
||||||
|
[2026-02-05 13:43:46] [INFO] [iridium_installer] 21474836480
|
||||||
|
[2026-02-05 13:43:46] [WARN] [iridium_installer] Disk too small for standard layout. Adjusting...
|
||||||
|
[2026-02-05 13:43:46] [INFO] [iridium_installer] Running command: sgdisk -Z /dev/vda
|
||||||
|
[2026-02-05 13:43:48] [INFO] [iridium_installer] GPT data structures destroyed! You may now partition the disk using fdisk or
|
||||||
|
[2026-02-05 13:43:48] [INFO] [iridium_installer] other utilities.
|
||||||
|
[2026-02-05 13:43:48] [INFO] [iridium_installer] Running command: sgdisk -o /dev/vda
|
||||||
|
[2026-02-05 13:43:49] [INFO] [iridium_installer] Creating new GPT entries in memory.
|
||||||
|
[2026-02-05 13:43:49] [INFO] [iridium_installer] The operation has completed successfully.
|
||||||
|
[2026-02-05 13:43:49] [INFO] [iridium_installer] Running command: sgdisk -n 1:0:+1024M -t 1:ef00 -c 1:EFI System /dev/vda
|
||||||
|
[2026-02-05 13:43:50] [INFO] [iridium_installer] The operation has completed successfully.
|
||||||
|
[2026-02-05 13:43:50] [INFO] [iridium_installer] Running command: sgdisk -n 2:0:0 -t 2:8300 -c 2:Root /dev/vda
|
||||||
|
[2026-02-05 13:43:51] [INFO] [iridium_installer] The operation has completed successfully.
|
||||||
|
[2026-02-05 13:43:51] [INFO] [iridium_installer] Running command: partprobe /dev/vda
|
||||||
|
[2026-02-05 13:43:52] [INFO] [iridium_installer] Formatting EFI partition...
|
||||||
|
[2026-02-05 13:43:52] [INFO] [iridium_installer] Running command: mkfs.vfat -F32 /dev/vda1
|
||||||
|
[2026-02-05 13:43:53] [INFO] [iridium_installer] mkfs.fat 4.2 (2021-01-31)
|
||||||
|
[2026-02-05 13:43:53] [INFO] [iridium_installer] Formatting Root partition...
|
||||||
|
[2026-02-05 13:43:53] [INFO] [iridium_installer] Running command: mkfs.ext4 -F /dev/vda2
|
||||||
|
[2026-02-05 13:43:53] [ERROR] [iridium_installer] mke2fs 1.47.3 (8-Jul-2025)
|
||||||
|
[2026-02-05 13:43:53] [INFO] [iridium_installer] Discarding device blocks: 0/4980475
|
||||||
@@ -33,7 +33,7 @@ qemu-system-x86_64 \
|
|||||||
-drive if=pflash,format=raw,readonly=on,file="$OVMF_CODE" \
|
-drive if=pflash,format=raw,readonly=on,file="$OVMF_CODE" \
|
||||||
-drive if=pflash,format=qcow2,file="$OVMF_VARS_LOCAL" \
|
-drive if=pflash,format=qcow2,file="$OVMF_VARS_LOCAL" \
|
||||||
-drive file="$DISK_PATH",format=qcow2,if=virtio \
|
-drive file="$DISK_PATH",format=qcow2,if=virtio \
|
||||||
-cdrom "$ISO_PATH" \
|
# -cdrom "$ISO_PATH" \
|
||||||
-boot once=d \
|
-boot once=d \
|
||||||
-netdev user,id=net0 \
|
-netdev user,id=net0 \
|
||||||
-device virtio-net-pci,netdev=net0 \
|
-device virtio-net-pci,netdev=net0 \
|
||||||
@@ -41,4 +41,4 @@ qemu-system-x86_64 \
|
|||||||
-display gtk,gl=on \
|
-display gtk,gl=on \
|
||||||
-monitor unix:$HOME/.local/share/iridium-installer-vm/monitor.sock,server,nowait \
|
-monitor unix:$HOME/.local/share/iridium-installer-vm/monitor.sock,server,nowait \
|
||||||
-name "Iridium Installer Test VM (UEFI)" \
|
-name "Iridium Installer Test VM (UEFI)" \
|
||||||
-loadvm clean-state
|
# -loadvm clean-state
|
||||||
|
|||||||
Reference in New Issue
Block a user