From 494d461234d5e0aef1445eba35106829f0d268b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20L=C3=B6ser?= Date: Thu, 30 Jan 2025 20:53:52 +0100 Subject: [PATCH] Fixes #38178 - Add linuxefi/initrdefi wrapper to GRUB2 templates Back in time, GRUB2 is using `linux` and `initrd` commands to load the kernel and initrd into ram on legacy BIOS. Later, `linuxefi` and `initrdefi` commands have been added to do the same on UEFI platforms. However, it looks like that `linuxefi` and `initrd` commands are deprecated and distributions like Ubuntu started to remove them starting with 24.04. In case of Secure Boot [1] and Ubuntu 24.04 - putting corresponding shim+GRUB2 binaries in bootloader universe directory - the network boot is not working anymore because of used `linuxefi/initrd` commands in the involved GRUB2 configuration templates. In order fix this we can simply add wrapper functions to provide `linuxefi`/`initrdefi` as commands. [1]:https://github.com/theforeman/foreman/pull/9864 --- .../PXEGrub2/preseed_default_pxegrub2.erb | 16 +++++++--------- .../preseed_default_pxegrub2_autoinstall.erb | 15 ++++++++++----- .../PXEGrub2/pxegrub2_global_default.erb | 8 ++++++++ 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/app/views/unattended/provisioning_templates/PXEGrub2/preseed_default_pxegrub2.erb b/app/views/unattended/provisioning_templates/PXEGrub2/preseed_default_pxegrub2.erb index 09897020374..98f2c33af80 100644 --- a/app/views/unattended/provisioning_templates/PXEGrub2/preseed_default_pxegrub2.erb +++ b/app/views/unattended/provisioning_templates/PXEGrub2/preseed_default_pxegrub2.erb @@ -15,16 +15,14 @@ description: | # # This file was deployed via '<%= template_name %>' template -<% - os_major = @host.operatingsystem.major.to_i - os_name = @host.operatingsystem.name +# Wrapper for deprecated linuxefi/initrd commands +function linuxefi { + linux $* +} +function initrdefi { + initrd $* +} - if (os_name == 'Ubuntu' && os_major > 12) || (os_name == 'Debian' && os_major > 8) - efi_suffix = 'efi' - else - efi_suffix = '' - end --%> set default=0 set timeout=<%= host_param('loader_timeout') || 10 %> diff --git a/app/views/unattended/provisioning_templates/PXEGrub2/preseed_default_pxegrub2_autoinstall.erb b/app/views/unattended/provisioning_templates/PXEGrub2/preseed_default_pxegrub2_autoinstall.erb index 28c0e89e20f..d5e6a6b2c1a 100644 --- a/app/views/unattended/provisioning_templates/PXEGrub2/preseed_default_pxegrub2_autoinstall.erb +++ b/app/views/unattended/provisioning_templates/PXEGrub2/preseed_default_pxegrub2_autoinstall.erb @@ -18,16 +18,21 @@ test_on: # lang = en_US # System locale # -<% - efi_suffix = 'efi' --%> + +# Wrapper for deprecated linuxefi/initrd commands +function linuxefi { + linux $* +} +function initrdefi { + initrd $* +} set default=0 set timeout=<%= host_param('loader_timeout') || 10 %> menuentry '<%= template_name %>' { - linux<%= efi_suffix %> <%= @kernel %> root=/dev/rd/0 rw auto <%= snippet('preseed_kernel_options_autoinstall', variables: {add_userdata_quotes: true}).strip %> - initrd<%= efi_suffix %> <%= @initrd %> + linuxefi <%= @kernel %> root=/dev/rd/0 rw auto <%= snippet('preseed_kernel_options_autoinstall', variables: {add_userdata_quotes: true}).strip %> + initrdefi <%= @initrd %> } <%= snippet_if_exists(template_name + " custom menu") %> diff --git a/app/views/unattended/provisioning_templates/PXEGrub2/pxegrub2_global_default.erb b/app/views/unattended/provisioning_templates/PXEGrub2/pxegrub2_global_default.erb index 023b87a70f2..38094741057 100644 --- a/app/views/unattended/provisioning_templates/PXEGrub2/pxegrub2_global_default.erb +++ b/app/views/unattended/provisioning_templates/PXEGrub2/pxegrub2_global_default.erb @@ -7,6 +7,14 @@ description: | The output is deployed on the host's subnet TFTP proxy. Do not associate or change the name. -%> +# Wrapper for deprecated linuxefi/initrd commands +function linuxefi { + linux $* +} +function initrdefi { + initrd $* +} + default=<%= global_setting("default_pxe_item_global", "local") %> timeout=20 echo Default PXE global template entry is set to '<%= global_setting("default_pxe_item_global", "local") %>'