Hosting virtual servers using Debian Lenny and Xen

The hype around virtual servers has quietened down and virtualization is becoming simply another tool in the sysadmin toolbox. Debian Lenny has made running instances in Xen even easier, but even so it isn't a no-brainer. For future reference, this is a quick list of steps for hosting virtual servers using static public IPs on Debian Lenny, using loopback files for containing the virtual server images.


One thing that I keep getting mixed up are the Xen terms Dom0 and DomU. For the record:

  • Dom0 - Your actual (host) server
  • DomU - Your virtual (guest) servers

Dom0 (host)

  • We'll assume you start with a fresh Debian Lenny install
  • Install Xen and a Xen-enabled Debian kernel: apt-get install xen-linux-system-2.6.26-1-xen-686 xen-utils-3.2-1 xen-utils-common grub
  • Set up grub: update-grub and select the installed Xen kernel as the default in /boot/grub/menu.lst
  • Configure /etc/xen/xend-config.sxp (at least make sure network-bridge and vif-bridge are enabled)
  • Reboot Dom0

DomU (guest)

  • Create a file to store the virtual server (5GB example): dd if=/dev/zero of=xen-image.img bs=1024M count=5
  • Turn it into a ext3 filesystem: mkfs.ext3 xen-image.img
  • Get the example Xen netboot configuration file:
  • Set the following in xm-debian.cfg:
    • name = 'vps1'
    • memory = 128
    • vif = [''] (this is the IP address through which the server will be accessible, a public IP is required if you want it accessible from the internet)
    • disk =['file:/path/to/xen-image.img,xvda,w']
  • To install Lenny on the virtual server: xm create -c xm-debian.cfg install=true install-mirror=
  • To boot the virtual server: xm create -c xm-debian.cfg
  • To connect to the console of the virtual server: xm console vps1
  • Set up networking in /etc/network/interfaces (the first IP address is the same as used above, the second IP address is the public IP address of your Dom0, which is acting as a gateway for your virtual servers):
  • iface eth0 inet static
  • Set up your DNS settings in /etc/resolv.conf
  • Restart your networking: /etc/init.d/networking restart
  • If everything went alright, you now have a fully-functional virtual Lenny!


  • To list the running virtual servers: xm list (see man xm for many more useful commands)
  • apt-get install ssh on your virtual server to be able to log in remotely
  • If you are planning to install multiple virtual servers, it's a good idea to make a copy of the fresh virtual Lenny install to avoid having to install Debian multiple times.


Other things to check out

  • xen-tools package
  • /etc/default/xendomains