The Perfect Xen 3.1.0 Setup For Debian Etch (i386) - Page 6

5.4 Creating Virtual Machines (domU)

(In this chapter I'm assuming that you've compiled a domU kernel to use with the virtual machines (/boot/vmlinuz-2.6.18-xenU). If you haven't, please replace all references to /boot/vmlinuz-2.6.18-xenU with /boot/vmlinuz-2.6.18-xen!)

We will use xen-tools to create virtual machines. xen-tools make it very easy to create virtual machines - please read this tutorial to learn more: xen-tools are available as a Debian Etch package, so we install that one right now:

apt-get install xen-tools

Next we edit /etc/xen-tools/xen-tools.conf. This file contains the default values that are used by the xen-create-image script unless you specify other values on the command line. I changed the following values and left the rest untouched:

vi /etc/xen-tools/xen-tools.conf

gateway   =
netmask   =

passwd = 1

kernel = /boot/vmlinuz-2.6.18-xenU
#initrd = /boot/initrd.img-2.6.16-2-xen-686

mirror =

Please make sure that you comment out the initrd line! At least on my installations I've never needed a ramdisk for virtual machines.

The passwd = 1 line makes that you can specify a root password when you create a new guest domain. In the kernel line you must specify the domU kernel that you want to use for your guest domains. In the mirror line specify a Debian mirror close to you.

Make sure you specify a gateway and netmask. If you don't, and you don't specify a gateway and netmask on the command line when using xen-create-image, your guest domains won't have networking even if you specified an IP address!

Now let's create our first guest domain,, with the IP address

xen-create-image --size=2Gb --swap=256Mb --ide \
--ip= --netmask= --gateway= --force \
--dir=/vserver --memory=32Mb --arch=i386 --kernel=/boot/vmlinuz-2.6.18-xenU \
--debootstrap --dist=etch --mirror= --passwd

A lot of switches are unnecessary here because we specified the same details in /etc/xen-tools/xen-tools.conf but it shows that you can specify the desired settings either on the command line or in /etc/xen-tools/xen-tools.conf. Please make sure that you specify --ide, otherwise your virtual machine might not boot!

(To learn more about the available options, take a look at the xen-create-image man page:

man xen-create-image


The xen-create-image command will now create the virtual machine for us. This can take a few minutes. The output should be similar to this one:

server1:/usr/src/xen-3.1.0-src# xen-create-image --size=2Gb --swap=256Mb --ide \
>   --ip= --netmask=  --gateway= --force \
>   --dir=/vserver --memory=32Mb --arch=i386 --kernel=/boot/vmlinuz-2.6.18-xenU \
>   --debootstrap --dist=etch --mirror= --passwd

General Infomation
Hostname       :
Distribution   :  etch
Fileystem Type :  ext3

Size Information
Image size     :  2Gb
Swap size      :  256Mb
Image type     :  sparse
Memory size    :  32Mb
Kernel path    :  /boot/vmlinuz-2.6.18-xenU

Networking Information
IP Address 1   :
Netmask        :
Gateway        :

Loopback module not loaded and you're using loopback images
Run the following to load the module:

modprobe loop loop_max=255

Creating swap image: /vserver/domains/

Creating disk image: /vserver/domains/

Creating ext3 filesystem on /vserver/domains/

Installing your system with debootstrap mirror

Running hooks

No role script specified.  Skipping

Creating Xen configuration file
Setting up root password
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
All done

Logfile produced at:

(You can ignore this warning:

Loopback module not loaded and you're using loopback images
Run the following to load the module:

modprobe loop loop_max=255

The virtual machine will work nevertheless.)

There should now be a configuration file - /etc/xen/ Take a look at it to become familiar with virtual machines configuration files:

cat /etc/xen/

#  Configuration file for the Xen instance, created on
# Tue May 29 01:21:54 2007.

#  Kernel + memory size
kernel  = '/boot/vmlinuz-2.6.18-xenU'

memory  = '32'

#  Disk device(s).
root    = '/dev/hda1 ro'

disk    = [ 'file:/vserver/domains/,hda1,w', 'file:/vserver/domains/,hda2,w' ]

#  Hostname
name    = ''

#  Networking
vif  = [ 'ip=' ]

#  Behaviour
on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'

To start the virtual machine, run

xm create /etc/xen/


xm console

to log in on that virtual machine (type CTRL+] if you are at the console, or CTRL+5 if you're using PuTTY to go back to dom0), or use an SSH client to connect to it (

To get a list of running virtual machines, type

xm list

The output should look like this:

server1:~# xm list
Name                                      ID   Mem VCPUs      State   Time(s)
Domain-0                                   0   301     1     r-----   1191.0                           1    32     1     -b----     50.6

To shut down, do this:

xm shutdown

If you want to start automatically at the next boot of the system, then do this:

ln -s /etc/xen/ /etc/xen/auto

Here are the most important Xen commands:

xm create -c /path/to/config - Start a virtual machine.
xm shutdown <name> - Stop a virtual machine.
xm destroy <name> - Stop a virtual machine immediately without shutting it down. It's as if you switch off the power button.
xm list - List all running systems.
xm console <name> - Log in on a virtual machine.
xm help - List of all commands.

Let's create a second vm, with the IP address

xen-create-image --size=2Gb --swap=256Mb --ide \
--ip= --netmask= --gateway= --force \
--dir=/vserver --memory=32Mb --arch=i386 --kernel=/boot/vmlinuz-2.6.18-xenU \
--debootstrap --dist=etch --mirror= --passwd

Afterwards, you can start like this:

xm create /etc/xen/

and shut it down like this:

xm shutdown

A list of all virtual machines that were created with the xen-create-image command is available under


server1:~# xen-list-images
Memory: 32

Memory: 32

To learn more about what you can do with xen-tools, take a look at this tutorial:

You can check which kernel you are using by running

uname -a

You can do this on both dom0 and domU. For example, on my virtual machine for which I have compiled a special domU kernel, the output looks like this:

xen1:~# uname -a
Linux 2.6.18-xenU #2 SMP Tue May 29 00:53:13 CEST 2007 i686 GNU/Linux

Share this page:

7 Comment(s)

Add comment


From: at: 2007-11-19 07:26:51

I installed xen from binary package in Debian Lenny (amd64) according your notes and everything is fine.

The only problem was initrd, where my Raid partitions were not recognized on the boot and therefore the boot failed. The solution was using:

mkinitramfs -o /boot/initrd.img-2.6.18-xen 2.6.18-xen

instead of

mkinitrd.yaird -o /boot/initrd.img-2.6.18-xen 2.6.18-xen

From: at: 2007-09-07 19:32:07

Dear Author

please add the bcc package to your requirements. The hvmloader won´t be compiled without it. It took me an hour or so to discover the missing package.

Best Regards an thx for the Howto



From: at: 2007-10-26 22:33:58

 You say:

> Please make sure that you comment out the initrd line!

When I did this my LVM-based VM's wouldn't boot.

From: at: 2007-11-14 22:14:38


 I think there isa newer version of xen utils neccessary, because the XEN-3.1.0 Binary version seems to be to new ...

It also asked a lots of questions about replacing scripts when I installed xen utils via aptitude - and after rebooting it a secound time my xen bridge settings got lost and I wheren't able to start any virtual machine again.

There might be an update of the Howto neccessary ...



J. K. S.

From: at: 2007-06-21 10:00:34

some hints for compiling Xen 3.1:

if you wan't the VNC/SDL feature with HVM you need the following packages:

 libjpeg62-dev, libvncserver-dev,  libsdl1.2-dev

and you need to set the following var:

export XENFB_TOOLS=y

and maybe you miss hvmloader: you need the package bcc or it will just not compile.

To check build dependecies there is a nice script:

cd tools/check

./chk build

- Thomas 

PS: see also: 

From: at: 2007-07-17 16:31:24

If your root partition is on LVM you need to create an initrd for xen0 kernel as well, run: mkinitramfs -o /boot/initrd.img-2.6.18-xen0 2.6.18-xen0 before update-grub

From: at: 2007-11-01 05:16:08

It seems that the default bnx2 drivers in the Debian Etch kernel are malfunctioning with the network-bridge script in Xen 3.1.

For anyone having issues with the network-bridge and you are using broadcom nics (Dell PowerEdge, etc.) you should install the drivers found here:

Also check out this thread for some talk on the problem: