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.
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?
Best Answer
OVMF supports
-boot
since r13683, and supports-kernel -append -initrd
since r13923.OVMF-0.1+r14071-1.1.x86_64.rpm
or newer version.bios.bin
from the rpm:rpm2cpio OVMF-0.1+r14071-1.1.x86_64.rpm | cpio -idmv
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: 2EFI 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.or
OVMF support virtio-scsi since EDK2 r13867.