The Perfect Xen 3.0.3 Setup For Debian Sarge

Want to support HowtoForge? Become a subscriber!
 
Submitted by falko (Contact Author) (Forums) on Fri, 2006-10-20 12:38. :: Debian | Xen | Virtualization

The Perfect Xen 3.0.3 Setup For Debian Sarge

Version 1.0
Author: Falko Timme <ft [at] falkotimme [dot] com>
Last edited 10/20/2006

This tutorial provides step-by-step instructions on how to install Xen (version 3.0.3) on a Debian Sarge (3.1) system.

Xen lets you create guest operating systems (*nix operating systems like Linux and FreeBSD), so called "virtual machines" or domUs, under a host operating system (dom0). Using Xen you can separate your applications into different virtual machines that are totally independent from each other (e.g. a virtual machine for a mail server, a virtual machine for a high-traffic web site, another virtual machine that serves your customers' web sites, a virtual machine for DNS, etc.), but still use the same hardware. This saves money, and what is even more important, it's more secure. If the virtual machine of your DNS server gets hacked, it has no effect on your other virtual machines. Plus, you can move virtual machines from one Xen server to the next one.

I will use Debian Sarge for both the host OS (dom0) and the guest OS (domU). I will describe how to install Xen from the sources (which I recommend) in chapter 4 and from the binary package (chapter 5). In an additional section at the end of chapter 4 (chapter 4.5 ) I will also show how to create a virtual local network with virtual machines, with dom0 being the router. Chapters 4 and 5 are mutually exclusive.

This howto is meant as a practical guide; it does not cover the theoretical backgrounds. They are treated in a lot of other documents in the web.

This document comes without warranty of any kind! I want to say that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take. I do not issue any guarantee that this will work for you!

 

1 Install The Debian Sarge Host System (dom0)

You can overall follow these instructions, but with a few changes:

However, it's important that you type linux26 at the boot prompt to install a kernel 2.6 system. dom0's FQDN in this example will be server1.example.com, so I specify server1 as Hostname and example.com as Domain name. server1.example.com's IP address will be 192.168.0.100 in this tutorial.

When it comes to the partitioning, I select Manually edit partition table. I create the following partitions:

  • /boot 100 MB (Primary) (Location for the new partition: Beginning) (ext3) (Bootable flag: on <-- important, otherwise your system will not boot!)
  • swap 1GB (Logical) (Location for the new partition: Beginning)
  • / 2GB (Logical) (Location for the new partition: Beginning) (ext3)
  • /vserver the rest (Logical) (Location for the new partition: Beginning) (ext3)

(Side note: You can also install everything in one big partition (as described here: http://www.howtoforge.com/perfect_setup_debian_sarge), but then you have to keep in mind that the Grub stanzas I describe in this howto are slightly different. For example, when I write that I add

[...]
	  
title Xen 3.0.3 / XenLinux 2.6
root (hd0,0)
kernel /xen.gz  dom0_mem=64000
module /vmlinuz-2.6-xen root=/dev/hda6 ro max_loop=255
module /initrd.img-2.6.16.29-xen

[...]

to /boot/grub/menu.lst then you should probably use

[...]
	  
title Xen 3.0.3 / XenLinux 2.6
root (hd0,0)
kernel /boot/xen.gz  dom0_mem=64000
module /boot/vmlinuz-2.6-xen root=/dev/hda6 ro max_loop=255
module /boot/initrd.img-2.6.16.29-xen

[...]

in that file instead...)

When the Debian installer prompts Choose software to install: I make no selection and go on (dom0 should run as few software as possible in order not to be vulnerable to attacks. To the outside world it will be accessible only over SSH.).

 

2 Configure dom0's Network

Because the Debian Sarge installer has configured our system to get its network settings via DHCP, we have to change that now because a server should have a static IP address. Edit /etc/network/interfaces and adjust it to your needs (in this example setup I will use the IP address 192.168.0.100):

vi /etc/network/interfaces

# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)

# The loopback interface
auto lo
iface lo inet loopback

# The first network card - this entry was created during the Debian installation
# (network, broadcast and gateway are optional)
auto eth0
iface eth0 inet static
        address 192.168.0.100
        netmask 255.255.255.0
        network 192.168.0.0
        broadcast 192.168.0.255
        gateway 192.168.0.1

Then restart your network:

/etc/init.d/networking restart

Edit /etc/resolv.conf and add some nameservers:

vi /etc/resolv.conf

search server
nameserver 145.253.2.75
nameserver 193.174.32.18
nameserver 194.25.0.60

 

Then set dom0's hostname:

echo server1.example.com > /etc/hostname
/bin/hostname -F /etc/hostname

 

3 Install Xen

There are two ways to install Xen: compile Xen and the Xen kernels from the sources, or install the binary package from the Xen website.

The last way is easier, but it has the disadvantage that the domU kernel that comes with the binary package has no support for quota and iptables, both features that I need in my virtual machines (domU). Plus, the dom0 kernel has no support for the dummy network driver, which might come in handy for more advanced network setups. Also, if you use the binary package, there is only one kernel for both dom0 and domU, and the network setup for the virtual machines cannot be done using configuration files on dom0, but has to be done within the virtual machines themself which is rather complicated if you want to create new virtual machines from a pre-made image. I also got the impression that the source install is much more stable/mature. On the binary install it happened to me that a virtual machine didn't boot up because of a kernel panic, and two minutes later the same unchanged virtual machine did boot up without problems. So I highly recommend to compile Xen from the sources, although this takes much more time.

In chapter 4 I describe how to compile and install Xen from the sources which is a must if you need quota and iptables in your virtual machines. In chapter 5 I describe how to install the Xen binary package which might be easier for beginners. Chapters 4 and 5 are mutually exclusive. Follow either chapter 4 or 5, but not both of them!


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by harm (registered user) on Fri, 2006-10-20 13:17.
Falko, although this is interesting to use with Sarge on relatively old hardware its useless on new hardware... eg. mainboards with Intel's ICH7 bridge will simply not function with Sarge's kernel (2.6.8) and your better of with Etch in that case. And Etc gets Xen with an easy apt-get :)