From 11607851c481935b256b792aafac7e82c1b27179 Mon Sep 17 00:00:00 2001 From: Softer Date: Wed, 6 May 2026 07:26:59 +0300 Subject: [PATCH] Keep standalone initramfs for grub-btrfs when UKI is enabled (#4513) * Keep standalone initramfs for grub-btrfs when UKI is enabled Fixes #4505 * Move keep_initramfs logic into add_bootloader() The grub-btrfs snapshot detection was in guided.py, forcing custom script authors to replicate it. Since Installer already holds disk_config, the check belongs inside add_bootloader(). --- archinstall/lib/installer.py | 24 ++++++++++++++++++------ archinstall/scripts/guided.py | 6 +++++- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 44a10eb2..801eaee2 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -1754,6 +1754,7 @@ class Installer: self, root: PartitionModification | LvmVolume, efi_partition: PartitionModification | None, + keep_initramfs: bool = False, ) -> None: if not efi_partition or not efi_partition.mountpoint: raise ValueError(f'Could not detect ESP at mountpoint {self.target}') @@ -1777,11 +1778,11 @@ class Installer: config = preset.read_text().splitlines(True) for index, line in enumerate(config): - # Avoid storing redundant image file if m := image_re.match(line): - image = self.target / m.group(2) - image.unlink(missing_ok=True) - config[index] = '#' + m.group(1) + if not keep_initramfs: + image = self.target / m.group(2) + image.unlink(missing_ok=True) + config[index] = '#' + m.group(1) elif m := uki_re.match(line): if diff_mountpoint: config[index] = m.group(2) + diff_mountpoint + m.group(3) @@ -1800,7 +1801,12 @@ class Installer: if not self.mkinitcpio(['-P']): error('Error generating initramfs (continuing anyway)') - def add_bootloader(self, bootloader: Bootloader, uki_enabled: bool = False, bootloader_removable: bool = False) -> None: + def add_bootloader( + self, + bootloader: Bootloader, + uki_enabled: bool = False, + bootloader_removable: bool = False, + ) -> None: """ Adds a bootloader to the installation instance. Archinstall supports one of five types: @@ -1849,7 +1855,13 @@ class Installer: bootloader_removable = False if uki_enabled: - self._config_uki(root, efi_partition) + keep_initramfs = ( + bootloader == Bootloader.Grub + and self._disk_config.has_default_btrfs_vols() + and self._disk_config.btrfs_options is not None + and self._disk_config.btrfs_options.snapshot_config is not None + ) + self._config_uki(root, efi_partition, keep_initramfs) match bootloader: case Bootloader.Systemd: diff --git a/archinstall/scripts/guided.py b/archinstall/scripts/guided.py index 899683f2..aab02cfd 100644 --- a/archinstall/scripts/guided.py +++ b/archinstall/scripts/guided.py @@ -115,7 +115,11 @@ def perform_installation( installation.setup_swap(algo=config.swap.algorithm) if config.bootloader_config and config.bootloader_config.bootloader != Bootloader.NO_BOOTLOADER: - installation.add_bootloader(config.bootloader_config.bootloader, config.bootloader_config.uki, config.bootloader_config.removable) + installation.add_bootloader( + config.bootloader_config.bootloader, + config.bootloader_config.uki, + config.bootloader_config.removable, + ) if config.network_config: install_network_config(