Skip to content

Commit

Permalink
Fixes #38178 - Add linuxefi/initrdefi wrapper to GRUB2 templates
Browse files Browse the repository at this point in the history
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]:theforeman#9864
  • Loading branch information
Jan Löser committed Jan 30, 2025
1 parent 07ff0b6 commit 494d461
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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") %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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") %>'
Expand Down

0 comments on commit 494d461

Please sign in to comment.