Xen Hypervisor: Running multiple OS on the same machine

Editors Note: This post targets extremely advance users and power users of linux. Please follow the steps carefully if you don’t know what you are doing.

Most of us are aware of Dual-Boot or Virtualizing the OS using VMWare or VirtualBox but there are some problem with the above two techniques. In case of dual booting, if we want to move to another OS we will have to restart the whole system. In case of Virtualization using VMWare or VirtualBox though, you get rid of the restarting problem but the performance with the guest OS is not upto the mark. So, what is the solution to the above problems?

A hypervisor(bare-metal hypervisor) is the solution to the above problems. So, the question arises what is a hypervisor? So, lets go and find this answer.

Introduction to Hypervisors

A hypervisor can be defined as a piece of software, firmware or hardware that can run Virtual Machines. There are two types of hypervisors Type 1 and Type 2.

Type 1 Hypervisors(Fig. 1): These types of hypervisors run just above the hardware layer and has direct access to the hardware and are also called Bare-Metal Hypervisors. Thus the guest OS runs on a level above the hypervisor. The examples of these types of hypervisors are Xen, Citrix XenServer(commercial alternative to Xen), Microsoft Hyper-V, etc.

Type 2 Hypervisors(Fig. 2):  These type of hypervisors run within a conventional Operating System environment and are also called Hosted hypervisors. The examples of these types of hypervisors are VMWare Workstation, VirtualBox, etc.

These hypervisors provide a layer of hardware virtualization through which multiple OS can simultaneously. In this article I will explain on Type 1 or Bare-Metal hypervisors.

Type 1 Hypervisors

These hypervisors run just above the hardware and try to implement the basic layer of hardware virtualization. A number of guest OS can be made to run simultaneously on these type of hypervisors. The guest OS interacts with these hypervisors to do its various tasks like interfacing with the hardware devices or to allocate memory and control the processor execution.

Hypervisors provide a layer of separation between different guest OS so that the guest OS can run independently. There are mainly two types of virtualizations possible using Type 1 Hypervisors namely 1). ParaVirtualization and 2). Full Virtualization.

Lets compare both of these virtualizations.

Para-Virtualization: In this type of virtualization the guest OS needs to be modified so that instead of interacting with hardware directly it interacts with the hypervisor for resource allocation.

Para-Virtualization avoids the need to emulate full hardware and firmware services which makes managing a paravirtulized guest easy to manage and also reduces the potential attack surface to malicious guest.

Full Virtualization: Full Virtualization doesn’t need a modified guest OS. It is capable of running a unmodified OS or a proprietary OS like Microsoft Windows. To achieve such type of virtualization a hypervisor depends upon Hardware Assisted Virtualization. In this type of virtualization the guest OS can directly interact with the hardware and can run on its full potential.

Xen: A powerful hypervisor

Xen is a hypervisor providing services that allows multiple computer operating systems to execute on the same hardware concurrently.

Xen is a powerful hypervisor capable of running many different types of guest OS like linux, netBSD, Solaris and Microsoft Windows.

Xen is a bare-metal hypervisor which provides a layer to the Guest OS for interfacing with the hardware.

Xen is capable of providing both para-virtualization and full virtualization. For Full Virtualization their should be Hardware-assisted Virtualization support.

Xen also supports live migration from one OS to another and aims to provide 0 downtime in migration. For this Xen loads all the OS address space in the memory so switching can be ultra-fast.

System Requirements for Xen:

A little explanation?

Now, we will know how to set dom0 and domU on Ubuntu 12.10.

Lets first know what exactly are these dom0 and domU.

Dom0

dom0 is the initial domain that is started by the Xen Hypervisor on boot. Without this the Xen hypervisor is just useless.

Dom0 is essentially the host operating system on which Xen hypervisor run Xen Mangement toolstack and has special privileges, like being able to access the hardware directly.

DomU

domU is the counterpart to dom0. It has no special privileges and can not interface the hardware directly. The kernel of domU comes from dom0 ‘s filesystem, not from filesystem exported to domU.

Now when we know what are dom0 and domU, lets have a look on how to install Xen as dom0 and domu on Ubuntu 12.10.

Installing Xen as dom0 and domU on Ubuntu

Installing Xen dom0 and domU on Ubuntu is very much easier. Lets have a look how to do it.

Open terminal in Ubuntu by pressing Ctrl+Alt+T and follow this guide.

Step 1: Write the following command in the terminal

sudo apt-get install xen-hypervisor-4.1-amd64 xen-utils-4.1 xenwatchxen-tools xen-utils-common xenstore-utils virtinst virt-viewer virt-manager

Running this command you will prompted to enter your password. Enter it and Ubuntu will ask you whether you want to install it or not. Just Press Y followed by Enter.

Step 2: Now all the required packages have been installed. Now you need to run your dom0. For this you will have to restart your system. But wait… there is one thing left. We need to edit a file “/etc/xen/xend-config.sxp”. For this run this command

 sudo gedit /etc/xen/xend-config.conf

In this file find “#(xend-unix-server no)” and change it to “(xend-unix-server yes)”.

Now restart and choose Ubuntu with Xen Hypervisor from GRUB boot menu.

Step 3: Now you will be in Ubuntu running with Xen hypervisor. Now lets proceed. Now use this command and you will see your system running.

sudo xm list

Step 4: Now lets create a domU. First we need to configure a file“/etc/xen-tools/xen-tools.conf”. For this execute this command.
sudo gedit /etc/xen-tools/xen-tools.conf

Conclusion

So after such a long process, now we are over with the Xen dom0 and domU creation on ubuntu 12.10. Now you can run the 2 OS concurrently and enjoy.

Comments

comments powered by Disqus