booting qemu/kvm directly from a file system

As it happens, it looks like a bug in debian's package of grub.

The -kernel grub.img approach works if I only include the grub modules I need upon grub-mkimage.

The -bios grub.bin works with the newer grub package from experimental (2.00-7). However, the grub.bin that comes with it is not very useful.

It comes with a memdisk that comes with the grub.cfg. It would have been better to use that memdisk to hold the modules and the grub.cfg be specified with the -c option of grub-mkimage. For instance, one of the menu entry looks for /boot/grub/grub.cfg and finds itself in the memdisk as a result. Also, the debian package doesn't include the qemu grub modules, so you can't build a different grub.bin (though you can binary edit the file to change the grub.cfg) unless you do it from the source package.

The -bios grub.bin approach sounds like the cleanest approach to me, but I'll use the -kernel or floppy approach until the debian package is fixed.

EDIT: well, the ata.mod grub module to read emulated IDE drives is a lot slower than using biosdisk.mod in combination with seabios (the default bios when not using -bios grub.bin). Also, it seems that grub firmware doesn't support virtio-blk nor virtio-scsi disks, so kvm -bios grub.bin is not going to be an option for me.

In case anyone wants to goes down that path, I'm now using (zsh syntax):

grub-mkimage -O i386-pc -c =(print -l serial 'terminal_input serial' \
  'terminal_output serial' 'set prefix=(hd0)/boot/grub' '. grub.cfg') -o grub.img \
  at_keyboard configfile biosdisk ext2 linux test serial halt minicmd terminal cat

And -kernel grub.img -nographic passed to kvm. That is to boot Linux VMs with no graphics (only a serial interface, so make sure that the VM's grub is configured to use serial (or at least not configured to use graphics), that the kernel console goes to ttyS0 and that you run a getty on there). It can easily be adapted to work for VGA consoles as well.


After a lot of web browsing I have not found any solution and I've made a wrapper for pygrub to be used with libvirt/kvm.

Maybe this solution is useful for you, even late, so I'd like to share it. It's a libvirt hook script. The script parses the domain configuration on prepare/begin event, lets pygrub find the kernel through the available disks and then copy the images to the desired folder in the host.

Take a look at github.com/baquilla/pygrub-kvm-wrapper.