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
This commit is contained in:
Xinliang Liu 2020-05-15 07:12:56 +00:00 committed by Radosław Piliszek
parent e865196192
commit b6e057d694
3 changed files with 36 additions and 18 deletions

View File

@ -10,8 +10,10 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
{% if base_package_type == 'rpm' %}
{% set ironic_pxe_packages = [
'grub2-tools',
'grub2-efi-*64',
'grub2-efi-aa64-modules',
'ipxe-bootimgs',
'shim-*64',
'tftp-server',
] %}
@ -24,8 +26,10 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
{{ macros.install_packages(ironic_pxe_packages | customizable("packages")) }}
{% elif base_package_type == 'deb' %}
{% set ironic_pxe_packages = [
'grub-efi-*64-signed',
'ipxe',
'pxelinux',
'shim-signed',
'syslinux-common',
'tftpd-hpa'
] %}
@ -34,10 +38,6 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
{% set ironic_pxe_packages = ironic_pxe_packages + [
'syslinux'
] %}
{% elif base_arch == 'aarch64' %}
{% set ironic_pxe_packages = ironic_pxe_packages + [
'grub-efi-arm64'
] %}
{% endif %}
{{ macros.install_packages(ironic_pxe_packages | customizable("packages")) }}

View File

@ -1,7 +1,8 @@
#!/bin/bash
function prepare_pxe {
# For x86 legacy BIOS boot mode
function prepare_pxe_pxelinux {
chown -R ironic: /tftpboot
for pxe_file in /var/lib/tftpboot/pxelinux.0 /var/lib/tftpboot/chain.c32 /usr/lib/syslinux/pxelinux.0 \
/usr/lib/syslinux/chain.c32 /usr/lib/PXELINUX/pxelinux.0 \
@ -12,6 +13,28 @@ function prepare_pxe {
done
}
# For UEFI boot mode
function prepare_pxe_grub {
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
shim_src_file="/usr/lib/shim/shim*64.efi.signed"
grub_src_file="/usr/lib/grub/*-efi-signed/grubnet*64.efi.signed"
elif [[ "${KOLLA_BASE_DISTRO}" =~ centos|rhel ]]; then
shim_src_file="/boot/efi/EFI/centos/shim*64.efi"
grub_src_file="/boot/efi/EFI/centos/grub*64.efi"
fi
if [[ "${KOLLA_BASE_ARCH}" == "x86_64" ]]; then
shim_dst_file="bootx64.efi"
grub_dst_file="grubx64.efi"
elif [[ "${KOLLA_BASE_ARCH}" == "aarch64" ]]; then
shim_dst_file="bootaa64.efi"
grub_dst_file="grubaa64.efi"
fi
cp $shim_src_file /tftpboot/$shim_dst_file
cp $grub_src_file /tftpboot/$grub_dst_file
}
function prepare_ipxe {
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
cp /usr/lib/ipxe/{undionly.kpxe,ipxe.efi} /tftpboot
@ -23,21 +46,10 @@ function prepare_ipxe {
# Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases
# of the KOLLA_BOOTSTRAP variable being set, including empty.
if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
prepare_pxe
prepare_pxe_pxelinux
prepare_pxe_grub
prepare_ipxe
exit 0
fi
if [[ -d /usr/lib/grub/arm64-efi ]]; then
modules="boot chain configfile efinet ext2 fat gettext help hfsplus loadenv \
lsefi normal part_gpt part_msdos read search search_fs_file search_fs_uuid \
search_label terminal terminfo tftp linux"
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
grub-mkimage -v -o /tftpboot/grubaa64.efi -O arm64-efi -p "grub" $modules
elif [[ "${KOLLA_BASE_DISTRO}" =~ centos ]]; then
grub2-mkimage -v -o /tftpboot/grubaa64.efi -O arm64-efi -p "EFI/centos" $modules
fi
fi
. /usr/local/bin/kolla_httpd_setup

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Fix AArch64 ubuntu ironic-python-agent images UEFI PXE booting failure.
Also fix x86_64 lacking of GRUB efi files issue.
`LP#1879265 <https://bugs.launchpad.net/kolla-ansible/+bug/1879265>`__