Linux Kernels from 2.6.25 and later come with built in paravirtual network and block device drivers so that they can run as paravirtual guests on KVM host running on release 60 or later. For older linux guest kernels than 2.6.25, the recently released linux paravirtual drivers will have to be downloaded and installed. In this article, I will demonstrate how to run Fedora 9 as a paravirtual guest since its most recent kernel update uses the 2.6.25 kernel making it "paravirtual ready".
At the time of this post, the Fedora 9 installs the 2.6.24 linux kernel so you will need to upgrade to the latest development release which is running on a 2.6.25 kernel. You should disable selinux security before rebooting into the updated 2.6.25 kernel as this can cause problems during the boot process.
![]()
Once you're finished upgrading to the 2.6.25 kernel, it is not necessary but you can verify that the kernel module drivers are installed in the 2.6.25 guest kernel as modules. You can verify this by checking the system configuration with the following command. In Fedora, the kernel config files are found in the /boot directory.
# grep /boot/VIRTIO_ config-2.6.25-0.139.rc6.git5.fc9
Below shows an example of what you should see.
![]()
From this output, you can see that the virtio paravirtual device drivers are installed in the updated kernel as modules. Once we verify this, the next step is to build a ramdisk with access to these paravirtual modules.
When the linux kernel first boots, it loads a kernel from ramdisk into memory. In order for this ramdisk kernel to function on the virtio "hardware", you will need to build a ramdisk with the paravirtual driver modules using the mkinitrd tool. You can build this ramdisk by using the 2.6.25 kernel images installed on your system. To list the available kernel images that can be used for building the ramdisk, examine the contents of the /boot/grub/grub.conf. In this example, you can see the contents of my grub.conf file.
![]()
From the contents of this file, I used the kernel image vmlinuz-2.6.25.-0.139.rc6.git5.fc9 (2nd entry from top) to build the customized ramdisk using the mkinitrd tool as shown below. Remember to use the version number without the vmlinuz prefix when specifying the kernel image you're using to build the ramdisk. Here is the command:
mkinitrd --preload=virtio_pci --preload=virtio_blk --preload=virtio_net /boot/initrd-2.6.25-0.139.rc6-virt.img 2.6.25-0.139.rc6.git5.fc9
Below shows a screenshot.

This will take a minute or two to build and should build without any errors. Now in the guest os, change the entry in /boot/grub/device.map from "(hd0) /dev/sda" to "(hd0) /dev/vda". (Note: If your linux guest machine is using LVM/UUID then there is no need to do the following step). Now change the entry in /boot/grub/menu.list from "root=/dev/sda1" to "root=/dev/vda1".
Once this is completed you are ready to boot your linux guest on the paravirtual block device.
Now you have to configure your grub.conf file to include an option to use the new ramdisk you just built. I edited the grub.conf file to include the new image and ramdisk as shown in the snapshot of my grub.conf file earlier.
Shutdown the guest linux machine and start qemu/kvm with the virtio block and network device options as shown. Remember to replace the -hda option with the -drive option for the virtio block device.
qemu-system-x86_64 -drive file=Fedora9.img,if=virtio,boot=on -net nic,model=virtio

You can now select the kernel/ramdisk option you added to your grub.conf file. Your Fedora 9 guest machine should now boot and automatically detect and load drivers for the new paravirtual disk and network card.
I was not able to get this working using a guest with LVM as the ramdisk was unable to detect the volume groups. I have seen other comments on the kvm development mailing list so at least I'm not alone. If anyone has had any luck with LVM, please feel free to post a comment. Thanks!
Comments
It seems that the issue with
Sunday, April 6, 2008 - 14:37 Haydn SolomonIt seems that the issue with lvm is related to the lvm2 package. Reportedly newer versions of the lvm2 package work although I have not tested yet. Once I have tested, I will post a updated comment.
LVM issue
Friday, April 25, 2008 - 07:14 Mark McLoughlin (not verified)Yeah, the lvm issue is fixed in F-9:
https://bugzilla.redhat.com/439175
Thanks for the update
Friday, April 25, 2008 - 16:06 Haydn SolomonThanks for that update Mark. I will give this a test run in a couple of days using the initial release of Fedora 9 and update this post.
works on CentOS 5.3
Saturday, May 16, 2009 - 17:33 Carlos Maldonado (not verified)[root@new-host-10 ~]# uname -a
Linux new-host-10 2.6.18-128.1.10.el5.centos.plus #1 SMP Mon May 11 07:04:55 EDT 2009 i686 i686 i386 GNU/Linux
[root@new-host-10 ~]# cat /etc/fstab
/dev/VolGroup00/LogVol00 / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/VolGroup00/LogVol01 swap swap defaults 0 0
[root@new-host-10 ~]# grep VIRTIO_ /boot/config-2.6.18-128.1.10.el5.centos.plus
CONFIG_VIRTIO_RING=m
CONFIG_VIRTIO_PCI=m
CONFIG_VIRTIO_BLK=m
CONFIG_VIRTIO_NET=m
I can certify these instructions work on CentOS 5.3 using CentOS Plus repos most recent kernel to date