The Perfect Xen 3.1.0 Setup For Debian Etch (i386)
Author: Falko Timme
Last edited 05/30/2007
This tutorial provides step-by-step instructions on how to install Xen (version 3.1.0) on a Debian Etch (4.0) system (i386).
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 Etch (i386) for both the host OS (dom0) and the guest OS (domU). I will describe how to install Xen from the binary package in chapter 5 and from the sources (chapter 5). In an additional section at the end of chapters 4 and 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!
A note on x86_64 systems: I tried to install Xen 3.1.0 on Debian Etch AMD64 as well, but regardless of the method (Xen source install vs. Xen x86_64 binary install), the Xen kernel didn't boot (no error messages, but the boot process was incredibly slow and never finished...).
1 Install The Debian Etch Host System (dom0)
You can overall follow these instructions, but with a few changes:
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 Manual. I create the following partitions:
- /boot 150 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)
- / 3GB (Logical) (Location for the new partition: Beginning) (ext3)
- /vserver the rest (Logical) (Location for the new partition: Beginning) (ext3)
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 Preparation Of The Host System
After the base system has been installed and you have removed the installation CD and booted the base system, you should run
apt-get install ssh openssh-server vim-full
to install an SSH server so that you can connect to the system with an SSH client such as PuTTY. The vim-full package makes sure that the vi text editor behaves as expected (without vim-full, you might experience some strange behaviour in the vi text editor).
Because the Debian Etch 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):
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface #allow-hotplug eth0 #iface eth0 inet dhcp 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:
Then edit /etc/hosts. Make it look like this:
127.0.0.1 localhost.localdomain localhost 192.168.0.100 server1.example.com server1 # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters ff02::3 ip6-allhosts
Edit /etc/resolv.conf and add some nameservers:
nameserver 18.104.22.168 nameserver 22.214.171.124 nameserver 126.96.36.199
echo server1.example.com > /etc/hostname
and reboot the system:
shutdown -r now
Both should show server1.example.com.
From now on you can use an SSH client such as PuTTY and connect from your workstation to your Debian Etch server and follow the remaining steps from this tutorial.
Edit /etc/apt/sources.list. Comment out the CD. It should look like this:
# # deb cdrom:[Debian GNU/Linux 4.0 r0 _Etch_ - Official i386 NETINST Binary-1 20070407-11:29]/ etch contrib main #deb cdrom:[Debian GNU/Linux 4.0 r0 _Etch_ - Official i386 NETINST Binary-1 20070407-11:29]/ etch contrib main deb http://ftp2.de.debian.org/debian/ etch main deb-src http://ftp2.de.debian.org/debian/ etch main deb http://security.debian.org/ etch/updates main contrib deb-src http://security.debian.org/ etch/updates main contrib
to update the apt package database and
to install the latest updates (if there are any).
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. In my past Xen tutorials I always recommended to compile Xen from the sources because some features such as quota or iptables were missing in the binary package. This has changed now, so you will most likely find all needed features in the binary package, so I recommend to install the binary package. If you want to be in full control of what features are in the Xen kernel or if you need a special feature that's not in the binary package, you should compile Xen from the sources.
In chapter 4 I describe how to install the Xen binary package which might be easier for beginners. In chapter 5 I describe how to compile and install Xen from the sources. Chapters 4 and 5 are mutually exclusive. Follow either chapter 4 or 5, but not both of them!