Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Hey guys I'm trying to emulate a EFI enviroment 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 EFI shell not enable to boot.

QEMU + EFI + LINUX KERNEL + SHELL

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

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 I'm not completely understand its functionality then I just replace the files after mount 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?

share|improve this question

2 Answers 2

up vote 7 down vote accepted

QEMU's -kernel, -boot, and -initrd are BIOS only. They are completely incompatible with EFI (currently).

Update: 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 currently only supports IDE disks. Make sure your QEMU instance is using IDE controller for the booting disk. OVMF support virtio-scsi since EDK2 r13867.

share|improve this answer

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 :)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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