-
Notifications
You must be signed in to change notification settings - Fork 356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide a command line option to install systemd-boot rather than grub2 on x86_64 and arm64 #4368
Changes from all commits
17fd46e
c4b31b6
e069f2a
d8f0384
1891b0f
30eb96c
73486e9
d05eb78
a9e0559
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -256,3 +256,13 @@ Below is a list of pure community features, their community maintainers, and mai | |
* Description: | ||
|
||
``Enable boot of the installed system from a BTRFS subvolume.`` | ||
|
||
systemd-boot as a bootloader | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
* Origin: https://github.com/rhinstaller/anaconda/pull/4368 | ||
* Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2135531 | ||
* Maintainer: Jeremy Linton <[email protected]> | ||
* Description: | ||
|
||
``Enable boot using systemd-boot rather than grub2.`` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
:Type: Kickstart Installation | ||
:Summary: Install an image using systemd-boot rather than grub (#2135531) | ||
|
||
:Description: | ||
With this release, systemd-boot can be selected as an alternative boot | ||
loader for testing and development purposes. | ||
|
||
This can be done with 'inst.sdboot' from the grub/kernel command | ||
line or with '--sdboot' in a kickstart file as part of the | ||
bootloader command. The resulting machine should be free of grub, | ||
shim, and grubby packages, with all the boot files on the EFI | ||
System Partition (ESP). This may mean that it is wise to dedicate | ||
the space previously allocated for /boot to the ESP in order to | ||
assure that future kernel upgrades will have sufficient space. | ||
|
||
For more information, refer to the anaconda and systemd-boot documentation. | ||
|
||
:Links: | ||
- https://bugzilla.redhat.com/show_bug.cgi?id=2135531 | ||
- https://github.com/rhinstaller/anaconda/pull/4368 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,15 +20,18 @@ | |
|
||
from pyanaconda.modules.storage.bootloader.base import BootLoaderError | ||
from pyanaconda.modules.storage.bootloader.grub2 import GRUB2 | ||
from pyanaconda.modules.storage.bootloader.systemd import SystemdBoot | ||
from pyanaconda.core import util | ||
from pyanaconda.core.kernel import kernel_arguments | ||
from pyanaconda.core.i18n import _ | ||
from pyanaconda.core.configuration.anaconda import conf | ||
from pyanaconda.core.kernel import kernel_arguments | ||
from pyanaconda.core.path import join_paths | ||
from pyanaconda.product import productName | ||
|
||
from pyanaconda.anaconda_loggers import get_module_logger | ||
log = get_module_logger(__name__) | ||
|
||
__all__ = ["EFIBase", "EFIGRUB", "Aarch64EFIGRUB", "ArmEFIGRUB", "MacEFIGRUB"] | ||
__all__ = ["EFIBase", "EFIGRUB", "Aarch64EFIGRUB", "ArmEFIGRUB", "MacEFIGRUB", "Aarch64EFISystemdBoot", "X64EFISystemdBoot"] | ||
|
||
|
||
class EFIBase(object): | ||
|
@@ -42,6 +45,16 @@ def efi_config_dir(self): | |
def _efi_config_dir(self): | ||
return "efi/EFI/{}".format(conf.bootloader.efi_dir) | ||
|
||
def get_fw_platform_size(self): | ||
try: | ||
with open("/sys/firmware/efi/fw_platform_size", "r") as f: | ||
value = f.readline().strip() | ||
except OSError: | ||
log.info("Reading /sys/firmware/efi/fw_platform_size failed, " | ||
"defaulting to 64-bit install.") | ||
value = '64' | ||
return value | ||
|
||
def efibootmgr(self, *args, **kwargs): | ||
if not conf.target.is_hardware: | ||
log.info("Skipping efibootmgr for image/directory install.") | ||
|
@@ -134,7 +147,7 @@ def install(self, args=None): | |
class EFIGRUB(EFIBase, GRUB2): | ||
"""EFI GRUBv2""" | ||
_packages32 = [ "grub2-efi-ia32", "shim-ia32" ] | ||
_packages_common = [ "efibootmgr", "grub2-tools" ] | ||
_packages_common = ["efibootmgr", "grub2-tools", "grub2-tools-extra", "grubby" ] | ||
stage2_is_valid_stage1 = False | ||
stage2_bootable = False | ||
|
||
|
@@ -144,14 +157,7 @@ def __init__(self): | |
super().__init__() | ||
self._packages64 = [ "grub2-efi-x64", "shim-x64" ] | ||
|
||
try: | ||
f = open("/sys/firmware/efi/fw_platform_size", "r") | ||
value = f.readline().strip() | ||
except OSError: | ||
log.info("Reading /sys/firmware/efi/fw_platform_size failed, " | ||
"defaulting to 64-bit install.") | ||
value = '64' | ||
if value == '32': | ||
if self.get_fw_platform_size() == '32': | ||
self._is_32bit_firmware = True | ||
|
||
@property | ||
|
@@ -197,13 +203,70 @@ def write_config(self): | |
super().write_config() | ||
|
||
|
||
class EFISystemdBoot(EFIBase, SystemdBoot): | ||
"""EFI Systemd-boot""" | ||
_packages_common = ["efibootmgr", "systemd-udev", "systemd-boot", "sdubby"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sdubby does not exist There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jlinton should we remove the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The package should be mandatory, but it is still in review (https://bugzilla.redhat.com/show_bug.cgi?id=2134972). See the comments above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://bugzilla.redhat.com/show_bug.cgi?id=2134972 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Formally it is under review. But I think that if the review is supposed to be more than just a rubber-stamp procedure, then IMO this particular package should not pass it. It provides a concentrated dose of bad technical choices and super super brittle workarounds for shortcomings in other packages. The good thing is that all of those other packages are under our control, so we can fix things: anaconda, grub2, kernel-install, kernel scriptlets, systemd-boot. We don't need a combination of rpm packaging, bash, python, and awk to serve as glue between those other packages. |
||
_packages64 = [] | ||
|
||
def __init__(self): | ||
super().__init__() | ||
|
||
if self.get_fw_platform_size() == '32': | ||
# not supported try a different bootloader | ||
log.error("efi.py: systemd-boot is not supported on 32-bit platforms") | ||
raise BootLoaderError(_("Systemd-boot is not supported on this platform")) | ||
Comment on lines
+214
to
+217
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Strictly speaking, sd-boot has a 32-bit variant. I think it isn't tested much, and it's fine not to even try it from Anaconda, but it exists. |
||
|
||
@property | ||
def packages(self): | ||
return self._packages64 + self._packages_common | ||
|
||
@property | ||
def efi_config_file(self): | ||
""" Full path to EFI configuration file. """ | ||
return join_paths(self.efi_config_dir, self._config_file) | ||
|
||
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: | ||
# efibootmgr remove old "fedora" | ||
# or use efiboot mgr to install a new one | ||
# lets just use `bootctl install` directly. | ||
# which will fix the efi boot variables too. | ||
SystemdBoot.install(self) | ||
|
||
|
||
class Aarch64EFIGRUB(EFIGRUB): | ||
_serial_consoles = ["ttyAMA", "ttyS"] | ||
_efi_binary = "\\shimaa64.efi" | ||
|
||
def __init__(self): | ||
super().__init__() | ||
self._packages64 = ["grub2-efi-aa64", "shim-aa64"] | ||
self._packages64 = ["grub2-efi-aa64", "shim-aa64", "grub2-efi-aa64-cdboot"] | ||
|
||
|
||
class Aarch64EFISystemdBoot(EFISystemdBoot): | ||
_serial_consoles = ["ttyAMA", "ttyS"] | ||
_efi_binary = "\\systemd-bootaa64.efi" | ||
|
||
def __init__(self): | ||
super().__init__() | ||
self._packages64 = [] | ||
|
||
class X64EFISystemdBoot(EFISystemdBoot): | ||
_efi_binary = "\\systemd-bootx64.efi" | ||
|
||
def __init__(self): | ||
super().__init__() | ||
self._packages64 = [] | ||
|
||
|
||
|
||
class ArmEFIGRUB(EFIGRUB): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"grub2" ?