Installing Xen On An Ubuntu Feisty Fawn Server From The Ubuntu Repositories
Version 1.0
Author: Falko Timme
This tutorial provides step-by-step instructions on how to install Xen on an Ubuntu Feisty Fawn (Ubuntu 7.04) server system (i386). You can find all the software used here in the Ubuntu repositories, so no external files or compilation are needed.
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 Ubuntu Feisty Fawn (i386) for the host OS (dom0) and Ubuntu Dapper Drake and Ubuntu Edgy Eft for the guest operating systems (domU).
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 Ubuntu Feisty Fawn Host System (dom0)
You can install the host system (dom0) as shown in the chapters one to seven of this tutorial: https://www.howtoforge.com/perfect_setup_ubuntu704 (of course, you don't have to do this if you already have an Ubuntu 7.04 host system that you want to use).
Make sure that the root account is enabled, because we must run all the steps from this tutorial as root user. Also, if you want to use vi as your text editor (as suggested by this tutorial), you should run
apt-get install vim-full
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).
dom0's FQDN in this example will be server1.example.com. server1.example.com's IP address will be 192.168.0.100 in this tutorial, and the gateway I use is 192.168.0.1, so the virtual machines will have to use that one, too.
2 Install Xen
To install Xen and all needed dependencies, all we have to do is run the following command:
apt-get install ubuntu-xen-server
This will also install the xen-tools package which we use later on to create virtual machines.
Now we edit /etc/xen/xend-config.sxp. Comment out the (network-script network-dummy) line and add (network-script network-bridge) right above the (vif-script vif-bridge) line, like this:
vi /etc/xen/xend-config.sxp
[...] #(network-script network-dummy) [...] (network-script network-bridge) (vif-script vif-bridge) [...] |
We also need to add the loop module to the kernel every time we boot our system, so edit /etc/modules and add the loop module at the end of the file:
vi /etc/modules
[...] loop max_loop=64 |
Now take a look at the /boot directory to see which kernels and ramdisks are installed:
ls -l /boot/
root@server1:~# ls -l /boot/
total 18780
-rw-r--r-- 1 root root 414210 2007-04-15 10:19 abi-2.6.20-15-server
-rw-r--r-- 1 root root 72726 2007-04-05 08:08 config-2.6.19-4-server
-rw-r--r-- 1 root root 83298 2007-04-15 08:33 config-2.6.20-15-server
drwxr-xr-x 2 root root 4096 2007-06-25 22:00 grub
-rw-r--r-- 1 root root 6325928 2007-06-25 21:56 initrd.img-2.6.19-4-server
-rw-r--r-- 1 root root 6802658 2007-06-25 23:10 initrd.img-2.6.20-15-server
-rw-r--r-- 1 root root 94600 2006-10-20 13:44 memtest86+.bin
-rw-r--r-- 1 root root 783333 2007-04-05 08:08 System.map-2.6.19-4-server
-rw-r--r-- 1 root root 812139 2007-04-15 10:20 System.map-2.6.20-15-server
-rw-r--r-- 1 root root 1726726 2007-04-05 08:08 vmlinuz-2.6.19-4-server
-rw-r--r-- 1 root root 1763308 2007-04-15 10:19 vmlinuz-2.6.20-15-server
-rw-r--r-- 1 root root 259025 2007-03-24 17:03 xen-3.0-i386-pae.gz
root@server1:~#
The /boot/vmlinuz-2.6.19-4-server kernel is the Xen kernel that got installed together with the ubuntu-xen-server package, and /boot/initrd.img-2.6.19-4-server is its ramdisk. We will need these soon.
I want to store my virtual machines in the /home/xen directory, therefore I create it now:
mkdir /home/xen
We will use xen-tools to create virtual machines. xen-tools make it very easy to create virtual machines - please read this tutorial to learn more: https://www.howtoforge.com/xen_tools_xen_shell_argo. As mentioned before, the xen-tools package got installed together with the ubuntu-xen-server package.
Now we edit /etc/xen-tools/xen-tools.conf. This file contains the default values that are used by the xen-create-image script unless you specify other values on the command line. I changed the following values and left the rest untouched:
vi /etc/xen-tools/xen-tools.conf
[...] dir = /home/xen dist = edgy gateway = 192.168.0.1 netmask = 255.255.255.0 passwd = 1 kernel = /boot/vmlinuz-2.6.19-4-server initrd = /boot/initrd.img-2.6.19-4-server mirror = http://de.archive.ubuntu.com/ubuntu/ [...] |
The dist line holds the default distribution that you want to install in a virtual machine. Although a comment in the /etc/xen-tools/xen-tools.conf mentions that at this time the only supported Ubuntu flavour is Dapper Drake (dapper), Edgy Eft (edgy) works as well (Feisty Fawn aka feisty does not at this time).
The kernel line must contain our Xen kernel, and the initrd line its ramdisk.
The passwd = 1 line makes that you can specify a root password when you create a new guest domain. In the mirror line specify an Ubuntu mirror close to you.
Make sure you specify a gateway and netmask. If you don't, and you don't specify a gateway and netmask on the command line when using xen-create-image, your guest domains won't have networking even if you specified an IP address!
Now reboot the system:
shutdown -r now
If your system reboots without problems, then everything is fine!
Run
uname -r
and your new Xen kernel should show up:
root@server1:~# uname -r
2.6.19-4-server
root@server1:~#