How to install Xen 4 on Debian 6 Squeeze x64.


This tutorial is for an HVM x64 VM on a XEN x64 HOST with LVM partition (IMO - is one of the fastest ways you can go for a XEN setup), so you’ll need a cpu with VT enabled. First off, you need to know what HVM, LVM mean, so go here. If you don’t know what XEN is you can go here; even though it’s for another tutorial, the same principle applies.

So if you know what XEN LVM HVM means, than you are good to go. I will show you how to install XEN 4 on Debian 6 Squeeze x64, with LVM. Xen on Debian 6 squeeze went smooth, in contrast to other setups. I have also, included “how to install Debian Squeeze with LVM” for beginner’s as well.

It’s best to start with a wiped HD when dealing with LVM. If it’s not a new HDD, I recommend using Darik’s Boot And Nuke, to wipe all data, before you get started.

Download the latest version of Squeeze, which at this time is 6.0 (kind of ironic, ay). You can download either the netinstall or full cd; only CD 1 is needed, so don’t go download a bunch of CDs you’ll never use.

Insert the Debian Squeeze x64 Installation Disk (debian-6.0.0-amd64-netinst.iso) to start the installation process.

How to install Debian Squeeze with LVM

Partition Disk - Select ‘Manual’ Partition
In my example, I use 73gb = 4gb for Debian Squeeze x64 OS, 2gb for swap, and the rest is for physical LVM. The swap here is for the XEN host, and will not be shared by the VMs.
So, on blank HDD, you’ll want to do the following:

Create Debian Squeeze OS Partition:

  • Select Disk you want to install OS to.
  • Select Yes, to create a new empty partition table on this device.
  • Select, pri/log 73 GB Free Space
  • Create a new partition (FYI: OS)
  • Enter 4GB, for partition size, select continue
  • Select Primary
  • Select Beginning
  • For partition settings, use the following settings (Label is Optional):
  • Use as: Ext4 journaling file system
    Mount point: /
    Mount options: defaults
    Label: none
    Reserved blocks: 5%
    Typical Usage: standard
    Bootable flag: on
  • Select, Done setting up the partition.

Create Swap Partition:

  • Select, pri/log 69 GB Free Space
  • Create a new partition (FYI: Swap)
  • Enter 2GB, for partition size, select continue (you’ll need to come up with a custom swap size for your server)
  • Select Logical
  • Select Beginning
  • For partition settings, use the following settings (Label is Optional):
  • Use as: swap area
    Bootable flag: off
  • Select, Done setting up the partition.

Create LVM:

  • Select, pri/log 67 GB Free Space
  • Create a new partition (FYI: LVM)
  • Enter default of 67gb, for partition size, select continue
  • Select Primary
  • For partition settings, use the following settings (Label is Optional):
  • Use as: physical volume for LVM
    Bootable flag: off
  • Select, Done setting up the partition.

So now your done with partitioning and Debian Squeeze will take care of the formatting.

Your screen should look like this: Note: I didn’t feel like creating a screenshot image, so I used an old image (same thing applies accept I used ext4 (YEA), instead of ext3.
Partitioning Debian 6 Squeeze for LVM - 1

  • Now select, Finish partitioning and write changes to disk.

Your screen should look like this: Note: I didn’t feel like creating a screenshot image, so I used an old image (same thing applies accept I used ext4 (YEA), instead of ext3.
Partitioning Debian 6 Squeeze for LVM - 2

  • Select, Yes. The base installation will start.

Set up Passwords

This is pretty self explanatory

Configure the package mngr

Select default, or your preference

Software Selection

Deselect all, i.e. Desktop Environment, Standard System Utilites, etc..

Installing Grub boot Loader

Select Yes (auto installs Grub2 by default)

Finish the installation

Select, Continue

It’s worth noting that Debian Squeeze has changed some common cli commands, and default installation pkgs (like the grub2). Debian Squeeze now installs grub2 by default, so the “used to be Lenny” grub.lst is now loacted in /boot/grub/grub.cfg; but not like you can edit this file and change the boot sequence anymore, as I’ll show you below how to boot your hypervisor. Another change is the command: prompt> /etc/init.d/networking restart, Running /etc/init.d/networking restart, is deprecated because it may not enable again some interfaces … (warning). So the new method is prompt> ifdown eth0 && ifup eth0. There are more changes, as I will explain as I go along with this tutorial.

Install essential pkgs

Our attempt here and throughout this tutorial is to create a slim installation of the Xen host.

Login as root.

prompt>apt-get update prompt>aptitude full-upgrade prompt>apt-get install openssh-server ssh wget

You can optionally remote log in as root, with SSH (i.e. ssh via putty); or optionally with mRemote for easability.

Configure static network IP

prompt>nano /etc/network/interfaces

Erase or comment out, all info and copy in the following (depending on your configuration):

  auto lo
  iface lo inet loopback
  auto eth0
  iface eth0 inet static
prompt>ifdown eth0 && ifup eth0

Once you restart networking, you will need to point your ssh client to the new IP,

We can now move onto installing and configuring Xen.

Install the latest stable version of Xen on Squeeze x64.

Install basic prerequsites.

prompt>apt-get install libvirt-bin virtinst bridge-utils

See what XEN Kernels are available for your Debian Squeeze x64.

prompt>apt-get update prompt>apt-cache search xen | grep image
linux-image-2.6.32-5-amd64 - Linux 2.6.32 for 64-bit PCs
linux-image-2.6.32-5-openvz-amd64 - Linux 2.6.32 for 64-bit PCs, OpenVZ support
linux-image-2.6.32-5-vserver-amd64 - Linux 2.6.32 for 64-bit PCs, Linux-VServer support
linux-image-2.6.32-5-xen-amd64-dbg - Debugging infos for Linux 2.6.32-5-xen-amd64
linux-image-2.6.32-5-xen-amd64 - Linux 2.6.32 for 64-bit PCs, Xen dom0 support
linux-image-2.6-amd64 - Linux 2.6 for 64-bit PCs (meta-package)
linux-image-2.6-openvz-amd64 - Linux 2.6 for 64-bit PCs (meta-package), OpenVZ support
linux-image-2.6-vserver-amd64 - Linux 2.6 for 64-bit PCs (meta-package), Linux-VServer support
linux-image-2.6-xen-amd64 - Linux 2.6 for 64-bit PCs (meta-package), Xen dom0 support
linux-image-amd64 - Linux for 64-bit PCs (meta-package)
linux-image-openvz-amd64 - Linux for 64-bit PCs (meta-package), OpenVZ support
linux-image-vserver-amd64 - Linux for 64-bit PCs (meta-package), Linux-VServer support
linux-image-xen-amd64 - Linux for 64-bit PCs (meta-package), Xen dom0 support
linux-image-2.6.30-2-amd64 - Linux 2.6.30 image on AMD64

Check out which kernel you have:

prompt>uname -r

So luck (or smart xen/debian squeeze contributors/maintainers/users) has it, that there is a XEN kernel which matches our kernel. We’ll install XEN with matching kernels; linux-image-2.6.32-5-xen-amd64.

prompt>apt-get install linux-image-2.6.32-5-xen-amd64 xen-tools

Configure XEN Loop

prompt>nano /etc/modules

Verify and add if not there:

loop max_loop=64

Edit XEN config file, reboot, and verify Xen Kernel running.

prompt>cp /etc/xen/xend-config.sxp /etc/xen/xend-config.sxp.bak

Always a good idea to back up original files. Ok, so know let’s change the file.

prompt>nano /etc/xen/xend-config.sxp

Change this:

#(xend-http-server no)

to this:

(xend-http-server yes)

Change this:

#(xend-unix-server no)

to this:

(xend-unix-server yes)

Change this:

#(network-script network-bridge)

to this:

(network-script 'network-bridge antispoof=yes')


(vif-script vif-bridge)

is uncommented

Change this:

#(vnc-listen '')

to this:

(vnc-listen '')

Change this:

(vncpasswd '')

to this:


Now you are probably woondering why we set VNC to, or even messed with VNC settings. Well to answer your thoughts, we need VNC, in order to install the HVM VM, remember this isn’t paravirtualization, where you use xen-tools to create VMS, here we’ll create VMs using VNC. We set the “listen to”, only for installtion and practical reasons. Once your VNC is setup, you’ll need to revisit the “listen to”, and configure it for security reasons.

Configure Squeeze Grub and Optional XEN Settings

Optional - Good idea to disable OS prober; prevents virtual machines on logical volumes from appearing in the boot menu, per

prompt>nano /etc/default/grub

Add the Following

#Disable OS prober.

Optional - Definitely optional, so loook into this before enabling, per


Add the Following


Required - Change grub2 loading order

prompt>ls /etc/grub.d/
00_header 05_debian_theme 10_linux 20_linux_xen 30_os-prober 40_custom 41_custom README

Unlike the former grub.lst, the new grub2 requires setting files in order, do we’ll move the 10_linux to the back, so 20_linux_xen, takes precedence. Per, Debian Squeeze and Sid use Grub 2, and the defaults are wrong for Xen. The Xen hypervisor (and not just a Xen-ready kernel!) should be the first entry, so do this: mv -i /etc/grub.d/10_linux /etc/grub.d/50_linux update-grub2

prompt>mv /etc/grub.d/10_linux /etc/grub.d/50_linux prompt>update-grub2
Generating grub.cfg …
Found linux image: /boot/vmlinuz-2.6.32-5-xen-amd64
Found initrd image: /boot/initrd.img-2.6.32-5-xen-amd64
Found linux image: /boot/vmlinuz-2.6.32-5-xen-amd64
Found initrd image: /boot/initrd.img-2.6.32-5-xen-amd64
Found linux image: /boot/vmlinuz-2.6.32-5-amd64
Found initrd image: /boot/initrd.img-2.6.32-5-amd64

Now check your shiny Xen 4.0 Kernal on x64, pretty cool ay?

prompt>uname -r

Run a quick test, you’ll notice Domain-O (domO).

prompt>xm list

If you had not change the order of the grub :) in the step prior, you would have recv’d this error:

prompt>xm list
WARNING! Can’t find hypervisor information in sysfs!
Error: Unable to connect to xend: No such file or directory. Is xend running?

Ok, so now that your XEN is “all cool and stuff”, we can move onto installing VNC.

One more thing before moving onto VNC. It’s weird but after the new Lenny to Squeeze change I get this error on reboot, with VT enabled or disabled in bios (maybe a bug or it could be a hug). Don’t know if you guys get it; let me know if you do and /or have any suggestions. Everything still runs fine, but would love to get rid of these error messages on reboot.

ERROR: Unable to locate IOAPIC for GSI 2
ERROR: Unable to locate IOAPIC for GSI 9
registering netback
"Your system does not have the CPU extension required to use KVM. Not doing anything.. failed"
XENBUS: Unable to read cpu state

Install VNC Server and Terminal Emulator

So, like I said before in order to install a XEN HVM VM, you’ll need VNC. We will simply need a basic VNC Server setup, which comes with Xvnc. To learn more about why VNC and Windows Manager go here.

  • Install VNC Server
prompt>apt-get install -y vncviewer vnc4server xinetd xterm
  • Setup Password with the following - Starts VNC Server and prompts you for a new password (SOMEVNCPASSWORD) up to 8 characters long.
  • To create new password, if you changed your mind

Configure VNC Server

Now, there are many ways to configure a VNC Server, so that we can interact with our Xen host and Xen host VMs. We’re going to enable a normal desktop (Xvnc) with terminal emulator, on the Xen host.

Edit VNC Server xstartup file.

prompt>nano /root/.vnc/xstartup

Change this:

#exec /etc/X11/xinit/xinitrc

To this:

exec sh /etc/X11/xinit/xinitrc

Pay attention, here the #exec /etc/X11/xinit/xinitrc, was uncommented and an ’sh’ was added. Your welcome.

This fixes the following problem in vncserver /root/.vnc/x01:5.log file:
/root/.vnc/xstartup: line 5: /etc/X11/xinit/xinitrc: Permission denied
/root/.vnc/xstartup: line 5: exec: /etc/X11/xinit/xinitrc: cannot execute: Success
per: vnc4server: Normal desktop permission prob with xinitrc

Change this:

x-window-manager &

To This:

#x-window-manager &

Obviously save it, and run:

prompt>chmod 755 /root/.vnc/xstartup

Create a Security Policy (if it doesn’t exist) file.

If you have been following this tutorial, this file currently doesn’t exist.

Up to you, which option you want.

Option 1:

prompt>mkdir /etc/X11/xserver prompt>nano /etc/X11/xserver/SecurityPolicy

and copy and save the following (line by line, as is (don’t get creative)) into the file:

# $Xorg: SecurityPolicy,v 1.3 2000/08/17 19:47:56 cpqbld Exp $
# The site policy fields are interpreted by the XC-QUERY-SECURITY-1
# authorization protocol.  The values are arbitrary and site-specific.
# Refer to the Security Extension Specification for the usage of the policies.
#sitepolicy A
#sitepolicy B
#sitepolicy C
# Property access rules:
# property <property> <window> <permissions>
# <window> ::= any | root | <propertyselector>
# <propertyselector> ::= <property> | <property>=<value>
# <permissions> :== [ <operation> | <action> | <space> ]*
# <operation> :== r | w | d
#       r       read
#       w       write
#       d       delete
# <action> :== a | i | e
#       a       allow
#       i       ignore
#       e       error
# Allow reading of application resources, but not writing.
property RESOURCE_MANAGER       root    ar iw
property SCREEN_RESOURCES       root    ar iw
# Ignore attempts to use cut buffers.  Giving errors causes apps to crash,
# and allowing access may give away too much information.
property CUT_BUFFER0    root    irw
property CUT_BUFFER1    root    irw
property CUT_BUFFER2    root    irw
property CUT_BUFFER3    root    irw
property CUT_BUFFER4    root    irw
property CUT_BUFFER5    root    irw
property CUT_BUFFER6    root    irw
property CUT_BUFFER7    root    irw
# If you are using Motif, you probably want these.
property _MOTIF_DEFAULT_BINDINGS        root    ar iw
property _MOTIF_DRAG_WINDOW     root    ar iw
property _MOTIF_DRAG_TARGETS    any     ar iw
property _MOTIF_DRAG_ATOMS      any     ar iw
property _MOTIF_DRAG_ATOM_PAIRS any     ar iw
# If you are running CDE you also need these
property _MOTIF_WM_INFO         root    arw
property TT_SESSION             root    irw
property WM_ICON_SIZE           root    irw
property "SDT Pixel Set"        any     irw
# The next two rules let xwininfo -tree work when untrusted.
property WM_NAME        any     ar
# Allow read of WM_CLASS, but only for windows with WM_NAME.
# This might be more restrictive than necessary, but demonstrates
# the <required property> facility, and is also an attempt to
# say "top level windows only."
property WM_CLASS       WM_NAME ar
# These next three let xlsclients work untrusted.  Think carefully
# before including these; giving away the client machine name and command
# may be exposing too much.
property WM_STATE       WM_NAME ar
property WM_CLIENT_MACHINE      WM_NAME ar
property WM_COMMAND     WM_NAME ar
# To let untrusted clients use the standard colormaps created by
# xstdcmap, include these lines.
property RGB_DEFAULT_MAP        root    ar
property RGB_BEST_MAP   root    ar
property RGB_RED_MAP    root    ar
property RGB_GREEN_MAP  root    ar
property RGB_BLUE_MAP   root    ar
property RGB_GRAY_MAP   root    ar
# To let untrusted clients use the color management database created
# by xcmsdb, include these lines.
property XDCCC_LINEAR_RGB_CORRECTION    root    ar
property XDCCC_LINEAR_RGB_MATRICES      root    ar
property XDCCC_GRAY_SCREENWHITEPOINT    root    ar
property XDCCC_GRAY_CORRECTION  root    ar
# To let untrusted clients use the overlay visuals that many vendors
# support, include this line.
property SERVER_OVERLAY_VISUALS root    ar

derived from from: /etc/X11/xserver/SecurityPolicy

Option 2:

prompt>apt-get install xserver-xorg

After this operation, 24.7MB of additional disk space will be used.

Autostart VNC server at Boot

Now make VNC Server auto start upon Xen host boot, by creating, editing, and configuring a new file, i.e. startvnc.

prompt>nano /etc/init.d/startvnc

Add the following:

#! /bin/sh
export USER="root"
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/bin/X11"
    su - $USER -c"vncserver :5"
    su - $USER -c"vncserver -clean -kill :1"
case "$1" in
        echo -n "Starting Xvnc: "
        echo -n "Stopping Xvnc "
        echo -n "Restarting Xvnc "
        echo "Usage: /etc/init.d/$NAME {start|stop|restart}"
        exit 1
exit 0

derived from VNC On Bootup

prompt>chmod 755 /etc/init.d/startvnc prompt>update-rc.d startvnc defaults
update-rc.d: using dependency based boot sequencing
insserv: warning: script ’startvnc’ missing LSB tags and overrides

Ok, I have not found a VNC start script that works without errors, if you find one, please comment. Regardless of the error, it does work.

If you decide to remove it, run:

prompt>update-rc.d -f startvnc remove

The reason I set the VNC default port to 5 on root localhost, is my preference and is part of this turorial I would leave it to 5. If you want, you can set to whatever you like.


View the ports, upon reboot.

Your looking for 5905.

prompt>netstat -tap


Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 *:x11-5                 *:*                     LISTEN      1180/Xvnc4
tcp        0      0 *:ssh                   *:*                     LISTEN      1151/sshd
tcp        0     52        ESTABLISHED 1251/1
tcp6       0      0 [::]:5905               [::]:*                  LISTEN      1180/Xvnc4
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN      1151/sshd

Test VNC

Install a VNC Client on Windows or Linux (i.e. RealVNC, TightVNC, etc..) on your other computer (i.e. laptop).

If your client is on a Windows Machine, launch VNC Client viewer (display), and type in: or

If your client is on your Xen host Server, than type in:
localhost:5 or x01:5 or

If your client is on a Linux Machine, than type:

Troubleshoot VNC

If you have been following this tutorial, the log file is located in:

Disregard the 8 lines of font missing, as we don’t use these fonts anyway’s.

prompt>cat /dev/null > /root/.vnc/x01:5.log prompt>reboot prompt>cat /root/.vnc/x01:5.log

Make sure VNC is working, before moving on to configuring LVM for Xen VM and installing Xen Guest VM, on Xen Host LV.

Configure LVM for Xen VM

IMPORTANT NOTE: Part of this section and mostly all of this article, was derived from my other article here. Doesn’t really matter as Debian is Debian, and not a variant like Ubuntu, so all should work the same. Not saying Ubuntu is lesser, as this is not the case.

Here is a breakdown (I’m keeping it simple here) of the LVM, installation process.


The VM image (OS and Swap) will be on one LV. The LV will be on the VG. LV will be treated as one Hard Drive available to the VM, therefore the VM, upon installation will create partitions inside LV, i.e. OS on primary partition and Swap - logical disk; depending on your preference.

Create Volume Group (VG) and a Logical Volume (LV) on your LVM, for your Xen VM.

Now, since we already created an LVM partition, prior to installing Debian Squeeze x64, all that’s left is to create a Volume Group, (VG), and Logical Volumes (LV).

prompt>fdisk -l


If you get Partition 1 does not end on cylinder boundary, etc…, error you can safely ignore. :).

After some googling, we concluded that having to align the partition boundaries with the cylinders was a DOS legacy issue, and was not something that would cause a problem for Linux…..

This was a bit disconcerting at first, but after a few minutes of thinking it dawned on me that modern systems use LBA (Logical Block Addressing) instead of CHS (Cylinder/Head/Sector) to address disk drives. If we view the partition table using sectors instead of cylinders:;…..

Disk /dev/sda: 73.0 GB, 72999763968 bytes
255 heads, 63 sectors/track, 8875 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000a7cb7
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1         487     3905536   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2             487         730     1951745    5  Extended
Partition 2 does not end on cylinder boundary.
/dev/sda3             730        8875    65428480   8e  Linux LVM
/dev/sda5             487         730     1951744   82  Linux swap / Solaris

I confirm, you can ignore (old legacy dos stuff). See below, they are actually not overlapping if you run this command.

prompt>sfdisk -uS -l /dev/sda


 Device Boot    Start       End   #sectors  Id  System
/dev/sda1   *      2048   7813119    7811072  83  Linux
/dev/sda2       7815166  11718655    3903490   5  Extended
/dev/sda3      11718656 142575615  130856960  8e  Linux LVM
/dev/sda4             0         -          0   0  Empty
/dev/sda5       7815168  11718655    3903488  82  Linux swap / Solaris

Ok, so now that we got that out of the way, let’s move on.

  • We’ll be creating one VG in sda3 LVM partition, and naming it vol.

    To initialize partition to support LVM

    prompt>pvcreate /dev/sda3

    Create a VG named vol.

    prompt>vgcreate vol /dev/sda3
  • We’ll be creating one LV in the newly created VG vol, and naming it vmx01cms01 (to match our VM host name).

    The size will be 15gb. Read NOTE: directly below to learn more…

    prompt>lvcreate -L 15gb -n vmx01cms01 vol prompt>mkfs -t ext4 /dev/vol/vmx01cms01
  • View the newly created LV:


      --- Logical volume ---
      LV Name                /dev/vol/vmx01cms01
      VG Name                vol
      LV UUID                tcswzC-yo6x-vFcn-RqgV-C2DU-RBBQ-SpoiZc
      LV Write Access        read/write
      LV Status              available
      # open                 0
      LV Size                15.00 GB
      Current LE             3840
      Segments               1
      Allocation             inherit
      Read ahead sectors     auto
      - currently set to     256
      Block device           254:0

Now your LV is ready for a VM installation. On to the next.

Once the OS is installed, the size 15gb, can be changed with Gparted LiveCD, like you would any computer

Install Xen Guest HVM VM, on Xen Host LV

Here we’ll install the (Fully Virtualized - HVM) Operating System VM on the newly created LV, with another Debian Squeeze x64 OS (you can use whatever os you like, i.e. Ubuntu, Suse, etc..). Before you get started you need qemu-dm, it used to be it was installed with XEN, but now in Squeeze, you have to install seperately.

prompt>apt-get install xen-qemu-dm

When you install xen-qemu-dm, it will also auto install etherboot mknbi, and install the latest stable version to match your XEN xernel; xen-qemu-dm-4.0



Download the OS image ISO.

We are using an ISO, instead of a cdrom to install the OS.

prompt>mkdir -p /dl/os && cd /dl/os

Visit or go directly to the link In my example we’ll use Squeeze 6.0 AMD 64 Net install.



Create the VM (domU)

We’ll create a Debian Squeeze amd 64 VM on the LV we created. This process, directly uses the Xen VM cfg creation file by means of HVM (full virtualization), instead of starting with the normal xen-tools.conf file, which creates this Xen VM cfg file for us (mostly used for paravirtualization).

Create a new Xen VM config file:

prompt>nano /etc/xen/vmx01cms01.cfg

At Minimum - Copy, paste, and save all the following into this new vmx01cms01.cfg, file.

kernel = "/usr/lib/xen-default/boot/hvmloader"
name = "vmx01cms01"
vif = ['bridge=eth0']
disk = [ 'phy:/dev/vol/vmx01cms01,ioemu:hda,w','file:/dl/os/debian-6.0.0-amd64-netinst.iso,ioemu:hdc:cdrom,r']
#memory = "2048"
#on_reboot   = 'restart'
#on_crash    = 'restart'

Go here to view some more Xen loadouts. Also, notice the commenting of the vcpus, memory, etc…; simply uncomment them to set it.

Start the VM and OS Installation Process

prompt>xm create /etc/xen/vmx01cms01.cfg

Or you can use:

xm create -c vmx01cms01.cfg

If you decide not to go through with the installation (no harm done, accept for a couple of log files), i.e. you decide to reconfigure something. prompt> xm destroy vmx01cms01

View and interact with the installation process via VNC Client

  • If your client is on a Windows Machine, launch VNC Client viewer (display), and type in: or
    You’ll be prompted for password.
  • If your client is on your Xen host Server, than type in:
    localhost:6 or x01:6 or
    You’ll be prompted for password.
  • If your client is on a Linux Machine, than type:
    Connected to RFB server, using protocol version 3.8
    Performing standard VNC authentication<
    Password: [Enter Password]

Your VNC display will look like this:
Xen on Debian 6.0 Squeeze VM


Congrats you are done!

Actually you are not done, yet.

Install VM

Answer each step of the installation process, as though you were installing a physical server to your preference. I selected manual partitioning with no LVM; two ‘primary’ partitions; 12gb for OS and 4.1gb for swap; swap in my case is twice the size of ram I will give the VM.

See My Example:
Debian 6.0 Squeeze VM Guest Partition - My Settings

I didn’t feel like creating a screenshot image, so I used an old image (same thing applies accept I used ext4 (YEA), instead of ext3. I selected two primary partitions, to keep it simple and chances are I will not be adding more than three partitions, so no need for logical partition; logical swap. With normal partitioning instead of LVM, you’ll be able to use Gparted in the future. This is totally up to you, because it depends on what the VM, is going to be used for; this is key. Finish the installation.

Remove ISO image

The final step in the installer, “Installation Complete” is to boot into your new system. At this point or during installation process you’ll want to remove “iso image” directive, by editing your vmx01cms01.cfg file.

Pay attention here:

prompt>nano /etc/xen/vmx01cms01.cfg

If you want to use the Xen host’s cdrom drive:


disk = [ 'phy:/dev/vol/vmx01cms01,ioemu:hda,w','file:/dl/os/debian-6.0.0-amd64-netinst.iso,ioemu:hdc:cdrom,r']


disk = [ 'phy:/dev/vol/vmx01cms01,ioemu:hda,w','phy:/dev/cdrom,hdc:cdrom,r', ]

If you don’t want to use the Xen host’s cdrom drive:


disk = [ 'phy:/dev/vol/vmx01cms01,ioemu:hda,w','file:/dl/os/debian-6.0.0-amd64-netinst.iso,ioemu:hdc:cdrom,r']


disk = [ 'phy:/dev/vol/vmx01cms01,ioemu:hda,w', ]

If you choose to use Xen host’s cdrom, than you must always, “I repeat again”, always have a cdrom drive attached to the Xen host, or else the VM will fail to boot. This gave me a lot of headaches, you’ll see a message in xend.log like:
DEBUG (DevController:156) Waiting for 768.
DEBUG (DevController:595) hotplugStatusCallback /local/domain/0/backend/vbd/4/768/hotplug-status.

Boot into new VM

You can now select: “Continue” to boot into new system.

prompt>xm destroy vmx01cms01 prompt>/etc/init.d/xend restart prompt>xm create /etc/xen/vmx01cms01.cfg

View Progress (or troubleshoot), by opening another ssh terminal:

prompt>tail -f /var/log/xen/xend.log -n 30

View and interact with your new VM via VNC Client


If it fails, it’s best to restart Xen host, as your first troubleshoot try.


Create Backup of the Xen VM cfg file

After you have a working VM, it’s a good idea to make a copy of it.

prompt>mkdir -p /bak/vm prompt>cp /etc/xen/vmx01cms01.cfg /bak/vm/

You, now you have a Debian 6 x64 HVM VM (guest, domU) on a Debian 6 x64 XEN Host (domO).

First thing you want to do is the following, so you can access the VM from a normal ssh terminal:


prompt>apt-get install openssh-server


Troubleshooting Debian 6 Squeeze Xen host and Optional Useful CLI Commands

To avoid Debian Squeeze x64 VM boot problems.

INIT: id co respawning too fast disabled for 5 minutes

On your Xen VM (guest, domU):

prompt>nano /etc/inittab

Change this:

co:2345:respawn:/sbin/getty hvc0 9600 linux

to this:

#co:2345:respawn:/sbin/getty hvc0 9600 linux

Or if that doesn’t work than try this:

On your Xen host (domO):

prompt>nano /etc/inittab

Change this:

1:2345:respawn:/sbin/getty 38400 tty1

to this:

1:2345:respawn:/sbin/getty 38400 hvc0

Here are some troubleshooting examples, and some very useful CLI commands.

If you need to install nic drivers on new Debian Squueze vm:

Copy the nic drivers to cdrom, than insert cdrom into Xen host cdrom drive, than run the following command on Xen VM:

prompt>mount -t iso9660 /dev/hdc /media/cdrom0 prompt>/media/cdrom0/dpkg -i firmware-bnx2_0.27_all.deb

After install Unmount

prompt>umount /media/cdrom0 prompt>reboot


If VM eth0 doesn’t come up.

Their are two solutions, the first is fixing the root of the problem, Use a permanent mac address found in /etc/xen/vmx01cms01.cfg, to permanently keep the same ethX. The second, is being caused by the VM thinking there is a new NIC installed.

First Solution:


Second Solution:

prompt>ifconfig -a

Make a note of the eth device number, i.e. eth3

prompt>nano /etc/network/interfaces




prompt>ifdown eth0 && ifup eth0

You shouldn’t get this problem if you didn’t change the permanent MAC address.

If you want to mount VM’s LV on Debian Squeeze Xen Host.

You can view the VM’s LV partitions on Xen host with:

prompt>fdisk -l -u /dev/vol/vmx01cms01


Disk /dev/vol/vmx01cms01: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 cylinders, total 31457280 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x0008ae25
               Device Boot      Start         End      Blocks   Id  System
/dev/vol/vmx01cms01p1   *          63    23438834    11719386   83  Linux
/dev/vol/vmx01cms01p2        23438835    31455269     4008217+  82  Linux swap / Solaris

Since the VM’s LV is a whole disk containing partitions, you can’t simply mount it. You first need to create maps to the individual partitions.

prompt>apt-get install kpartx prompt>kpartx -av /dev/vol/vmx01cms01 prompt>mount -t ext3 /dev/mapper/vol-vmx01cms01p1 /mnt prompt>ls /mnt

Make sure to umount it, when your done:

prompt>umount /mnt

Remove device mapping

prompt>kpartx -dv /dev/vol/vmx01cms01


If you want to use XM console.

XM Console works in Paravirtualization with little fuss, but with HVM (full virtualization), XM Console is rather cumbersome to setup, therefore you can ssh or vnc into initial installation of the HVM VM. If you are brave to install xm console for hvm, visit, Xen FAQ.

Useful XEN and VM CLI commands and tips.

Here are some useful CLI commands, which OpenQRM will mostly facilitate for us with the WebUI.

Some common xen commands:


prompt>xm create /etc/xen/vmx01cms01.cfg


prompt>xm shutdown vmx01cms01

Or Destroy (Unplug the VM from outlet)

prompt>xm destroy vmx01cms01

View running VMs, in real mode:

prompt>xm top

List running VMs:

prompt>xm list


If you want to delete VM and the LVs from Debian Squeeze Xen Host (domO)

If you want to delete all VM and LV, and start from scratch

For reference only. Might not work for LVs inside an LV.

Unplug the VM

prompt>xm destroy vmx01cms01

Unmount LV (probably not mounted anyway’s, for reference only)

prompt>umount /dev/mapper/vol-vmx01cms01

Deactivate it

prompt>lvchange -a n /dev/mapper/vol-vmx01cms01

Delete LV

prompt>lvremove /dev/mapper/vol-vmx01cms01 prompt>lvdisplay

Nothing to display.

Now simply delete the vmx01cms01.cfg, VM file.

prompt>rm /etc/xen/vmx01cms01.cfg

You now have no VM and no LV.

Don’t forget to change the fstab, in case you mounted any of these LVs.

prompt>nano /etc/fstab

Don’t forget to empty out your ssh known host, if your using the same LV configs again.

prompt>cat /dev/null > /root/.ssh/known_hosts


If you want to resize LV VM(Shrinking) from Debian Squeeze Xen Host (domO)

For reference only. Might not work for LVs inside an LV.

Unmount (just in case it’s mounted) so we can shrink

prompt>umount /dev/mapper/vol-vmx01cms01 prompt>e2fsck -f /dev/mapper/vol-vmx01cms01

Resize VG

prompt>resize2fs /dev/mapper/vol-vmx01cms01 1000M

Resize LV

prompt>lvresize -L 1G /dev/vol/vmx01cms01

Show Results


Remount - Optional

prompt>mount /dev/mapper/vol-vmx01cms01


Some Useful CLI commands and GUI, for LV

LVM Managing - CLI

prompt>vgdisplay prompt>pvdisplay prompt>lvdisplay

LVM Managing - GUI

prompt>apt-get install system-config-lvm


Also, loook into OpenQRM as it’s a great Web UI tool to manage XEN and other VMS.

Read about my other article on openQRM.


Have Fun with VM

you finished the tutorial. Thank you for following this tutorial.


This entry was posted on Friday, February 11th, 2011 at 9:13 pm and is filed under How To. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.