On this page
The Perfect Xen 3.0.1 Setup For Debian
Author: Falko Timme
This tutorial provides step-by-step instructions on how to install Xen (version 3.0.1) 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). In an additional section at the end I will also show how to create a virtual local network with virtual machines, with dom0 being the router.
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 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: https://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.1 / XenLinux 2.6.12-xen0
to /boot/grub/menu.lst then you should probably use
title Xen 3.0.1 / XenLinux 2.6.12-xen0
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):
# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)
Then restart your network:
Edit /etc/resolv.conf and add some nameservers:
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: install the binary package from the Xen website, or compile Xen and the Xen kernels from the sources.
The first 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.
In chapter 3.1 I describe how to install the Xen binary package which is recommended for beginners (skip chapter 3.2 and continue with chapter 4). If you need quota and iptables in your virtual machines, then skip chapter 3.1 and continue with chapter 3.2 where I show how to install Xen from the sources.