Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to install Xen (XCP-XAPI) on Ubuntu 12.04 LTS Server in a cross platform approach (Windows and Linux users)? I need a complete and comprehensive guide on the subject covering all steps necessary to have an environment (hypervisor) complete, functional, affordable and easy to maintain for Linux, Windows and "Winux" users!

share|improve this question

This document has helped me a lot. I will give you some spoilers though:

  • LVM backed SR storage will not work with the xcp-xapi ubuntu packages. (you'll need install a few driver files to hack some files to enable it, the xcp-xapi source packages have those), alternatively, you use a ppa archive (there are some that work)
  • grub2 on domU machines will give you boot problems, (if you backup to file and restore, 12:04 LTS domU will not boot). Older like Maverick will. It's a grub2 update. write down your UUID's (root disk !) from inside your domU machines as you need it to fix that.
  • you can install any client you want after that, being HVM/PV ....

Now how that maps to your business in terms of affordability and so on, is an exercise left up to you.


I would not mod the files myself anymore, It was a painstaking process, prone to error. Using the custom PPA's seem to work flawlessy (I have 1 out of 6 xcp-xapi installs that way now, working great). I use these now:

deb precise main
deb-src precise main

Even though my own blog about xcp-install doesn't mention this (yet), I changed my mind since then and it's for the better.

share|improve this answer
Thank you so much! I will examine this document! – Eduardo Lucio Jan 24 '14 at 17:04
up vote 0 down vote accepted

Setting up XCP - Xen Cloud Platform (XEN Hypervisor) on Ubuntu Server 12.04 LTS/Debian 6/Debian-Based Distributions

  • Contents

    • About This Guide

    • Introduction

    • During Installation of Ubuntu

    • After Installation of Ubuntu

    • Installing Xen (XCP - Xen Cloud Platform)

    • Download and install XenCenter (Windows)

    • Download and install OpenXenManager (Alternative to XenCenter) (Ubuntu 12.04 Server LTS)

    • Why should I dedicate fixed amount of memory for Xen "dom0"?

    • Sources

  • About This Guide

    This guide is intended for users who want to use XEN in a simple and uncomplicated way exploring all Ubuntu Server 12.04 LTS facilities and for users who work in hybrids environments and with "hybrids users" (Windows/Linux).

    This guide is comprehensive and include installation and configuration of Ubuntu Server 12.04 LTS too. Here we present the installation of Open SSH for remote access, among other things.

    We also had the concern to provide brief guidance (embedded on this guide) on how you can test this procedure (using VMware Workstation). Being a friendly Hypervisor, we suggest VMware Workstation as the test environment for those interested in studying and using XEN. That is, we are talking about installing XEN Hypervisor (XAPI) on VMWare Workstation so that the user can know the technology in a simple, controlled, fast and safe way on his desktop.

    We explain the installation of the OpenXenManager (administration environment) and present another toolstack alternatives.

  • I could use XenServer, right?

    The XenCenter is a great and practical option, but in the end you will come across some problems:

    • Renew License "free" every 12 months;

    • You will not be using a system totaly free;

    • You will be contributing more to society by using totally free software;

  • Hardware Limitations

    Xen is not designed to run using desktop hardware (this including processors!). To find out if your processors is supported see the following pages: (XenServer, same Xen free base code)

    Note: Xen supports Intel i7 and i5;

  • Introduction

    Xen is a type 1, bare-metal virtual machine monitor (or hypervisor), which provides the ability to run one or more operating system instances on the same physical machine. Xen, like other types of virtualization, is useful for many use cases such as server consolidation and isolation of production and development environments (Eg.: corporate and personal environments on the same system).

    Our example uses LVM for virtual disks and network bridging for virtual network cards. It also assumes Xen 4.1 (the version available in 12.04). It assumes a familiarity with general virtualization issues, as well as with the specific Xen terminology. Please see the Xen wiki (see for more information.

  • During Installation of Ubuntu

    Note: For VMware Workstation test users -> On VM settings enable "Virtualize Intel VT-x/EPT or AMD-V/RVI"

    During the install of Ubuntu for the partitioning method choose "Guided - use the entire disk and setup LVM". Then, when prompted to enter "Amount of volume group to use for guided partitioning" enter a value large enough for the Xen dom0 system, leaving the rest for virtual disks. Enter a value smaller than the size of your installation drive. For example 100 GB should be large enough for a minimal Xen dom0 system. Keep in mind that in our model stay inside that guest (dom0) all installation media for guest OSs and other useful files, so that guest must have enough space on it.

  • After Installation of Ubuntu

    • Install Open SSH

    As you may already know, SSH is a secure communication protocol that lets you remotely access networked computers. It is known as a replacement for Telnet which is very unsecure. While Telnet sends traffic in plain text, SSH on the other hand uses a secure protocol to communicate.

    Run the commands below to install SSH Server.

    To log in on remote machine type on your terminal

    ssh <remote_user>@<ip_or_name>
  • Installing Xen (XCP - Xen Cloud Platform)

    XCP - Xen Cloud Platform is the open source version similar to Citrix XenServer that uses the Xen Hypervisor. XCP uses XAPI or XenAPI to manage Xen hosts. XCP is based on CentOS 5.5.

    Project Kronos is an initiative to port the XAPI tool stack to Debian and Ubuntu. It is a management stack implemented in OCaml that configures and controls Xen hosts, attached storage, networking and virtual machine life cycle. It exposes a command line interface (xe) for resource management.

    XenCenter is Windows desktop application by Citrix that is distributed with XenServer for managing servers running XenServer (the equivalent of linux is OpenXenManager). It uses XAPI for talking to Xen resource pools. Since we are setting up XAPI, we can use XenCenter to manage the server (there are some bugs in this relation).

    Ubuntu Server 12.04 is a LTS release that is supported for 5 years

    • Installing and configuring Xen Hypervisor

    Install the Xen Hypervisor

    sudo apt-get install xen-hypervisor

    Setup GRUB to boot the Xen Hypervisor

    sudo sed -i 's/GRUB_DEFAULT=.*\+/GRUB_DEFAULT="Xen 4.1-amd64"/' /etc/default/grub

    Disable apparmor at boot

    sudo sed -i 's/GRUB_CMDLINE_LINUX=.*\+/GRUB_CMDLINE_LINUX="apparmor=0"/' /etc/default/grub

    Restrict "dom0" to 1GB of memory and 1 VCPU (example) (see "Why should I dedicate fixed amount of memory for Xen "dom0"?")

    sudo gedit /etc/default/grub

    After GRUB_CMDLINE_LINUX="apparmor=0" add the line GRUB_CMDLINE_XEN="dom0_mem=1G,max:1G dom0_max_vcpus=1"

    Update Grub with the config changes we just made

    sudo update-grub

    Reboot the server so that Xen boots on the server

    sudo reboot

    Once the server is back online ensure that Xen is running

    cat /proc/xen/capabilities should display "control_d"

    Note: To stop or start xcp-xapi

    sudo /etc/init.d/xcp-xapi stop (or start)
    • Installing and configuring XAPI (XenAPI)

    • Install XCP-XAPI

      sudo apt-get install xcp-xapi

    Note: Choose "bridge" when prompted for network backend

    • Setup the default toolstack

      sudo gedit /etc/default/xen

    Note: Set "TOOLSTACK=xapi"

    • Disable xend from starting at boot

      sudo sed -i -e 's/xend_start$/#xend_start/' -e 's/xend_stop$/#xend_stop/' /etc/init.d/xend

    Note: Only xend the deamon needs to be disabled from starting, "/etc/init.d/xend" handles other things like modules and xenfs. Do not disable it from the runlevel.

    • Disable service xendomains

      sudo update-rc.d xendomains disable

    • Fix for "qemu" which emulates the console does not have the keymaps in the correct location

      sudo mkdir /usr/share/qemu; sudo ln -s /usr/share/qemu-linaro/keymaps /usr/share/qemu/keymaps

    • Network configuration

    This section describes how to set up Linux bridging in Xen. It assumes eth0 is both your primary interface to dom0 and the interface you want your VMs to use. It also assumes that you will use manually IP configuration.

    sudo apt-get install bridge-utils

    Note: If not already installed

    • Setup bridge networking

      sudo gedit /etc/network/interfaces

    Create a bond called xenbr0. The file should look like this for a static network configuration:

    # This file describes the network interfaces available on your system
    # and how to activate them. For more information, see interfaces(5). 
    # The loopback network interface
    auto lo
    iface lo inet loopback
    # Xen network interface for "dom0"
    auto xenbr0
    iface xenbr0 inet static
    # IP address
    # Subnet mask
    # Default Gateway
    # DNS Server
    bridge_ports eth0
    iface eth0 inet manual
    # The primary network interface
    # auto eth0
    # iface eth0 inet dhcp

    Configure xcp to use "bridge" networking instead of "openswitch"

    sudo gedit /etc/xcp/network.conf

    Note: Replace “openswitch” with “bridge”

    Note: For VMware Workstation (Linux) test users:

    Configure with "bridge" for network adapter and run these comands on host:
            sudo chmod ugo+rwx /dev/vmnet0
            sudo chown <username> /dev/vmnet0
            sudo chown :<usergroup> /dev/vmnet0
            sudo chmod ugo+rwx /dev/vmnet0
            sudo chown eduardo /dev/vmnet0
            sudo chown :eduardo /dev/vmnet0

    To test whether the network is working run the command

    sudo /etc/init.d/networking restart

    All set! Ready to reboot and let xcp-xapi toolstack take over

    sudo reboot

    On restart confirm that xcp is working

    sudo xe vm-list

    Example of an expected output:

    uuid (RO) : dbcf74d2-ee50-edd5-d44d-b81fc8ba1777
    name-label (RW): Control domain on host: ubuntu-xenserver-1
    power-state (RO): running

    Note: If your output looks similar, "xapi" is running on the server, if you get “Connection refused” then xapi is not setup correctly!

    • Configure Storage Repository for Use With XAPI

    NFS servers are a common form of shared filesystem infrastructure, and can be used as a storage repository substrate for virtual disks. As NFS storage repositories are shared, the virtual disks stored in them allow VMs to be started on any server in a resource pool and to be migrated between them using XenMotion. When you configure an NFS storage repository, you simply provide the hostname or IP address of the NFS server and the path to a directory that will be used to contain the storage repository (if this resource is on another machine, it is not our case).

    To show your volume group (VG)

    sudo pvs

    Create a LV with X GBs

    sudo lvcreate -L <X>GB -n <StorageRepositoryName> /dev/<VG>
    Eg1.: sudo lvcreate -L 25GB -n StorageRepository /dev/ubuntus1204
    Eg2.: sudo lvcreate -l 100%FREE -n StorageRepository /dev/ubuntus1204 

    Register the logical volume for use with XAPI

    sudo xe sr-create type=ext shared=true name-label=<StorageRepositoryName> device-config:device=/dev/<VG>/<StorageRepositoryName>
    Eg.: sudo xe sr-create type=ext shared=true name-label=StorageRepository device-config:device=/dev/ubuntus1204/StorageRepository

    This should display the Storage Repository

    sudo xe sr-list name-label=<StorageRepositoryName>
    Eg.: sudo xe sr-list name-label=StorageRepository
    uuid ( RO): 37bc5263-c9fc-8876-d24c-d5927f1bbed2
    name-label ( RW): StorageRepository
    name-description ( RW):
    host ( RO): ubuntus1204
    type ( RO): ext
    content-type ( RO):
    • Configure a ISO Repository for Use With XAPI

    An ISO Repository contains ISOs (disk images) with operational systems to perform the installations.

    Then the following example makes a storage repository called ISOs

    sudo xe sr-create name-label=<LocalISORepositoryName> type=iso shared=true device-config:location=<FolderPath> device-config:legacy_mode=true content-type=iso        
    sudo mkdir -p /var/opt/xen/LocalISORepository/
    sudo xe sr-create name-label=LocalISORepository type=iso shared=true device-config:location=/var/opt/xen/LocalISORepository/ device-config:legacy_mode=true content-type=iso

    This should display the ISO Repository

    sudo xe sr-list name-label=<LocalISORepositoryName>
    Eg.: sudo xe sr-list name-label=LocalISORepository
    uuid ( RO): 26edb27b-72fc-af56-ad2f-4d15a8d8e3f7
    name-label ( RW): LocalISORepository
    name-description ( RW):
    host ( RO): ubuntus1204
    type ( RO): iso
    content-type ( RO): iso

    Note: In this tutorial (link below) I teach you how to make a samba share easily, so you can access your files, ISOs, etc on "domu".,%20Simple%20and%20Brief%20Way!

share|improve this answer
Oliver, this article was made by me. It is of my authorship. Note also that it has been improved over the previous not being a mere copy. The previous was also made ​​by me! I wish the best to you! =D Thanks! – Eduardo Lucio Jan 26 '14 at 23:32
I see. In that case, thanks for sharing ;) – Oliver Salzburg Jan 27 '14 at 8:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .