How to boot EFI kernel using QEMU (kvm)?

OVMF supports -boot since r13683, and supports -kernel -append -initrd since r13923.

  1. Download OVMF-0.1+r14071-1.1.x86_64.rpm or newer version.
  2. Extract bios.bin from the rpm: rpm2cpio OVMF-0.1+r14071-1.1.x86_64.rpm | cpio -idmv
  3. Specify firmware parameter for QEMU: qemu-kvm -bios ./usr/share/qemu-ovmf/bios/bios.bin -m 1G -cdrom boot.iso (Tested with Fedora's boot.iso created with special measures)

I also tested qemu -kernel -append -initrd with kernel 3.5, 3.6, and 3.8.


EFI firmware has format and file hierarchy requirements for ISO image to be bootable(1), and other for disks. Your modified ISO image probably did not meet the requirements so the firmware did not recognize it. EFI firmware also has format requirements for the binary to execute, so your bzImage or whatever kernel image needs to be built with EFISTUB.

You can boot kernel from EFI shell with parameters manually specified. Examples: 2. You can create a startup.nsh to the save a little typing. You can use bootloaders to have more complete management. You need to learn these: 2

EFI firmware saves boot options in NVRAM. QEMU currently does not preserve NVRAM, so boot options are lost once you close QEMU. Without boot options, the firmare tries to find \EFI\BOOT\BOOTX64.EFI to execute but it's not here, so it does not know what to boot and leaves control to you. What you need to do to boot the kernel in EFI shell is just enter a filesystem, navigate to a proper path, and execute a binary.

fs0:
    cd EFI\fedora
    grub.efi

or

vmlinuz.efi ...

OVMF support virtio-scsi since EDK2 r13867.