Skip to content

Commit 02f5222

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 c16f3d4 commit 02f5222

File tree

3 files changed

+37
-19
lines changed

3 files changed

+37
-19
lines changed

docker/ironic/ironic-pxe/Dockerfile.j2

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,19 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
2525
{% if base_arch != 's390x' %}
2626
{% set ironic_pxe_packages = ironic_pxe_packages + [
2727
'grub2-tools',
28-
'grub2-efi-aa64-modules'
28+
'grub2-efi-*64',
29+
'grub2-efi-aa64-modules',
30+
'shim-*64',
2931
] %}
3032
{% endif %}
3133

3234
{{ macros.install_packages(ironic_pxe_packages | customizable("packages")) }}
3335
{% elif base_package_type == 'deb' %}
3436
{% set ironic_pxe_packages = [
37+
'grub-efi-*64-signed',
3538
'ipxe',
3639
'pxelinux',
40+
'shim-signed',
3741
'syslinux-common',
3842
'tftpd-hpa'
3943
] %}
@@ -42,10 +46,6 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
4246
{% set ironic_pxe_packages = ironic_pxe_packages + [
4347
'syslinux'
4448
] %}
45-
{% elif base_arch == 'aarch64' %}
46-
{% set ironic_pxe_packages = ironic_pxe_packages + [
47-
'grub-efi-arm64'
48-
] %}
4949
{% endif %}
5050

5151
{{ 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|rhel ]]; 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)