QEMU doesn't have native support for multiboot. Instead, you'll need to create a virtual hard drive image and install some sort of multiboot boot loader (such as grub), then put your multiboot image somewhere on the drive (i.e. in a file on a partition).
As far as actually installing grub onto a virtual HDD, there's multiple ways to do it, but here's the process I always use:
- Use
qemu-img
or dd if=/dev/zero
to create your HDD image.
- Download a Linux installer ISO (I typically use Arch Linux).
- Boot
qemu
with the blank HDD image and ISO using -hda <HDD-image-filename> -cdrom <ISO-file-name> -boot once=d
. The last bit ensures qemu
will try to boot from CD first.
- Use
fdisk
/parted
/etc to format the disk.
- Mount your boot partition (the one you want to install grub to) and use
grub-install
.
- Unmount and shut down the emulator.
Then, you'll be able to boot off the HDD image and use grub or whatever loader you choose to boot your multiboot image.
The reason your simple ASM example works is because you're effectively emulating the MBR, the first sector of a typical hard drive, so QEMU's BIOS will boot from it (specifically, it sees that 0xaa55
signature).
jmp $
is in the wrong place. It should be before thetimes
statement. As it is the JMP pushed the boot signature of 0xaa55 outside the first 512 bytes which will cause QEMU to not identify it as a boot sector. – Treasurermov ax, 0x0e
is wrong, it should mov to ah. – Downhearted