How to Install the Xen Hypervisor on Ubuntu

Here is the basic architecture:

Xen – this is the software that boots up when you boot the server.

domain-0 – this controls Xen and all the virtual machines added to the machine.

domain-u – these are the virtual machines.

paravirtual drivers – performance with Windows will be really slow unless you instill the opensource network,
storage, bus, and other paravirtual drivers.

[See Also: 6 Easy Ways to Start Working on OpenStack for Custom Development]

Installation

You will need the ISO image of the operating system you want to use.

  • Install Ubuntu on an empty machine and use the LVM (logical volume manager) option when you do that. Leave space for a logical volume for VMs when you are asked to create partitions. Or use another drive for that when you set up the VMs later.
  • Install XEN:
    sudo apt-get install xen-hypervisor-amd64
    sudo reboot
  • Now you have a Xen hypervisor.  Run this to confirm:
    sudo xl list
    You will see domain-0:
    Name                     ID   Mem VCPUs      State    Time(s)
    Domain-0                 0 10789     1     r—–    2643.0
  • Configure bridged networking.  Do not use OpenvSwitch (You can but these instructions will not work for that.):cat /etc/network/interfaces auto lo eth0iface lo inet loopbackiface eth0 inet manualauto xenbr
  • iface xenbr inet dhcp
  • bridge_ports eth0
  • Assign memory to the domain-0 machine so that it does not run slow when you add VMs by adding this line:
  • GRUB_CMDLINE_XEN_DEFAULT=”dom0_mem=10794M,max:10794M”
  • to:
  • sudo vi /etc/default/grub.d/xen.cfg
  • sudo update-grub
  • sudo reboot
  • That gives domain-0 10GB.

[See Also: Building and Configuring Open vSwitch on OpenWrt for Cloud Networking]

  • Create a logical volume and partition it with Gparted using fat32 or whichever format you are comfortable with.  Click on the vm option under Manage Flags when you create the partition.  Create the volume group (Google for instructions) on the partition, then create the logical volume by using:sudo lvcreate -n (logical volume -L (size)g (logical volume group)
  • sudo xl create (config file) “Create” does not mean create, it means start.  You need to “create” each time you boot the host machine.  If you want to avoid that read about the “xl save” command.
  • Now connect to the virtual machine console on port 5900.  The second one will be on port 5901, and so forth.  Use vncviewer and enter host “localhost:5900” to connect to the console.  Here you will have to install Debian, Ubuntu, Windows, or any other ISO you use by going through the screens to do that.  You need to use a separate logical volume for each VM so that one does not overview the other (That seems to be a bug with Xen version 4.4).
  • Now if it is a Windows machine install paravirtual drivers. Download them from here. For Linux they are already built into the Kernel.
  • Now give the domain-0 the majority of CPU time as the virtual machines by using something like:sudo xl sched-credit -d 0 -w 65000 Where 65000 is a multiple of the default 256.  65,000 is the maximum allowed value. To verify that it worked run:sudo xl sched-credit You will need to do that each time you boot Xen.
  • Here is a config file example to get you started:
  • Config file
  • Save this file anywhere with any name.
  • builder=’hvm’ (whether you want hardware based, i.e., Intel or AMD, or paravirtual)
  • memory = 2048 (memory to assign to machine)
  • cpu=(number of physical CPUs on machine, not cores)
  • vcpus=(number of CPUs to assign to this VM)
  • name = (some name)
  • vif = [‘mac=<some valid mac address, google for how to make one uṕ>,bridge=xenbr’]
  • disk = [‘phy:(logical volume),hda,w’,’file:(location of ISO),hdc:cdrom,r’]
  • boot=”dc” (hardrive and then CD rom)
  • serial=’pty’
  • vnc=1
  • vnclisten=”0.0.0.0″
  • usbdevice=’tablet’ (to make mouse sync up with host mouse)

Everything you need to know about outsourcing technology developmentAccess a special Introduction Package with everything you want to know about outsourcing your technology development. How should you evaluate a partner? What components of your solution that are suitable to be handed off to a partner?

Conclusion

About The Author

Speak to our Experts
Lets Talk

Our Latest Blogs

With Zymr you can