Switching between emulation and virtio/initrd problems...

When I started using KVM I started using disk emulation (IDE drive) and added “virtio_blk” and “virtio_net” to /etc/sysconfig/kernel and did an mkinitrd to create a kernel that would laso run with virtio drivers.

However, after some time experimenting, I switched back to IDE for some performance tests. But then my guest did not boot. After some digging, I found that the ‘mkinitrd’ when executed on a guest with only virtio devices did not include the required modules. Right now I am working around this by creating a monster initrd using “mkinitrd -a”.

Still, I wonder how to create a more optimal initrd that works for both disk emulation and virtio disks.

The output of mkinitrd on the virtio guest is:

Kernel image: /boot/vmlinuz-2.6.34.7-0.5-default
Initrd image: /boot/initrd-2.6.34.7-0.5-default
Kernel Modules: thermal_sys thermal scsi_mod libata ata_piix ata_generic processor fan virtio virtio_pci virtio_ring virtio_net virtio_blk dm-mod dm-snapshot crc16 jbd2 ext4 usbcore pcmcia_core pcmcia mmc_core ssb ohci-hcd ehci-hcd uhci-hcd usbhid linear
Features: dm block usb lvm2 resume.userspace resume.kernel
Bootsplash: openSUSE (800x600)

and the output of the same command on guest with IDE emulation is:

Kernel image: /boot/vmlinuz-2.6.34.7-0.5-default
Initrd image: /boot/initrd-2.6.34.7-0.5-default
Kernel Modules: thermal_sys thermal scsi_mod libata ata_piix ata_generic processor fan virtio virtio_pci virtio_ring virtio_net virtio_blk dm-mod dm-snapshot crc16 jbd2 ext4 pata_sl82c105 pata_hpt3x2n sata_mv pata_sch pata_netcell pata_acpi pata_sc1200 pata_it8213 sata_vsc pata_serverworks sata_via pata_ns87415 ahci pcmcia_core pcmcia pata_pcmcia pata_mpiix pata_jmicron pata_piccolo sata_svw sata_inic162x pdc_adma pata_atp867x pata_ali pata_hpt3x3 pata_efar pata_marvell pata_sil680 pata_cs5530 pata_pdc202xx_old sata_sil pata_it821x sata_sil24 pata_cypress pata_opti sata_promise sata_nv pata_optidma pata_sis pata_hpt37x pata_cmd640 pata_artop pata_amd sata_qstor sata_uli pata_cs5520 sata_sis pata_radisys pata_rz1000 sata_sx4 pata_cmd64x pata_ns87410 pata_triflex pata_hpt366 pata_ninja32 pata_via pata_rdc pata_atiixp pata_pdc2027x pata_oldpiix sd_mod usbcore mmc_core ssb ohci-hcd ehci-hcd uhci-hcd usbhid linear
Features: dm block usb lvm2 resume.userspace resume.kernel
Bootsplash: openSUSE (800x600)

Clearly, a huge difference in the number of modules between the two.

How would I go about creating a more optimal initrd that works for both situations?

Cheers
Erik