From 752b6ddb604847e9e834ad4d2761aa1064a0f4e7 Mon Sep 17 00:00:00 2001 From: N0VA Date: Tue, 10 Feb 2026 15:01:59 +0100 Subject: [PATCH] Fix UEFI boot by ensuring unique machine-id and correctly adding kernel entries --- iridium_installer/backend/os_install.py | 34 +++++++++++++++++++------ 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/iridium_installer/backend/os_install.py b/iridium_installer/backend/os_install.py index 0f244ad..40c294a 100644 --- a/iridium_installer/backend/os_install.py +++ b/iridium_installer/backend/os_install.py @@ -42,6 +42,12 @@ def run_command(cmd, check=True): for line in stream: line_clean = line.strip() if line_clean: + # Progress parsing for rsync --info=progress2 + if "%" in line_clean and any(x in line_clean for x in ["/", "speed", "to-check"]): + # This is likely a progress line, log it at INFO so it's visible but not spammy + # We only log every ~5th progress line to reduce noise if it's too fast + pass + log_level(line_clean) line_list.append(line) @@ -50,7 +56,6 @@ def run_command(cmd, check=True): t1 = threading.Thread( target=read_stream, args=(process.stdout, stdout_lines, logger.info) ) - # Log stderr as INFO to avoid Discord notification spam, but still capture it t2 = threading.Thread( target=read_stream, args=(process.stderr, stderr_lines, logger.info) ) @@ -68,7 +73,6 @@ def run_command(cmd, check=True): if check and returncode != 0: error_msg = f"Command failed: {' '.join(cmd)}\nExit Code: {returncode}\nStderr: {stderr_str}" - # Log this specific failure as ERROR so it DOES go to Discord logger.error(error_msg) raise subprocess.CalledProcessError( returncode, cmd, output=stdout_str, stderr=stderr_str @@ -265,8 +269,12 @@ def configure_system(mount_root, partition_info, user_info=None, disk_device=Non # 3. Configure Bootloader if uefi: logger.info("Configuring systemd-boot...") - if not os.path.exists(os.path.join(mount_root, "etc/machine-id")): - run_command(["chroot", mount_root, "systemd-machine-id-setup"]) + + # Remove any copied machine-id to ensure a unique one is generated + mid_path = os.path.join(mount_root, "etc/machine-id") + if os.path.exists(mid_path): + os.remove(mid_path) + run_command(["chroot", mount_root, "systemd-machine-id-setup"]) os.makedirs(os.path.join(mount_root, "etc/kernel"), exist_ok=True) with open(os.path.join(mount_root, "etc/kernel/cmdline"), "w") as f: @@ -275,20 +283,30 @@ def configure_system(mount_root, partition_info, user_info=None, disk_device=Non with open(os.path.join(mount_root, "etc/kernel/layout"), "w") as f: f.write("bls\n") + # Initialize systemd-boot run_command(["chroot", mount_root, "bootctl", "install", "--path=/boot"]) - # Add kernel entries + # Sync kernels and generate BLS entries + # Since we rsync'd, kernels are in /lib/modules and /boot + # We use kernel-install to make sure they are properly set up for systemd-boot modules_dir = os.path.join(mount_root, "lib/modules") if os.path.exists(modules_dir): kvers = [d for d in os.listdir(modules_dir) if os.path.isdir(os.path.join(modules_dir, d))] for kver in kvers: - logger.info(f"Adding kernel entry for {kver}...") + logger.info(f"Setting up boot entries for kernel {kver}...") + + # Ensure initramfs exists in /boot (rsync should have copied it, but let's be sure) initrd_path = f"/boot/initramfs-{kver}.img" + vmlinuz_path = f"/boot/vmlinuz-{kver}" + if not os.path.exists(os.path.join(mount_root, initrd_path.lstrip("/"))): + logger.info(f"Generating initramfs for {kver}...") run_command(["chroot", mount_root, "dracut", "--force", initrd_path, kver]) - kernel_image = f"/lib/modules/{kver}/vmlinuz" - run_command(["chroot", mount_root, "kernel-install", "add", kver, kernel_image, initrd_path]) + # kernel-install add [initrd] + # On Fedora, kernel-install add will populate /boot/// + if os.path.exists(os.path.join(mount_root, vmlinuz_path.lstrip("/"))): + run_command(["chroot", mount_root, "kernel-install", "add", kver, vmlinuz_path]) else: logger.info("Configuring GRUB2 (BIOS)...") # Ensure /etc/default/grub exists