User Tools

Site Tools


kvm

KVM

Installation

Building a Host Kernel

Building a Guest Kernel

The initrd doesn't have a udev implementation, so won't create the device nodes for the vda block devices automatically. We have to manually create these, and arrange for them to be available in /dev inside the initrd. /net/universe/mnt/pool/kvm/kernels/build/initramfs-overlay contains a /dev directory, and device nodes copied from an live cd.

The kvm kernel configs also build the virtio device drivers as modules, so these need to be loaded into the initramfs before the main system can boot. Genkernel does not currently include these modules by default, so the default initramfs scripts need to be updated to add support.

Edit module_load to have the modules included in the initramfs: /usr/share/genkernel/arch/x86_64/module_load|<code bash> - Virtual hardware drivers MODULES_VIRTIO="virtio virtio_balloon virtio_console virtio_net virtio_blk virtio_pci virtio_ring" </code>

Then edit initrd.default to recognise the new VIRTIO module group and have the modules modprobe'd during the /linuxrc> /usr/share/genkernel/default/initrd.default|<code bash> HWOPTS='keymap cache modules pata sata scsi usb firewire waitscan slowusb evms lvm dmraid mdadm fs net virtio' MY_HWOPTS='modules pata sata scsi usb firewire waitscan dmraid mdadm fs net iscsi virtio' </code>

These files are not protected and will be replaced each time {{Package|direct=yes|sys-kernel/genkernel is updated.}}

Now build the kernel, initrd, and modules packages with the following command line: <code bash> genkernel \ --no-clean \ --no-mrproper \ --kernname=kvm-sabayon \ --kerneldir=/usr/src/linux-2.6.35-sabayon \ --kernel-config=/net/universe/mnt/pool/kvm/kernels/build/config-x86_64-2.6.35-kvm-sabayon-r6 \ --iscsi \ --disklabel \ --lvm \ --luks \ --unionfs \ --splash \ --splash=natural-gentoo \ --splash-res=1280x800 \ --initramfs-overlay=/net/universe/mnt/pool/kvm/kernels/build/initramfs-overlay/ \ --minkernpackage=/net/universe/mnt/pool/kvm/kernels/build/kernel-x86_64-2.6.35-kvm-sabayon-r6.tar.bz2 \ --modulespackage=/net/universe/mnt/pool/kvm/kernels/build/modules-x86_64-2.6.35-kvm-sabayon-r6.tar.bz2 \ --no-install \ all </code>

This will build a bzip'd tarball of the kernel files, and another package containing all the modules. Extract the kernel files from the archive and put them in the right place. The generated files wont have the correct kernname either, so fix that at the same time. {{Root|

cd /net/universe/mnt/pool/kvm/kernels/
tar -xjf kernel-x86_6x-2.6.35-kvm-sabayon-r6.tar.bz2
mv kernel-2.6.35-sabayon kernel-x86_64-2.6.35-kvm-sabayon-r6
mv config-x86_64-2.6.34-{sabayon,kvm-sabayon}-r6
mv initramfs-x86_64-2.6.34-{sabayon,kvm-sabayon}-r6

}}

The modules package needs to be copied into the guest, and extracted into the root filesystem. Finally, edit the domain config to use the new kernel and initramfs, then reboot the guest and hope for the best.

Provision a new VM using the command line

Creating a new instance of a template

Sending SysRq keys

You can use virsh to send SysRq key presses to guests; handy if things get stuck and you want to force a slighly more graceful reboot than pulling the virtual power.

{{Root|

  - where $key is one of REISUB
virsh send-key $domain KEY_LEFTALT KEY_SYSRQ KEY_${key}

}}

Credit for this tip to Dusty Mabe for this.

kvm.txt · Last modified: 2014/11/24 02:11 by ben