Xen on Debian Lenny dom0

From Wiki
Jump to: navigation, search

This is OLD: For Debian Squeeze (6), see Xen on Debian Squeeze dom0

Important Notes/Assumptions

  • These instructions refer to Debian Lenny (5) and are now OUTDATED. For Debian Squeeze (6), see Xen on Debian Squeeze 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 Lenny 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.
  • 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:
# 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.

Xen

  • Install the required packages (vim, sudo, openssh-server not required but are handy):
# apt-get update
# apt-get install xen-hypervisor-3.2-1-amd64 xen-linux-system-2.6.26-1-xen-amd64 xen-utils-3.2-1 xenstore-utils xenwatch xen-shell xen-tools \
vim sudo openssh-server
  • Edit /etc/xen/xend-config.sxp
    • Uncomment this line:
      (network-script network-bridge)
    • Comment out this one:
      #(network-script network-dummy)
  • Reboot in order to load the Xen-capable kernel just installed a moment ago:
# shutdown -r now

domU

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

dist = lenny

gateway   = 172.16.0.254
netmask   = 255.255.255.0
broadcast = 172.16.0.255

passwd = 1

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

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

serial_device = hvc0

disk_device = xvda
  • Here, I'm creating a Debian Lenny paravirtualised domU using the debootstrap method defined in the above config:
# xen-create-image --hostname=xen1.spruce.toastputer.net --size=8Gb --swap=256Mb --ip=172.16.0.19 --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 Lenny 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.