Laptop Depicting some code

Xen HyperVisor on Debian with Ubuntu HVM

Installing the Xen Hypervisor on Debian Stretch

It’s not that complex

I have been trying to find installation instructions and commands for the Xen HyperVisor for Debian. Even after some long search I never found anything which made sense. After spending a couple of days, going through documentations, I finally managed to install it. I am sharing the steps which I used to create a domain and run an Ubuntu HVM on the same.


You can modify the part of the scripts mentioned below as per your requirement and use the same to install Xen on your system.

#Automation of installation of Xen Hypervisor

#Install non-free firmware
apt-get -y install firmware-linux-nonfree

#Install Large Volume Management
apt-get -y install lvm2

#Create the allocated LVM as a Physical Volume. Change sda4 to whichever
#device you had created as LVM for installation
pvcreate /dev/sda4

#Create a Volume Group (extents) using physical Volume
#Replace sda4 with device mentioned in pvcreate
vgcreate vg0 /dev/sda4

#Install bridge utils for network bridging
apt-get -y install bridge-utils

#Configure bridging interface
echo "" >> /etc/network/interfaces
echo "#The bridge network interface" >> /etc/network/interfaces
echo "auto xenbr0" >> /etc/network/interfaces && echo "iface xenbr0 inet dhcp" >> /etc/network/interfaces
# Change the iface name enp3s0 as applicable e.g. eth0
echo -e "\t bridge_ports enp3s0" >> /etc/network/interfaces

#Restart the network service
service networking restart

#Install Xen Server
apt-get -y install xen-hypervisor-4.8-amd64 xen-tools xen-utils-4.8

#Create a lv disk to be used with our vm
lvcreate -ndisk_0 -L20G vg0


The HVM file contains the entire information for setting up the VM. You may need to change the <ISO_FOLDER> to folder which contains your ISO in this case the Ubuntu Server X64 version.

# =====================================================================
# Example HVM guest configuration
# =====================================================================
# This is a fairly minimal example of what is required for an
# HVM guest. For a more complete guide see xl.cfg(5)

# This configures an HVM rather than PV guest
builder = "hvm"

# Guest name
name = "ubuntu_srv"

# 128-bit UUID for the domain as a hexadecimal number.
# Use "uuidgen" to generate one if required.
# The default behavior is to generate a new UUID each time the guest is started.

# Enable Microsoft Hyper-V compatibile paravirtualisation /
# enlightenment interfaces. Turning this on can improve Windows guest
# performance and is therefore recommended
#viridian = 1

# Initial memory allocation (MB)
memory = 2048

# Maximum memory (MB)
# If this is greater than `memory' then the slack will start ballooned
# (this assumes guest kernel support for ballooning)
#maxmem = 512

# Number of VCPUS
vcpus = 2

# Network devices
# A list of 'vifspec' entries as described in
# docs/misc/xl-network-configuration.markdown
vif = [ 'bridge=xenbr0' ]
# Disk Devices
# A list of `diskspec' entries as described in
# docs/misc/xl-disk-configuration.txt
disk = [ '/dev/vg0/disk_0,raw,hda,w','/<ISO_FOLDER>/ubuntu-17.10.1-server-amd64.iso,raw,hdc,cdrom' ]
# Guest VGA console configuration, either SDL or VNC
sdl = 0
vnc = 1
boot = "c"


  • Modify the shell script as per your requirement and run it. This will install Xen and all necessary tools. Restart the server.
  • Create a file ubuntu.hvm in your /etc/xen/ and copy the contents mentioned above. Modify information as per your system
  • Run the following command to create and start the VM
xl create /etc/xen/ubuntu.hvm

This will create a VM and start the VM with the the ISO image mentioned in the HVM file.

You will be able to see the installation screen by connect to the ip address of the debian machine on which Xen is currently installed on port 5900 using VNC viewer.

  • Walk through Ubuntu installation and you will have your Ubuntu VM ready at the end of it.
  • Run the command
xl list

and you should see a list of VM’s installed on the system e.g.

Name                                        ID   Mem VCPUs	State	Time(s)
Domain-0                                     0  3957     4     r-----     211.5
ubuntu_srv                                   1  2040     2     -b----     336.2

The b in the state column suggests that the VM is in blocked state. This does not indicate that the VM is hung. In case you run a processing intensive task on the VM you will see the state changed to r.

Things to Remember

In this section I am covering the key aspects which you should remember while creating the VM’s else you end up in the issues mentioned below.

Dreaded GRUB Install failure

I learnt this the hard way. Twice, after the entire installation process I was unable to install the GRUB boot manager in the MBR. After searching a lot of sites and going through equally large number of articles, I figured out that he size of the first partition has to be small, since a larger partition results in the size of core.img becoming greater than that the MBR can accommodate. This is a classic problem with LVM. So ensure when you partition the disk for installing ubuntu, create a /boot partition with roughly 200MB-300MB space and you will not encounter this issue.

Enabling auto configuration of eth0

On first boot of the guest VM you will have to edit the
/etc/network/interfaces file and update the information regarding the eth0 interface. Add following lines without the comment marks
# auto eth0
# iface eth0 inet dhcp
This will ensure that your guest vm is able to connect to the network get an IP and hosts will be able to connect to this guest



The above mentioned files and ubuntu.hvm can also be obtained from the following github location

This was a small attempt at demystifying the Xen server installation. I hope you all will find it useful to run your own VM’s. Hope the information helps and look forward to your comments and suggestions.