Virtualization Ready: Xen User Guide

Virtual machine installation prerequisites

Storage Method

Each virtual machine must have its own method of storing information.

In this article we use the image method where the information is placed into a single file which is in fact an image of the virtual machine. Please refer to the appropriate architectures section to know how to create an image in each of them.

Installation Tools

It is necessary that you have the installation medium for the operating system you plan to install on your virtual machines. An image of the CD-ROM (.iso) or a mirror will suffice.

Here's a short list of sites available to get .iso for Linux :

For more information about the Windows operating system visit: :

* To install the Windows virtual machine you must also have in hand a valid license and key.


We must first create a storage image that we will use for the virtual machine. Then we will choose an installation medium, such as an image or a mirror. 

Storage Image

1. Change to the Xen image directory:

cd /var/lib/xen/images/

2. Create a new image:

dd if=/dev/zero of=/var/lib/xen/images/<vm name>.img oflag=direct bs=1M count=<capacity> 

Note: You must replace“‘<vm name>” with the name you want on your virtual machine. Then you must replace “<capacity>” with the desired size for this image (ex. 20GB). 

Now that you have your storage for you virtual machine you can move on to the next page to create the virtual machine. 


Virt-install is a Xen utility that allows you to create a virtual machine and automatically generate the configuration file.

So, now that you have an image (for the storage) and an installation medium, you simply use the virt-install command to create a virtual machine and start the installation process. Here is the detailed information about the command :

virt-install -n <nom_vm> -r <ram> -f <file> -b xenbr0 --vnc -v [-c <media_install> | -l location ]


-n : Name you want for the virtual machine
-r : Number of RAM you want to allocate to the virtual machine
-f : To specify the path of your storage (eq. -f /var/lib/xen/images/myvm.img)
-b : The Xen bridge that the virtual machine will be assigned (default is xenbr0)
--vnc : Attach a VNC console so that we may connect to it in order to complete the installation -v : Configure the virtual machine in full virtual mode
-c : To specify a CD-ROM image installation (ex. -c /var/lib/xen/images/iso/debian.img)
-l : To specify a mirror installation (ex. -l 

Example of the virt-install command :

    1. Using a debian.iso image as an installation tool

virt-install -n vm1 -r 128 --f /var/lib/xen/images/vm1.img -b xenbr0 --vnc -v -c /var/lib/xen/images/ debian.iso 

    2. Using a debian mirror as an installation tool

virt-install -n vm2 -r 512 -f /var/lib/xen/images/vm2.img -b xenbr0 --vnc -v -l

Installing the Operating System

Once the virt-install is completed, Xen will automatically create a configuration file in /etc/xen/ and will also connect a VNC console to allow you to install the operating system on the virtual machine. 

The first step is to find the VNC port for the virtual machine you just created. By default, the port should start with 59 and end with the virtual machine id. So to find the VNC port we just need to find your new VM id with the following command :

xm list

This command should give a result similar to this :

Name ID Mem VCPUs State Time(s)
Domain-0 0 3598 2 r----- 1857.0
MyVM 2 263 1 r----- 95.0

Note that in this instance the new VM called “MyVM” has been assigned the id number 2 so we can deduce that the VNC port for this virtual machine will be 5902. 

Once we have the port, we can use a VNC client to connect to our VM. Here are URLs for VNC clients if you don't have one already: 

You must then create a new connection in the VNC client and connect to the server primary address on the virtual machine VNC port (ex., Port 5902). 

Once on the VNC console, simply complete the installation by following the steps to install the operating system. See next page for the network configuration. 

Network configuration

While installing the operating system you will need to enter the correct IP address to get an external connection. Each virtual machine should use a secondary IP address except for the first secondary ip (which serves as gateway to the virtual machine). 

Important note: If you are behind a firewall in NAT mode, you have private IP addresses assigned to your server - usually a /24 IP range. Your virtual machine will have to use them.  it means if your Xen is configured in Bridge mode, you can use the same gateway for the host and the VM. The gateway is the internal IP of the firewall.

For example, If the firewall has the private IP range, the gateway will be

Here is an example of a server with two virtual machines and their network configuration:

Note: IP addresses mentioned in this example are not real but the DNS server addresses are the iWeb DNS servers (which you can use). 

Primary Ip :
Secondary Ip :
DNS : ,

Secondary IP :
Netmask :
Gateway :
DNS : ,

Secondary IP :
Net mask :
Gateway :
DNS : ,

On the server (the host) we have the primary IP address and the first IP address of your secondary IP address range (which will be used as gateway for the VM). Then each virtual machine uses a secondary IP address. 

First you must make sure that the first secondary IP address is actually configured on the server (the host). Otherwise you can use the following command to add it: 

ifconfig eth0:0 <first secondary ip > up    

In addition, you must ensure that the "ip forwarding" is enables on the host by using the following command: 

echo 1 > /proc/sys/net/ipv4/ip_forward


Article is closed for comments.
Powered by Zendesk