== Building A VM host == External3 was rebuilt into a VM host. {{{ BASE OS: Ubunut 11.04 Bridge: Open V Switch Emulator: KVM }}} '''UPDATE:''' I've amended the directions to eliminate the need for bridging compatibly. This requires us to not use libvirt and virt-manager/virsh. We want to use open vswitch in it's native mode with out the bridge. This should be a more "flexible" setup. === Building the Host === It was built using the following steps: 1. Install Ubuntu 11.04 from CD (with stock kernel): Had to switch to version 11.04 for kernel compatibly with openvswitch. The running Kernel Version is: {{{ root@external3:~# uname -r 2.6.38-8-server root@external3:~# uname -a Linux external3 2.6.38-8-server #42-Ubuntu SMP Mon Apr 11 03:49:04 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux }}} 1. run kvm-ok. You might need to run {{{ apt-get install cpu-checker }}} Check for a message like this one: {{{ INFO: /dev/kvm does not exist HINT: sudo modprobe kvm_intel INFO: Your CPU supports KVM extensions INFO: KVM (vmx) is disabled by your BIOS HINT: Enter your BIOS setup and enable Virtualization Technology (VT), and then hard poweroff/poweron your system KVM acceleration can NOT be used }}} If disabled, you will need to enter the bios to enable it. 1. Install the openvswitch packages. Do not use the Ubuntu repositories since the install the incorrect versions of the package, instead download the packages that match your kernel version from [http://openvswitch.org/releases/binaries/1.2.2.10448/natty_amd64/ here] I downloaded: {{{ openvswitch-datapath-module-2.6.38-8-server_1.2.2.10448_amd64.deb openvswitch-common_1.2.2.10448_amd64.deb openvswitch-switch_1.2.2.10448_amd64.deb }}} and then Installed them in that order with "dpkg -i". It will recommend a restart. [[BR]]'''NOTE:''' The package '''openvswitch-brcompat_1.2.2.10448_amd64.deb''' was removed because we are not using bridge compatability. 1. Once these are installed and the system freshly restarted, you can query the module. {{{ root@external3:~# ovs-vsctl show d03e1847-34f4-4129-8821-63fff3403553 ovs_version: "1.2.2.10448" }}} lsmod should also show the running openvswitch_mod. 1. The readme refrenced [http://openvswitch.org/cgi-bin/gitweb.cgi?p=openvswitch;a=blob_plain;f=INSTALL.KVM;hb=HEAD here] recomends installing the uml utilities, I didn't need them but I installed them any way. {{{ apt-get install uml-utilities }}} 1. After these components were installed I added a bridge and got it an address: {{{ ovs-vsctl add-br br0 ovs-vsctl add-port br0 eth0 ifconfig eth0 up dhclient br0 }}} 1. Make the ovs-ifup and ovs-ifdown scripts as referenced [http://openvswitch.org/cgi-bin/gitweb.cgi?p=openvswitch;a=blob_plain;f=INSTALL.KVM;hb=HEAD here]. Make sure to chmod +x them. {{{ /etc/ovs-ifup -------------------------------------------------------------------- #!/bin/sh switch='br0' /sbin/ifconfig $1 0.0.0.0 up ovs-vsctl add-port ${switch} $1 -------------------------------------------------------------------- /etc/ovs-ifdown -------------------------------------------------------------------- #!/bin/sh switch='br0' /sbin/ifconfig $1 0.0.0.0 down ovs-vsctl del-port ${switch} $1 -------------------------------------------------------------------- }}} 1. '''NOTE:''' Omit this step since we are not using bridging compatability.[[BR]]'' As referenced in the brcompat documentation [http://openvswitch.org/cgi-bin/gitweb.cgi?p=openvswitch;a=blob_plain;f=INSTALL.bridge;hb=HEAD here], I took these steps to bring up the bridge daemon. According to the kvm documentation, you don't really need brcompat however virtmanager fails to build VM's if you don't bring up the daemon. '''NOTE''' you do not need, and should not install bridge-utils, it will load the bridge modules and create conflicts with openvswitch_mod.'' {{{ insmod /lib/modules/2.6.38-8-server/kernel/brcompat_mod.ko ovs-brcompatd --pidfile --detach }}} 1. Now we're ready to install the KVM packages documented [https://help.ubuntu.com/community/KVM/Installation here], all but the bridge-utils: {{{ sudo apt-get install qemu-kvm }}} '''NOTE:''' This step has been amended to exclude: '''libvirt-bin ubuntu-vm-builder virt-manager'''. This is because we are no longer using bridging compatibly. 1. Next we will build a vm using the command line tools. ---- === Building the client OS === This process is clubbed together from a collection of references listed at the bottom. The crux of the process is that instead of using libvirt based tools (e.g. virsh/virt-manager), we will use the qemu/kvm tools directly. A Virtual machine is really only two components, a running process that is spawned via the kvm exectuable (an alias form qemu), and a disk image that is the state of the running VM. To get the virtual machine up we need to build the disk and then start the process. One the process is spawned, a vnc session will begin listening on the proper port (usually 5900). You can connect a vnc client to this port, and thus get "console" access to the VM. 1. Building the disk: We use the kvm-img tool to build the disk image. there are many formats but we will used the qcow2 type since it supports snapshots. {{{ kvm-img create -f qcow2 filename }}} 1. Spawing the process: This can be as simple as: {{{ kvm filename }}} However we'll want to add a few parameters to get the machine in a usable mode. {{{ kvm -daemonize -vnc :0 -m 2048 -smp 2 -net nic,macaddr=00:11:22:EE:EE:EE -net tap,script=/etc/ovs-ifup,downscript=/etc/ovs-ifdown -drive file=/root/test_mac.img -cdrom /root/ubuntu-11.04-server-amd64.iso -boot order=dc }}} The paramenters are: * -vnc - specify which vnc session to spawn, this argument can be specified in several diffrent ways. * -m - Memeory * -snp - #of cpus * -net nic,.. - specify the mac of the first interface. more can be added but the flags will be diffrent. * -net tap,... - specify how the other end of the nic gets connected. In this case we used the vswitch start up scripts * -drive - the name of the disk drive (there are many ways to specify this flag, include -hda,etc ...) * -cdrom - location of the iso to use as a cd-rom (alternatively you could use /dev/cdrom) * -boot order=dc - specify boot params like boot order, splash screen, etc... If omitted will default to the first disk 1. Once this done you can point your vnc client (locally, or if you specified the parameters correctly remotely) to the specfied port and answer the prompts to preform an installation. 1. After the os is installed, it will try to reboot and fail. At this point you can "shut down" the machine by kill -9 the process. 1. Next "remove" the cdrom and start the vm again. It should boot appropriately. Note the missing -boot param. {{{ kvm -daemonize -vnc :0 -m 2048 -smp 2 -net nic,macaddr=00:11:22:EE:EE:EE -net tap,script=/etc/ovs-ifup,downscript=/etc/ovs-ifdown -drive file=/root/test_mac.img }}} ---- ==== Old process, Deprecated ==== 1. copy the install iso to some directory (I used /root) {{{ wget http://mirrors.mit.edu/ubuntu-releases/11.10/ubuntu-11.10-server-amd64.iso }}} 1. Start up virt-manager (you will probably need x11 forwarding enabled). Click on the new button.[[BR]] [[Image(virtmanager.jpg)]] 1. When you're setting the params make sure to specify bridging as the networking method.[[BR]] [[Image(virtmannet.jpg)]] 1. When you get to the ubuntu install screen, Rember to press f4 on the ubuntu install menu to get the virtual machine version. refrences: * http://translate.googleusercontent.com/translate_c?hl=en&ie=UTF8&rurl=translate.google.de&sl=de&tl=en&u=http://qemu-buch.de/de/index.php/QEMU-KVM-Buch/_Inhaltsverzeichnis&usg=ALkJrhir9hvb8x9SA1RJNnNapZstHXVYGg * http://en.wikibooks.org/wiki/QEMU * http://www.crashcourse.ca/wiki/index.php/QEMU * http://wiki.qemu.org/Manual#User_Documentation * https://help.ubuntu.com/community/KVM * http://openvswitch.org/releases/binaries/1.2.2.10448/natty_amd64/ * http://openvswitch.org/cgi-bin/gitweb.cgi?p=openvswitch;a=blob_plain;f=INSTALL.bridge;hb=HEAD * http://openvswitch.org/cgi-bin/gitweb.cgi?p=openvswitch;a=blob_plain;f=INSTALL.KVM;hb=HEAD * https://help.ubuntu.com/community/KVM/Installation * https://help.ubuntu.com/community/KVM/Networking