From ce863ae11c6338d9269df3020db7e82f7608a30e Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Wed, 23 Mar 2022 17:04:14 +1300 Subject: [PATCH] Make ipxe-boot image EFI capable This refreshes the ipxe build makefile to build an image that works in both legacy BIOS and UEFI environments. This makes the following changes: - Moves the ipxe submodule commit to current master - Creates an EFI partition efi.img containing ipxe.efi as the default binary - Builds ipxe-boot.img as an MBR/GPT hybrid ISO which boots and runs iPXE in both legacy BIOS and UEFI environments - Stop creating ipxe-boot.qcow2 since the conversion from ipxe-boot.img has an incorrect EFI partition, and there is no real benefit over the raw image anyway - Refresh the documentation for how to upload the images to an OpenStack cloud, remove the redundancy from ipxe/README Change-Id: I720ed5aaa0d55ded73e01aaba9db66602adc26cd --- doc/source/host-cloud/prepare.rst | 29 ++++++++--------- ipxe/Makefile | 53 ++++++++++++++++++++++++------- ipxe/README | 16 ++-------- ipxe/ipxe | 2 +- 4 files changed, 59 insertions(+), 41 deletions(-) diff --git a/doc/source/host-cloud/prepare.rst b/doc/source/host-cloud/prepare.rst index 9a484be..29f8192 100644 --- a/doc/source/host-cloud/prepare.rst +++ b/doc/source/host-cloud/prepare.rst @@ -1,25 +1,26 @@ Preparing the Host Cloud Environment ==================================== -#. Build or download an ipxe-boot image for the baremetal instances. +#. The ``ipxe`` directory contains tools for building an IPXE image which is used by the baremetal + instances to begin provisioning over the network. - #. To download a pre-built image:: + To install the required build dependencies on a Fedora system:: - wget https://repos.fedorapeople.org/repos/openstack-m/ovb/ipxe-boot.qcow2 + sudo dnf install -y gcc xorriso make qemu-img syslinux-nonlinux xz-devel - #. To build the image, run the following from the root of the OVB repo:: + It may be necessary to use the ``direct`` libguestfs backend:: + + export LIBGUESTFS_BACKEND=direct + + To build the image, run the following from the root of the OVB repo:: make -C ipxe - To install the required build dependencies on a Fedora system:: +#. Upload an ipxe-boot image for the baremetal instances, for both UEFI boot and + legacy BIOS boot:: - sudo dnf install -y make gcc perl xz-devel genisoimage qemu-img - -#. Source an rc file that will provide admin credentials for the host cloud. - -#. Upload an ipxe-boot image for the baremetal instances:: - - glance image-create --name ipxe-boot --disk-format qcow2 --property os_shutdown_timeout=5 --container-format bare < ipxe/ipxe-boot.qcow2 + openstack image create --progress --disk-format raw --property os_shutdown_timeout=5 --file ipxe/ipxe-boot.img ipxe-boot + openstack image create --progress --disk-format raw --property os_shutdown_timeout=5 --property hw_firmware_type=uefi --property hw_machine_type=q35 --file ipxe/ipxe-boot.img ipxe-boot-uefi .. note:: The path provided to ipxe-boot.qcow2 is relative to the root of the OVB repo. If the command is run from a different working @@ -28,10 +29,6 @@ Preparing the Host Cloud Environment .. note:: os_shutdown_timeout=5 is to avoid server shutdown delays since since these servers won't respond to graceful shutdown requests. - .. note:: On a UEFI enabled openstack cloud, to boot the baremetal instances - with uefi (instead of the default bios firmware) the image should - be created with the parameters --property="hw_firmware_type=uefi". - #. Upload a CentOS 7 image for use as the base image:: wget http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2 diff --git a/ipxe/Makefile b/ipxe/Makefile index de24a01..30c739a 100644 --- a/ipxe/Makefile +++ b/ipxe/Makefile @@ -4,17 +4,39 @@ IPXE_SRCDIR=ipxe/src # The specific image to use as the OVB iPXE boot image # Override this to use a different image (e.g. ipxe.hd) -IPXE_IMG=ipxe.iso +IPXE_IMG=bin/ipxe.iso -ipxe_img_path=$(IPXE_SRCDIR)/bin/$(IPXE_IMG) +IPXE_EFI=bin-x86_64-efi/ipxe.efi -all: ipxe-boot.img ipxe-boot.qcow2 +ipxe_img_path=$(IPXE_SRCDIR)/$(IPXE_IMG) +ipxe_efi_path=$(IPXE_SRCDIR)/$(IPXE_EFI) -ipxe-boot.img: $(ipxe_img_path) script.ipxe - cp $< $@ +all: ipxe-boot.img -ipxe-boot.qcow2: ipxe-boot.img - qemu-img convert -f raw -O qcow2 $< $@ +ipxe-boot.img: $(ipxe_img_path) efi.img + tmp_dir=$$(mktemp -d) && \ + cp efi.img $$tmp_dir/efi.img && \ + mkdir -p $$tmp_dir/boot/efi && \ + xorriso -osirrox on -indev $(ipxe_img_path) -extract / $$tmp_dir && \ + xorriso -as mkisofs \ + -isohybrid-mbr /usr/share/syslinux/isohdpfx.bin \ + -c boot.catalog \ + -b isolinux.bin \ + -no-emul-boot \ + -boot-load-size 4 \ + -boot-info-table \ + -eltorito-alt-boot \ + -e efi.img \ + -no-emul-boot \ + -isohybrid-gpt-basdat \ + -o ipxe-boot.img \ + $$tmp_dir + +efi.img: $(ipxe_efi_path) + tmp_dir=$$(mktemp -d) && \ + mkdir -p $$tmp_dir/EFI/BOOT && \ + cp $(ipxe_efi_path) $$tmp_dir/EFI/BOOT/BOOTX64.EFI && \ + virt-make-fs --format=raw --type=fat $$tmp_dir efi.img # iPXE is configured by setting config macros in the source tree. The repo # contains a number of config headers in ipxe/src/config/*.h which contain @@ -38,18 +60,27 @@ repo_config_path = $(IPXE_SRCDIR)/config/local repo_config_headers = $(foreach header,$(config_headers),$(repo_config_path)/$(header)) # Copy individual repo_config_headers from ipxe-config/ -$(repo_config_path): ; mkdir $@ +$(repo_config_path): $(IPXE_SRCDIR) + mkdir -p $@ $(repo_config_path)/%.h: ipxe-config/%.h | $(repo_config_path) cp $< $@ +$(IPXE_SRCDIR): + git submodule init + git submodule update + # We disable -Werror so we can build older commits with newer gcc # Don't use parallel make, as this races to initialise config headers in a # clean repo. -$(ipxe_img_path): $(repo_config_headers) - $(MAKE) -C ipxe/src NO_WERROR=1 EMBED=../../script.ipxe bin/$(IPXE_IMG) +$(ipxe_img_path): $(repo_config_headers) script.ipxe + $(MAKE) -C ipxe/src NO_WERROR=1 EMBED=../../script.ipxe $(IPXE_IMG) + +$(ipxe_efi_path): $(repo_config_headers) script.ipxe + $(MAKE) -C ipxe/src NO_WERROR=1 EMBED=../../script.ipxe $(IPXE_EFI) clean: - $(MAKE) -C ipxe/src clean + rm -rf ipxe + mkdir ipxe rm -f ipxe-boot.img ipxe-boot.qcow2 .PHONY: $(ipxe_img_path) clean diff --git a/ipxe/README b/ipxe/README index b97d7b8..ac795c4 100644 --- a/ipxe/README +++ b/ipxe/README @@ -1,17 +1,7 @@ IPXE image-building tools ------------------------- -This directory contains tools for for building an IPXE image. Run ``make`` to -build the image. It is provided as both raw and qcow2. +This directory contains tools for for building an IPXE image. Documentation +to build the image is found at: -The iPXE image has minimal build dependencies. On a Fedora system, these are: - -* gcc -* genisoimage -* make -* qemu-img -* syslinux-nonlinux -* xz-devel - -Please ping Ben Nemec when making a change which -affects the ipxe image to update the public repo of pre-built images. +https://openstack-virtual-baremetal.readthedocs.io/en/latest/host-cloud/prepare.html \ No newline at end of file diff --git a/ipxe/ipxe b/ipxe/ipxe index c63ef42..f58b510 160000 --- a/ipxe/ipxe +++ b/ipxe/ipxe @@ -1 +1 @@ -Subproject commit c63ef427a2b18d318b313a4adf6267bb4dfa0c1c +Subproject commit f58b5109f46088bdbb5345a9d94b636c54345bdf