Xen on Debian Squeeze dom0

From Wiki
Jump to: navigation, search

Important Notes/Assumptions

  • These instructions refer to Debian Squeeze (6). For Debian Lenny (5), see Xen on Debian Lenny dom0.
  • It is assumed that the architecture is amd64. If using another architecture such as i386, substitute as necessary. Note that only paravirtualisation will be available if your CPU lacks the appropriate instruction sets needed for full virtualisation. It is possible (and desirable) to run Linux under paravirtualisation, but other OSes such as Windows and *BSD will be diffucult or impossible. TO check whether your CPU has the right instructions, run:
# xm dmesg | grep HVM

If you have no HVM extensions then there will be no output, but if they are present you'll see:

(XEN) HVM: SVM enabled
(XEN) HVM: Hardware Assisted Paging detected and enabled.

dom0 OS Install

dom0 is the hypervisor, the system upon which the guest virtual machines (domU) reside.

  • Perform a bare-bones Debian Squeeze install. Allocate as little disk space as possible, this scheme would do:
Filesystem       Size    Mounted on
/dev/md0          92M    /boot
/dev/md1         2.8G    /
/dev/md2         942M    /var
  • When your system is installed and booted, most of your disk space should be unallocated. Create a new partition, allocating as much of this free space you wish to use for your domU virtual machines. I used all of it.
  • Among other advantages, Xen has much better disk IO performance if you use LVM rather than disk images. Create the volume group like so, assuming md3 is your empty partition:
# apt-get install lvm2
# pvcreate /dev/md3
# vgcreate xen-vol /dev/md3
  • Verify that the volume group really was created:
# vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "xen-vol" using metadata type lvm2
  • Later, xen-create-image will create logical partitions on the fly when you instantiate a new domU. These will appear within the xen-vol volume group.


  • Install the required packages (vim, sudo, openssh-server not required but are handy):
# apt-get update
# apt-get install linux-image-xen-amd64 xen-hypervisor-4.0-amd64 xen-tools vim sudo openssh-server
  • Edit /etc/xen/xend-config.sxp
    • Uncomment or add this line:(network-script network-bridge)

  • The default is to have Xen try to save the state of each domU when the dom0 shuts down and then restore it later. There are two problems with this:
    • It requires a large amount of free space on /var
    • It doesn't work very well
  • So disable it:
# vi /etc/default/xendomains


  • Debian Squeeze now uses the Grub 2 bootloader. Grub 2's defaults are wrong for Xen. The Xen hypervisor must be the first entry, so do this:
# mv /etc/grub.d/10_linux /etc/grub.d/50_linux
  • Disable the OS prober so that you don’t get unwanted boot entries for each virtual machine you install later:
# echo "" >> /etc/default/grub
# echo "# Disable OS prober to prevent virtual machines on logical volumes from appearing in the boot menu." >> /etc/default/grub
# echo "GRUB_DISABLE_OS_PROBER=true" >> /etc/default/grub
  • Tell Grub 2 to read in the changes:
# update-grub2
  • Reboot in order to load the Xen-capable kernel just installed a moment ago:
# shutdown -r now


  • Now we're ready to create a virtual machine. The fastest and easiest way to get started is to use xen-create-image. Alternativeley, you could use my friend candidhat's method. Let's create a default configuration:
  • Ensure that the following parameters in /etc/xen-tools/xen-tools.conf are set:
lvm = xen-vol

dist = squeeze

gateway   =
netmask   =
broadcast =

passwd = 1

kernel      = /boot/vmlinuz-`uname -r`
initrd      = /boot/initrd.img-`uname -r`

mirror = http://ftp.uk.debian.org/debian/

serial_device = hvc0

disk_device = xvda
  • Here, I'm creating a Debian Squeeze paravirtualised domU using the debootstrap method defined in the above config:
# xen-create-image --hostname=xen1.spruce.toastputer.net --size=8Gb --swap=256Mb --ip= --memory=512Mb --arch=amd64 --role=udev

xen-create-image along with the rest of xen-tools is very powerful, look.

  • After a bit of thinking, Xen will spit out a fully formed Debian Squeeze host. Start the host like this:
# xm create /etc/xen/xen1.spruce.toastputer.net.cfg

You can either ssh to the new domU, or connect directly to its console:

# xm console xen1.spruce.toastputer.net
  • ^] disconnects from the console. Run xm with no arguments to see other operations.