KVM (Kernel-based Virtual Machine) on Ubuntu 8.04.1 Desktop

I am now demonstrating Ubuntu 8.04.1 Desktop hosting a guest Ubuntu 8.04.1 Desktop by KVM (Kernel-based Virtual Machine).

Step 1 :

Since KVM requires your CPU to support hardware virtualization technology, such as INTEL-VT and AMD-V, you should make sure your CPU is supported. Most modern CPUs support this technology. For AMD, all CPU for Socket AM2 and AM2+ are supported. However, I have no idea for the Intel CPUs and you can check it out from Intel’s website. For your information, some motherboards may disable this feature by default.

If there is a output from the following command on the host computer, your CPU is supported and then carry on; otherwise, stop here. (i.e. If you find ‘svm’ on AMD system and ‘vmxl’ on Intel system from the output, your CPU is supported.)

egrep '(vmx|svm)' /proc/cpuinfo

Step 2 :

On the host computer, install the following packages.

sudo apt-get update
sudo apt-get install kvm libvirt-bin virt-manager

Step 3 :

Add yourself (the current user) to the group of libvirtd.

sudo addgroup `whoami` libvirtd

Step 4 :

The KVM is installed and ready to go. KVM does not support Live CD or DVD feature. That means you should install the guest operating system right away. Make sure you have selected ‘QEMU’ and create the guest under ‘localhost (system)’ on the Virtual Machine Manager.

For example, if you installed Ubuntu 8.04.1 (or other Linux distributions) as guest, you can change the guest screen size on your desire as the default guest screen size is in 16:10.

On the guest, edit the /etc/X11/xorg.conf to your desirable screen size.

Shortcoming of KVM

There is no sound driver or device for the guest. The Number Pad on the guest does not work. The middle roller button on the mouse not function; however, you can use up and down keys to operate the browser.

Bridged networking (Optional)

In general, the guest with KVM is running NAT and ready to surf the internet. The following is the option steps for bridged network between host and guest operating systems. The steps I mentioned here is assumed that the host system is behind a router and the ip addresses are distributed by DHCP from the router.

First of all, you should not create the guest before doing the following steps. Otherwise, the guest will not be bridged accordingly.

Step A :

Install the required package for the bridged network on the host.

sudo apt-get install uml-utilities bridge-utils

On the host, issue the following command to stop the network interface.

sudo invoke-rc.d networking stop

Edit the /etc/network/interfaces by the below command.

sudo nano /etc/network/interfaces

The content of the file should be like this. That is, append the line of ‘auto br0’ and the rest to the end of /etc/network/interfaces. The codes are for bridging eth0 and you can change it as required.

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual

auto br0
iface br0 inet dhcp
bridge_ports eth0
bridge_fd 9
bridge_hello 2
bridge_maxage 12
bridge_stp off

Restart the network interface.

sudo /etc/init.d/networking restart

Step B :

Still on the host.

sudo /etc/udev/rules.d/40-permissions.rules

Append the following line at the end of /etc/udev/rules.d/40-permissions.rules.

KERNEL=="tun", GROUP="kvm", MODE="0660"

Step C :

Still on the host. Make the file /etc/kvm/kvm-ifup look like the following.

sudo /etc/kvm/kvm-ifup


switch=$(ip route ls | awk '/^default / { for(i=0;i<NF;i++) { if ($(i) == "dev") print $(i+1) }}')
'''sudo''' /sbin/ifconfig $1 up
'''sudo''' /usr/sbin/brctl addif ${switch} $1
exit 0

Step D :

Still on the host. Now, edit the /etc/sudoers to make the kvm does not require sudo password to operate.

sudo nano /etc/sudoers

Append the following lines to the end of the file.

# Allow members of the kvm group to configure a bridged virtual network interface
%kvm ALL=(ALL) NOPASSWD: /sbin/ifconfig, /usr/sbin/brctl, /usr/sbin/tunctl

Step E :

Now you can create your guest operating system by selecting the KVM on the menu ‘Applications’ and ‘System Tools’. Make sure to select ‘br0’ as the network interface.

Step F :

On the guest. The guest operating system (here is Ubuntu 8.04.1 Desktop) cannot connect to the internet after booting up. You should do something to make it work automatically.

sudo /etc/network/interfaces

Append the following lines to the end of /etc/network/interfaces on the guest Ubuntu Desktop.

auto eth0
iface eth0 inet dhcp

Finally, your guest will get the ip address that distributed by the router. For example, the host has ip address of and your guest will be something like this You can treat the guest as a physical system on the intranet.

Happy virtualization on Ubuntu Desktop!!!!


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: