Skip to content

Commit 2171f0a

Browse files
xin3liangyoctozepto
authored andcommitted
Use distro provided GRUB efi
Use distro provided GRUB efi instead of creating it like ironic GRUB setup doc[1]. This avoids below ubuntu ironic-python-agent images PXE booting failure. ---------- error: invalid magic number. error: you need to load the kernel first. Press any key to continue... ---------- This also fixes x86_64 uefi pxe booting issue by setting up GRUB efi for x86_64. Besides, GRUB setup only needs to do once at bootstrap stage. [1]: https://docs.openstack.org/ironic/train/install/configure-pxe.html#uefi-pxe-GRUB-setup Closes-Bug: #1879265 Change-Id: I8be5bdf5f1a62751aefe6bd0959e8f558fcfe591 (cherry picked from commit b6e057d)
1 parent ff75a2e commit 2171f0a

File tree

3 files changed

+36
-18
lines changed

3 files changed

+36
-18
lines changed

docker/ironic/ironic-pxe/Dockerfile.j2

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
1010
{% if base_package_type == 'rpm' %}
1111
{% set ironic_pxe_packages = [
1212
'grub2-tools',
13+
'grub2-efi-*64',
1314
'grub2-efi-aa64-modules',
1415
'ipxe-bootimgs',
16+
'shim-*64',
1517
'tftp-server',
1618
] %}
1719

@@ -24,8 +26,10 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
2426
{{ macros.install_packages(ironic_pxe_packages | customizable("packages")) }}
2527
{% elif base_package_type == 'deb' %}
2628
{% set ironic_pxe_packages = [
29+
'grub-efi-*64-signed',
2730
'ipxe',
2831
'pxelinux',
32+
'shim-signed',
2933
'syslinux-common',
3034
'tftpd-hpa'
3135
] %}
@@ -34,10 +38,6 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
3438
{% set ironic_pxe_packages = ironic_pxe_packages + [
3539
'syslinux'
3640
] %}
37-
{% elif base_arch == 'aarch64' %}
38-
{% set ironic_pxe_packages = ironic_pxe_packages + [
39-
'grub-efi-arm64'
40-
] %}
4141
{% endif %}
4242

4343
{{ macros.install_packages(ironic_pxe_packages | customizable("packages")) }}
Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/bin/bash
22

33

4-
function prepare_pxe {
4+
# For x86 legacy BIOS boot mode
5+
function prepare_pxe_pxelinux {
56
chown -R ironic: /tftpboot
67
for pxe_file in /var/lib/tftpboot/pxelinux.0 /var/lib/tftpboot/chain.c32 /usr/lib/syslinux/pxelinux.0 \
78
/usr/lib/syslinux/chain.c32 /usr/lib/PXELINUX/pxelinux.0 \
@@ -12,6 +13,28 @@ function prepare_pxe {
1213
done
1314
}
1415

16+
# For UEFI boot mode
17+
function prepare_pxe_grub {
18+
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
19+
shim_src_file="/usr/lib/shim/shim*64.efi.signed"
20+
grub_src_file="/usr/lib/grub/*-efi-signed/grubnet*64.efi.signed"
21+
elif [[ "${KOLLA_BASE_DISTRO}" =~ centos|rhel ]]; then
22+
shim_src_file="/boot/efi/EFI/centos/shim*64.efi"
23+
grub_src_file="/boot/efi/EFI/centos/grub*64.efi"
24+
fi
25+
26+
if [[ "${KOLLA_BASE_ARCH}" == "x86_64" ]]; then
27+
shim_dst_file="bootx64.efi"
28+
grub_dst_file="grubx64.efi"
29+
elif [[ "${KOLLA_BASE_ARCH}" == "aarch64" ]]; then
30+
shim_dst_file="bootaa64.efi"
31+
grub_dst_file="grubaa64.efi"
32+
fi
33+
34+
cp $shim_src_file /tftpboot/$shim_dst_file
35+
cp $grub_src_file /tftpboot/$grub_dst_file
36+
}
37+
1538
function prepare_ipxe {
1639
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
1740
cp /usr/lib/ipxe/{undionly.kpxe,ipxe.efi} /tftpboot
@@ -23,21 +46,10 @@ function prepare_ipxe {
2346
# Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases
2447
# of the KOLLA_BOOTSTRAP variable being set, including empty.
2548
if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
26-
prepare_pxe
49+
prepare_pxe_pxelinux
50+
prepare_pxe_grub
2751
prepare_ipxe
2852
exit 0
2953
fi
3054

31-
if [[ -d /usr/lib/grub/arm64-efi ]]; then
32-
modules="boot chain configfile efinet ext2 fat gettext help hfsplus loadenv \
33-
lsefi normal part_gpt part_msdos read search search_fs_file search_fs_uuid \
34-
search_label terminal terminfo tftp linux"
35-
36-
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
37-
grub-mkimage -v -o /tftpboot/grubaa64.efi -O arm64-efi -p "grub" $modules
38-
elif [[ "${KOLLA_BASE_DISTRO}" =~ centos ]]; then
39-
grub2-mkimage -v -o /tftpboot/grubaa64.efi -O arm64-efi -p "EFI/centos" $modules
40-
fi
41-
fi
42-
4355
. /usr/local/bin/kolla_httpd_setup
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
fixes:
3+
- |
4+
Fix AArch64 ubuntu ironic-python-agent images UEFI PXE booting failure.
5+
Also fix x86_64 lacking of GRUB efi files issue.
6+
`LP#1879265 <https://bugs.launchpad.net/kolla-ansible/+bug/1879265>`__

0 commit comments

Comments
 (0)