Running in KVM
Installing CernVM on KVM
CernVM images for KVM (Kernel-based Virtual Machine) are intended to be used by experienced users, or by system administrators (e.g. in unatended environments like Grid worker nodes).For creating and controlling virtual machines with KVM we recommend using libvirt (in particular 'virsh' command line utility) and virt-manager graphical tool.
Prerequisies
- Make sure that your host supports kvm (the output of the command should not be empty)
egrep '(vmx|svm)' --color=always /proc/cpuinfo
- Make sure that the necessary packages are installed
# rpm -qa | egrep 'kvm|bridge-utils|tunctl|virt-manager|libvirt' kmod-kvm-83-164.el5_5.30.x86_64 bridge-utils-1.1-2.x86_64 kvm-83-164.el5_5.30.x86_64 kvm-tools-83-164.el5_5.30.x86_64 virt-manager-0.6.1-12.el5.x86_64 kvm-qemu-img-83-164.el5_5.30.x86_64 etherboot-zroms-kvm-5.4.4-13.el5.x86_64 libvirt-0.6.3-33.el5_5.3.x86_64 #
- Make sure that the kvm kernel module is loaded (if not insert it with 'modprobe kvm-intel' or 'modprobe kvm-amd')
# lsmod|grep kvm
If not insert the module with one of the following commands.
For Intel machines# modprobe kvm-intel
For AMD machines
# modprobe kvm-amd
- Make sure that the permissions of /dev/kvm file are set to 0666. The file should be owned by 'root', and the group ownership should be set to 'kvm'
# ls -al /dev/kvm crw-rw---- 1 root kvm 10, 232 Oct 19 14:49 /dev/kvm
- Make sure that KVM network is properly set up for using NAT
# virsh net-dumpxml default <network> <name>default</name> <uuid>a6ae5d2a-8ab5-45a9-94b2-62c29eb9e4f4< /uuid> <forward mode='nat'/> <bridge name='virbr0' stp='on' forwardDelay='0' /> <ip address='192.168.122.1' netmask='255.255.255.0'> <dhcp> <range start='192.168.122.2' end='192.168.122.254' /> </dhcp> </ip> </network> #
Creating a Virtual Machine
If you plan to run on an unattended environment like (e.g. a worker node) start form either 'Batch Node' or 'Head node' image, otherwise use the 'Basic' image. Download CernVM image from CernVM Downloads page and unzip it.
Create a virtual machine definition file for 'virsh' (libvirt guest domain management interface), which should contain the following:
- Virtual machine name
- Memory size (in MB)
- Type of architecture ('x86_64' for 64 bit images and 'i686' for 32 bit images) and boot device ('hd')
- Hard drive definition
- Network interface definition
- Graphical device definition
Example virtual machine definition file looks like this:
<domain type='kvm'>
<name>CernVM-2.2.0-x86_64</name>
<memory>524288</memory>
<os>
<type arch='x86_64'>hvm</type>
<boot dev='hd'/>
</os>
<devices>
<disk type='file' device='disk'>
<source file='/data/test/cernvm-2.2.0-x86_64.hdd' />
<target dev='hda'/>
</disk>
<interface type='network'>
<source network='default'/>
<model type='virtio'/>
</interface>
<graphics type='vnc' listen='0.0.0.0' port='6019'/>
</devices>
</domain>
Virtual machine is created with the following command:
# virsh create vm-definition.xml
Virtual machines can be listed, started and stopped with:
# virsh list Id Name State ---------------------------------- 18 CernVM-2.2.0-x86_64 running # virsh shutdown CernVM-2.2.0-x86_64 Domain CernVM-2.2.0-x86_64 is being shutdown # virsh start CernVM-2.2.0-x86_64 Domain CernVM-2.2.0-x86_64-4 started #
Virtual machine console can be opened using virt-manager program.
Virtual machine configuration
Please refer to the final CernVM configuration step to configure the virtual machine for a specific experiment.
