I'm trying to emulate a EFI environment using QEMU (kmv); virtualbox takes 15 minutes to boot in EFI mode using archboot.

Using legacy BIOS mode, I can boot using this command:

root@citsnmaiko-deb:/home/maiko/uefi/ovmf# qemu-system-x86_64 -kernel  ../bzImage -initrd ../rootfs.gz -append "rw root=/dev/ram0  ramdisk_size=40960"

and it works with my custom kernel and file system.

file ../bzImage 
../bzImage: Linux kernel x86 boot executable bzImage, version 3.6.1 (root@citsnmaiko-deb) #4 , RO-rootFS, swap_dev 0x3, Normal VGA

it has EFI support too.

I'm trying to do the same with EFI files that I downloaded from here

wget http://ufpr.dl.sourceforge.net/project/edk2/OVMF/OVMF-X64-r11337-alpha.zip -P ovmf
cd ovmf/
unzip -x OVMF-X64-r11337-alpha.zip
# rename the files for QEMU find them
mv OVMF.fd bios.bin
mv CirrusLogic5446.rom vgabios-cirrus.bin
# start QEMU
root@citsnmaiko-deb:/home/maiko/uefi/ovmf# qemu-system-x86_64 -L .  -kernel  ../bzImage -initrd ../rootfs.gz -append "rw root=/dev/ram0  ramdisk_size=40960" 
Could not open option rom 'linuxboot.bin': No such file or directory
pci_add_option_rom: failed to find romfile "pxe-e1000.bin"

And I'm dropped in an EFI shell, not enable to boot.


If I use the the latest Ubuntu release using the same EFI environment

root@citsnmaiko-deb:/home/maiko/uefi/ovmf# qemu-system-x86_64 -L . -boot d -cdrom ../ubuntu-12.10-desktop-amd64.iso
pci_add_option_rom: failed to find romfile "pxe-e1000.bin"

... the boot process works fine.

enter image description here

I've tried to replace the Ubuntu boot files with mine but maybe I don't completely understand its functionality. When I just replace the files after mounting the ISO:

mkdir tmp
bsdtar xf ubuntu-12.10-desktop-amd64.iso -C tmp
cp bzImage tmp/casper/vmlinuz
cp rootfs.gz tmp/casper/initrd.lz 
genisoimage -o customUbuntu.iso tmp/
qemu-system-x86_64 -L . -boot d -cdrom customUbuntu.iso 

the same EFI Shell appears. Is it ok? initrd.lz and rootfs.gz are interchangeable right? How about bzImage and vmlinuz ?

What am I missing?

5 Answers 5


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.

    cd EFI\fedora


vmlinuz.efi ...

OVMF support virtio-scsi since EDK2 r13867.

  • OVFM link is dead.
    – jcoffland
    Commented Jun 4, 2015 at 22:55
  • @jcoffland It's not really dead, the directories are browseable just the folder with the outdated release has been removed. Go to download.opensuse.org/repositories/home:/jejb1:/UEFI and pick the latest release you can find that matches the pattern from the original link.
    – LiveWireBT
    Commented Aug 17, 2015 at 3:53
  • 4
    In modern Ubuntu you can just apt install ovmf and then kvm -bios OVMF.fd ...
    – Tobia
    Commented Jun 18, 2017 at 18:19
  • The link download.opensuse.org/repositories/home:/jejb1:/UEFI/… is dead Commented Aug 26, 2019 at 15:14
  • See the other answer here. Included in Ubuntu 20 nowadays - and there are also easy build instructions.
    – Dagelf
    Commented Jan 14, 2021 at 20:48

On latest Ubuntu 20.04:

sudo qemu-system-x86_64 -enable-kvm -bios /usr/share/ovmf/OVMF.fd -hda myimage.raw 

On earlier Ubuntu's and perhaps other Linuxes:

cd ~
git clone git://github.com/tianocore/edk2.git
cd edk2
git submodule init
git submodule update --depth=1
make -C BaseTools
. edksetup.sh
vi Conf/target.txt
  ACTIVE_PLATFORM       = MdeModulePkg/MdeModulePkg.dsc 
  TOOL_CHAIN_TAG        = GCC5  # or GCC49 GCC48 ... check ./Conf/tools_def.txt
  TARGET_ARCH           = X64
vi Conf/target.txt
  ACTIVE_PLATFORM       = OvmfPkg/OvmfPkgX64.dsc
sudo qemu-system-x86_64 -enable-kvm -bios ./Build/OvmfX64/RELEASE_GCC5/FV/OVMF.fd -hda myimage.raw 

Instructions adapted from https://wiki.ubuntu.com/UEFI/OVMF and https://wiki.ubuntu.com/UEFI/EDK2 and tested on Ubuntu 20.04 as of this post.


Using this script, cd into a kernel source tree and run:

runlinux -- -bios ~/path/to/OVMF.fd

where OVMF.fd was extracted from https://sourceforge.net/projects/edk2/files/OVMF/OVMF-X64-r15214.zip/download

The script generates a minimal filesystem with BusyBox, compiles the kernel and runs it in QEMU with:

qemu-system-x86_64 -enable-kvm -kernel bzImage \
                   -initrd ../rootfs.gz -bios ~/path/to/OVMF.fd

We can now verify that UEFI was used from inside QEMU as mentioned in this post:

ls /sys/firmware/efi

Not a direct answer but as there are none you might be interested in this xorriso bugreport -- I'm going to comment there too but in short, xorriso-1.2.4 with the upstream revision 1044 works fine for me and my hardware stand with exactly this script (it's a Russian spoken wiki but the script part should be legible enough; pay attention to efiboot.img).

Note that /usr/lib/syslinux/isohdpfx.bin comes from syslinux and it seems like the latest 4.06 has relevant changes in EFI department.

Here's another well of useful knowledge on (U)EFI, and thank you for the scriptlet in the question as well :)

qemu-system-x86_64  -kernel xxx.elf -serial /dev/stdout -monitor stdio
  • 5
    Hi and welcome to the site. Please add some details to your answer. What is this command? Where should it be run? Should it be added to the bootlaoder configuration perhaps? How? Where? Unless you explain what this is, I am afraid it isn't a useful answer.
    – terdon
    Commented Oct 15, 2018 at 8:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .