Building a KVM with the Ubuntu Server
KVM is a full featured virtual server that allows for the user to create multiple operating systems on a single platform.
Ubuntu Server has the ability to run KVM out of the box with minimal setup. The one major caveat is that KVM requires Hardware Virtualization. This means that your Computer hardware whether Desktop or Server spec has to have the CMOS and CPU extensions to support Hardware Virtualization. More information can be found on this topic at Ubuntu KVM Requirements
Assuming that your computer can play nice with KVM this is what you will need to install the packages nessary for KVM to work correctly.
You need to install packages so that the Ubuntu Server has the KVM modules available to it.
sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder
These packages are all that you need to get KVM running on KVM compatible hardware. Aside from the packages necessary it is recommended that you add at least one other user to the libvirtd system so that a user other than ROOT can manage the virtual Machines.
sudo adduser USERNAME libvirtd
Building the Services that KVM will use is simple, but the most technical aspect of the building process is in the development of the networking aspect of the KVM machine. It is my recommendation that a bridged network is created so that the Virtual Machines can use the same NIC card that the host server uses. It is certainly possible to have the KVM Virtual Machines run on a separate NIC card or on a VNIC but for this install we will be using a Bridged Network.
To create a bridged network in Ubuntu Server it is relatively simple though does require editing the network setup. You now have to setup the network interfaces.
sudo nano /etc/network/interfaces
Once in the Network Interfaces you need to modify one of the available networks. You have to change a working Networking interface to support a Bridged Interface.
Here is a typical setup without bridging activated.
auto eth0 iface eth0 inet static address 10.10.10.200 netmask 255.255.255.0 network 10.10.10.0 broadcast 10.10.10.255 gateway 10.10.10.1 dns-nameservers 184.108.40.206
Here is an example of the setup after the change to a bridged.
auto eth0 iface eth0 inet manual auto br0 iface br0 inet static address 10.10.10.200 netmask 255.255.255.0 dns-nameservers 220.127.116.11 bridge_ports eth0 bridge_fd 9 bridge_hello 2 bridge_maxage 12 bridge_stp off
Once the bridging has been setup and is inplace you have to restart the networking for the changes to take effect.
sudo /etc/init.d/networking restart
You now need to create a DEV directory for the KVM to mount memory and stats correctly.
sudo mkdir /dev/cgroup
After building the mount point you will have to create the mount in your fstab. To edit the fstab, the partion loader at boot;
sudo vi /etc/fstab
Now add the line of code that will auto mount the device directory
cgroup /dev/cgroup cgroup defaults 0 0
You are now ready to begin building your Virtual Machines. Here is a post on how-to build KVM Virtual Machines. Building KVM Virtual Machines