I can create a VM with libvirt/qemu to boot in UEFI mode. I know that it does iPXE by default, but I want to create/modify a iPXE image in order to override filename and next-server properties.

How can I do such thing?


I tried the following:

git clone git://git.ipxe.org/ipxe.git

In the directory ipxe/src create an iPXE script:

Contents of file ipxe/src/chain.ipxe:

prompt --key 0x02 --timeout 2000 Press Ctrl-B for the iPXE command line... && shell ||
set net0/filename /pxeserver/loader/uefi/bootx64.efi.0
set net0/next-server <IP>
show net0/filename
show net0/next-server

Build the image with embedded script:

make bin-x86_64-efi/ipxe.efi EMBED=chain.ipxe

Build the image:

truncate -s 3MiB usb.img
mkfs.vfat usb.img
mmd -i usb.img "::/efi"
mmd -i usb.img "::/efi/boot"
mcopy -i usb.img bin-x86_64-efi/ipxe.efi "::/efi/boot/bootx64.efi"

Then I create a VM specifying this usb.img on the VM storage device. It boots iPXE, prints the filename and next-server overrides, gets IP through DHCP, then tries to boot from the server, it gets the corresponding bootloader, and then it starts the grub shell, as it seems that it does not try to download any grub configuration from next-server (double checked on its logs, it only logs the bootx64.efi.0 file, not grub.cfg file at all, as if it does not redirect PXE boot to the second server.

2 Answers 2


At least on Debian, the iPXE ROM images qemu uses are located at /usr/lib/ipxe and /usr/lib/ipxe/qemu, depending on which virtual NIC you're using in your VM.

Download the iPXE source code, make your modifications to it, build the ROM images, and replace the standard images with your customized ones.

  • 1
    That is kind of what I am doing, but without luck. See above
    – djuarez
    Nov 7, 2019 at 14:45

iPXE has more features than the average bootloader, in this case when booting grub, grub will try to load the configuration from the same location as it was started from, however that does not work due to previously mentioned features.

To work around this make sure to build iPXE with correct config, in this case that is CONFIG=qemu which does #define EFI_DOWNGRADE_UX (page with some details: https://bugs.launchpad.net/maas/+bug/1789319/comments/16 there is mailing list threads with more details)

Regarding named configs, See https://ipxe.org/appnote/named_config

You can then either build this as a ROM to replace the original, either by replacing the original file, or provide path to ROM at commandline. Other ways is to chain from the original to your new one, or as you do now build a usb device.

I think you can even have it in your target to avoid the manual image build step: make bin-x86_64-efi/ipxe.usb EMBED=chain.ipxe CONFIG=qemu

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.