Wednesday, December 8, 2010

Install BT4-rc2 on KVM+Virtio

Recently, I tried to migrate my virtual machines KVM.  I tried to install BT4-rc2 on KVM as soon as I got it.  I first set the disk type IDE, but I found it was very slow to install BT4-rc2 in the virtual disk.  So I changed the virtual disk's type to virtio.  I finally could run it after a few hours struggle.

Here is a brief summary.
* Boot from BT4-rc2.iso.
* Compile and load virtio modules.
* Install BT4-rc2.
* Make new initrd file
* Copy virtio modules and initrd file to the target disk.

** Compile and load virtio modules
   virtio modules are not included in BT4-rc2's kernel.  So the installation program could not find the virtio disk /dev/vda.  For supporting virtio disk, I compiled and loaded virtio modules.
   > cd /usr/src/linux

   --- Config Virtio Modules ---
   > make menuconfig
     Mark all virtio modules, they are in
     ->Virtualization                (Basic Modules of Virtio)
     ->Device Drivers->Block Drivers (Virtio Disk Driver)
     ->Device Drivers->Net Drivers   (Virtio Net Driver)

   --- Compile Basic Virtio Modules ---
    > make SUBDIRS=drivers/virtio modules
    > mkdir drivers/net/virtio

   --- Compile Virtio Net Module ---
    > mkdir drivers/net/virtio
    > cat drivers/net/Makefile|grep virt> drivers/net/virtio/Makefile
    > cp drivers/net/virtio_net.c drivers/net/virtio
    > make SUBDIRS=drivers/net/virtio modules

   --- Compile Virtio Block Module ---
    > mkdir dirvers/block/virtio
    > cat drivers/block/Makefile |grep virt> drivers/block/virtio/Makefile
    > cp drivers/block/virtio_blk.c drivers/net/virtio
    > make SUBDIRS=drivers/block/virtio modules

   --- Copy and Load Modules ---
    > mkdir /lib/modules/2.6.35.8/kernel/drivers/virtio
    > cp drivers/virtio/*.ko /lib/modules/2.6.35.8/kernel/drivers/virtio
    > cp drivers/net/virtio/*.ko /lib/modules/2.6.35.8/kernel/drivers/net
    > cp drivers/block/virtio/*.ko /lib/modules/2.6.35.8/kernel/drivers/block
    > depmod -ae
    > modprobe virtio_blk
    > modprobe virtio_pci

** Make new initrd file
   > mkinitramfs -o /tmp/initrd.img-2.6.35.8

** Copy to target
   Copy virtio modules and initrd file to target disk after BT4-rc2 has been installed.
   > mount /dev/vda1 /mnt
   Replace vda1 by the partition in which BT4-rc2 is installed.
    > mv /mnt/boot/initrd.img-2.6.35.8 /mnt/boot/initrd.img-2.6.35.8.bak
    > cp /tmp/initrd.img-2.6.35.8 /mnt/boot/
    > mkdir /mnt/lib/modules/2.6.35.8/kernel/drivers/virtio
    > cd /usr/src/linux
    > cp drivers/virtio/*.ko /mnt/lib/modules/2.6.35.8/kernel/drivers/virtio
    > cp drivers/net/virtio/*.ko /mnt/lib/modules/2.6.35.8/kernel/drivers/net
    > cp drivers/block/virtio/*.ko /mnt/lib/modules/2.6.35.8/kernel/drivers/block
    > cp /lib/modules/2.6.35.8/modules.* /mnt/lib/modules/2.6.35.8/

No comments:

Post a Comment