Skip to content

Commit

Permalink
bootloader: rely on unified GRUB configuration for UEFI and BIOS
Browse files Browse the repository at this point in the history
With the unified GRUB configuration in Fedora and EL, the bootloader setup no longer requires
a custom EFI stub config. The grub2-common package automatically generates this stub,
which points to a single, hybrid configuration file at /boot/grub2/grub.cfg.

This patch simplifies the code by removing redundant EFI-specific configuration steps and
relying on grub2-common to handle the UEFI stub creation.
  • Loading branch information
KKoukiou committed Nov 14, 2024
1 parent 50e55fd commit 9563fac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 39 deletions.
2 changes: 2 additions & 0 deletions anaconda.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ Requires: python3-pid
Requires: crypto-policies
Requires: crypto-policies-scripts

Requires: grub2-common

# required because of the rescue mode and RDP question
Requires: anaconda-tui = %{version}-%{release}

Expand Down
42 changes: 3 additions & 39 deletions pyanaconda/modules/storage/bootloader/efi.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,9 @@ def write(self):
if self.skip_bootloader: # pylint: disable=no-member
return

try:
os.sync()
self.stage2_device.format.sync(root=conf.target.physical_root) # pylint: disable=no-member
self.install()
finally:
self.write_config() # pylint: disable=no-member
os.sync()
self.stage2_device.format.sync(root=conf.target.physical_root) # pylint: disable=no-member
self.install()

def check(self):
return True
Expand Down Expand Up @@ -177,31 +174,6 @@ def efi_config_file(self):
""" Full path to EFI configuration file. """
return "%s/%s" % (self.efi_config_dir, self._config_file)

def write_config(self):
config_path = "%s%s" % (conf.target.system_root, self.efi_config_file)

with open(config_path, "w") as fd:
grub_dir = self.config_dir
if self.stage2_device.format.type != "btrfs":
fs_uuid = self.stage2_device.format.uuid
else:
fs_uuid = self.stage2_device.format.vol_uuid

if fs_uuid is None:
raise BootLoaderError("Could not get stage2 filesystem UUID")

grub_dir = util.execWithCapture("grub2-mkrelpath", [grub_dir],
root=conf.target.system_root)
if not grub_dir:
raise BootLoaderError("Could not get GRUB directory path")

fd.write("search --no-floppy --fs-uuid --set=dev %s\n" % fs_uuid)
fd.write("set prefix=($dev)%s\n" % grub_dir)
fd.write("export $prefix\n")
fd.write("configfile $prefix/grub.cfg\n")

super().write_config()


class EFISystemdBoot(EFIBase, SystemdBoot):
"""EFI Systemd-boot"""
Expand Down Expand Up @@ -230,14 +202,6 @@ def check(self):
# Force the resolution order to run the systemd-boot check.
return SystemdBoot.check(self) and EFIBase.check(self)

def write_config(self):
""" Write the config settings to config file (ex: grub.cfg) not needed for systemd. """
config_path = join_paths(conf.target.system_root, self.efi_config_file)

log.info("efi.py: (systemd) write_config systemd : %s ", config_path)

super().write_config()

def install(self, args=None):
log.info("efi.py: (systemd) install")
# force the resolution order, we don't want to:
Expand Down

0 comments on commit 9563fac

Please sign in to comment.