Booting a GRUB2 image directly in QEMU

grub2qemu

I have an image file that the Linux file utility says is an ELF image.

If I create either an GRUB2 based ISO file or a qcow2 file QEMU is able to boot it successfully. For example qemu-system-i386 myimage.iso.

My grub2 grub.cfg on an ISO is as follows:

menuentry 'TEST' {
    set root='(hd0)/'

legacy_kernel '/myimage' '/myimage'
}

(hd0) changes to (hd0,msdos1) if its on an .img file but none the less it still boots.

My (daft?) question is can I boot this MYIMAGE directly using QEMU? i.e. without GRUB2 directly from the command line?

i.e QEMU MYIMAGE [options]? All I get when I try this is Fread().

Best Answer

You can give this a try:

qemu-system-i386 -kernel /path/to/kernel -initrd /path/to/initial/ram/disk

Your kernel has to be multiboot compliant.

On a side note, I'm attempting to do the same for Xinu, but it core-dumps when loaded directly through qemu -kernel. If it is loaded through grub2, it gets loaded fine.

Related Question