With the growing projects, we’ve decided to upgrade our test servers to a production grade server and setup virtual machines within the server. This move really makes sense because instead of allocating a workstation for each project as test machine, we are cutting it down into one server with multiple test VMs.
At the time of this writing, there are no official documentation on Lucid Lynx yet. There are a couple of variations on the configuration as compared to Ubuntu 9.10. This setup guide is to configure a KVM on Ubuntu Server and management of the VMs is done remotely from another machine running Ubuntu Desktop.
So, here is the step-by-step guide:
STEP #1: Install lib-virt package.
sudo apt-get install kvm libvirt-bin
STEP #2: Create user to manage lib-virt.
sudo adduser $USER libvirtd
where $USER is the username who will perform VM management.
STEP #3: Install bridge utilities.
sudo apt-get install bridge-utils
STEP #4: Configure network to bridge setup.
Edit /etc/network/interfaces and add the following (assumes dhcp bridge):
auto virbr1 iface virbr1 inet dhcp bridge_ports eth0 bridge_fd 9 bridge_hello 2 bridge_maxage 12 bridge_stp off
STEP #5: Restart networking service.
sudo /etc/init.d/networking restart
If bridge is properly configured you should still be able to connect to any external network. (e.g. ping www.google.com). Once this work, proceed to Ubuntu Desktop to create the VM guests.
STEP #6: Install Virtual Machine Manager (on Ubuntu Desktop machine).
sudo apt-get install virt-manager
STEP #7: Invoke virt-manager and connect to Ubuntu Server.
virt-manager -c qemu+ssh://<ubuntu_server>/system
where <ubuntu_server> is hostname or IP address of the server.
STEP #8: Create the Guest VM image. Virtual Machine Manager provides a GUI to easily create an image. Just right-click on the server and select “New”. You will then be prompted step-by-step on the variables (e.g. # of processors, memory, etc.) needed to be configured for your VM.
STEP #9: Install the Guest VM OS. Use your regular CD/DVD installer or iso image to install the operating system on the VM. In my case, we use Ubuntu Server and Ubuntu Desktop on the guest VMs.
STEP #10: Change guest network connection to use pre-configured bridge. VMM does not have the option to configure bridge network. To setup the bridge, manually change the configuration file (xml) from libvirt. On Ubuntu Server, edit the xml configuration file under /etc/libvirt/qemu by changing the network portion to:
<interface type='bridge'> <source bridge='virbr0'/> </interface>
STEP #11: Restart VM. Upon restart, you should be able to access external network and VM is accessible from external network. On Ubuntu guests, the network device is found as eth3 and you may need to enable eth3 on /etc/network/interfaces.
That’s it. You can repeat steps (#8-#11) to setup additional guest VMs.