From 1873e1dc82f370c7c66cb88defac50fae2050710 Mon Sep 17 00:00:00 2001 From: Peter Jung Date: Sat, 21 Mar 2026 21:02:17 +0100 Subject: [PATCH] bootloader: fix refind install crash when /boot is a separate partition refind-install does not always create /boot/refind_linux.conf, e.g. when /boot is on a separate fat32 partition. The code unconditionally tried to open the file for reading, causing a FileNotFoundError. If the file exists after refind-install, update it as before. Otherwise, generate it manually with the correct kernel parameters. Issue: https://www.reddit.com/r/cachyos/comments/1rzytkb/trying_to_install_cachyos_get_an_error/ Signed-off-by: Peter Jung --- src/modules/bootloader/main.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/modules/bootloader/main.py b/src/modules/bootloader/main.py index 34e5a9fd2b..ab131b7e44 100644 --- a/src/modules/bootloader/main.py +++ b/src/modules/bootloader/main.py @@ -1035,16 +1035,23 @@ def install_refind(efi_directory): check_target_env_call(["refind-install"]) - with open(conf_path, "r") as refind_file: - filedata = [x.strip() for x in refind_file.readlines()] - - with open(conf_path, 'w') as refind_file: - for line in filedata: - if line.startswith('"Boot with standard options"'): - line = f'"Boot with standard options" "{kernel_params}"' - elif line.startswith('"Boot to single-user mode"'): - line = f'"Boot to single-user mode" "{kernel_params}" single' - refind_file.write(line + "\n") + if os.path.exists(conf_path): + with open(conf_path, "r") as refind_file: + filedata = [x.strip() for x in refind_file.readlines()] + + with open(conf_path, 'w') as refind_file: + for line in filedata: + if line.startswith('"Boot with standard options"'): + line = f'"Boot with standard options" "{kernel_params}"' + elif line.startswith('"Boot to single-user mode"'): + line = f'"Boot to single-user mode" "{kernel_params}" single' + refind_file.write(line + "\n") + else: + # refind-install didn't create refind_linux.conf (e.g. separate /boot partition), + # so generate it manually + with open(conf_path, 'w') as refind_file: + refind_file.write(f'"Boot with standard options" "{kernel_params}"\n') + refind_file.write(f'"Boot to single-user mode" "{kernel_params}" single\n') update_refind_config(efi_directory, installation_root_path)