The Perfect Xen Setup For Debian And Ubuntu - Page 2

3.1 Installing The Binary Package

Run the following commands:

apt-get remove exim4 exim4-base lpr nfs-common portmap pidentd pcmcia-cs pppoe pppoeconf ppp pppconfig
apt-get install screen ssh debootstrap python python2.3-twisted iproute bridge-utils libcurl3-dev

<-- Yes
<-- Yes
<-- Yes

3.1.1 Install Xen

Next do this:

cd /usr/src/
wget http://www.cl.cam.ac.uk/Research/SRG/netos/xen/downloads/xen-2.0.7-install-x86_32.tgz

tar xvzf xen-2.0.7-install-x86_32.tgz
cd xen-2.0-install
./install.sh

mv /lib/tls /lib/tls.disabled

Now Xen is installed. In order to start the Xen services at boot time, do the following:

update-rc.d xend defaults 20 21
update-rc.d xendomains defaults 21 20

3.1.2 Configure The Bootloader And Reboot

Next we add the Xen kernel to Grub, our bootloader. Edit /boot/grub/menu.lst, and before the line ### BEGIN AUTOMAGIC KERNELS LIST add the following stanza:

title Xen 2.0 / XenLinux 2.6.11
kernel /xen.gz dom0_mem=64000
module /vmlinuz-2.6.11-xen0 root=/dev/hda6 ro console=tty0

Make sure that /dev/hda6 is your / partition. Keep in mind what I said about Grub and partitioning in chapter 1!

Now reboot the system:

shutdown -r now

At the boot prompt, Grub should now list Xen 2.0 / XenLinux 2.6.11 as the first kernel and boot it automatically. If your system comes up without problems, then everything is fine!

Share this page:

21 Comment(s)

Add comment

Comments

From: Anonymous at: 2006-01-30 15:17:16

This has been a very helpful howto. Thanks for creating it. A follow up for xen 3 would be appreciated!

From: Anonymous at: 2009-10-18 00:26:41

Hi,

can you change this (on first page):

 

echo server1.example.com > /etc/hostname

 

to this:

 

echo server1 > /etc/hostname

 

Quote from `man hostname':

FILES
       /etc/hosts /etc/hostname This file should only contain domain name and not the full FQDN.

Thank you.
(i didn't want to create an account to be able to send an email...) ;-)

From: Anonymous at: 2006-03-11 15:56:39

In Ubuntu my ./install.sh failed due to i missing the twisted framework.

The error was;

Installing Xen from './install' to '/'...
All done.
Checking to see whether prerequisite tools are installed...
FAILED check_twisted
Checks failed. See /usr/src/xen-2.0-install/check/.chkinstall for details.
All done.

I fixed this by 'apt-get install python-twisted'

k31th

From: Anonymous at: 2006-03-16 15:15:21

This is a great how-to and I only have a small addition:

If you want to run more than 4 virtual machines, you need to add a boot option for the dom0 kernel in order to permit enough file-backed virtual block devices. In the example above, the line

module /vmlinuz-2.6.11-xen0 root=/dev/hda6 ro console=tty0

in section 3.1.2 has to be modified to

module /vmlinuz-2.6.11-xen0 root=/dev/hda6 ro console=tty0 max_loop=X

where the X needs to be replaced by 2 times the number of virtual machines.

Of course, as the Xen manual points out, if you have heavy I/O taking places in your virtual machines, you may experience performace losses if you increase X much beyond the default value of 8.


Dirk Petry

From: Anonymous at: 2006-05-06 21:21:13

as well as the max_loop=16 (or 2 x however many VMs you want)

you might need to make the loop devices eg /dev/loop8 /dev/loop9 etc

This helped me:

for i in $(seq 8 63) ; do mknod /dev/loop$i b 7 $i ; done

chmod 660 /dev/loop* ; chown 0.disk /dev/loop*

HTH Simon Faulkner

From: Anonymous at: 2005-11-16 16:58:47

If you receive:

/root/xen-2.0/xen/include/asm/processor.h:175: error: array type has incomplete element type

You may need to specify the version of GCC you wish to use for the compile.

I found people recommending to use:
make CC=gcc-3.2 world

However, the best I could get was gcc-3.3 (ie. /usr/bin/gcc-3.3) so I did:
make CC=gcc-3.3 world


From: Anonymous at: 2005-11-16 17:33:12

My previous comment regarding make world also applies to make install

From: Anonymous at: 2005-12-02 03:52:19

When I compiled the kernel, I also needed to apt-get install patch to get the patch program.

From: Anonymous at: 2005-12-21 17:21:54

Steps that begin with "cd .." cause confusion. I suggest either changing to a specific folder "cd ~/xen" or at least commenting where you are changing to "#Change to the ~/xen folder" so the user can know they are in the correct path.

This is very useful. Thanks for taking the time to document the perfect xen setup!

Tim


From: admin at: 2005-12-22 09:00:21

As stated at the beginning of this tutorial, this is a "copy & paste" howto, i.e. you should simply follow the steps presented here without doing anything else in between (e.g. change directories or something like that) - then it will work without problems.

From: Anonymous at: 2006-01-11 20:17:03

Falko has done a brilliant job with this Howto. Apart from very minor things such as not mounting devpts after chrooting, it worked without a hitch. I've pasted a slightly modified version of section 3 below to show how I installed Xen 3.0.0 using Falko's Howto.

cheers,

Hizar

3.2 Installing From The Sources

Run the following commands:

apt-get remove exim4 exim4-base lpr nfs-common portmap pidentd pcmcia-cs pppoe pppoeconf ppp pppconfig
apt-get install iproute bridge-utils python-twisted gcc-3.3 binutils make libcurl3-dev zlib1g-dev python-dev transfig bzip2 screen ssh debootstrap libcurl-dev libncurses5-dev
(1 line!)
cd ~
mkdir xen
cd xen
mkdir archive
cd archive

3.2.1 Install Xen

Now execute these commands:

wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.12.tar.bz2
wget http://www.cl.cam.ac.uk/Research/SRG/netos/xen/downloads/xen-3.0.0-src.tgz

cd ..

tar -xvzf archive/xen-unstable.7-src.tgz
tar -xvjf archive/linux-2.6.12.tar.bz2

cd xen-unstable
make world

make install
sh ./install.sh

Now Xen is installed. In order to start the Xen services at boot time, do the following:

update-rc.d xend defaults 20 21
update-rc.d xendomains defaults 21 20

3.2.2 Compile A New dom0 Kernel

Next we compile a new dom0 kernel with Xen-, iptables-, quota-, and dummy support. The kernel will be installed to ~/xen/install so that we can save it for other machines. From ~/xen/install we will install it to the real locations. Xen works with kernel 2.6.11, so I take the latest 2.6.12 kernel (2.6.12) instead of newer kernels, e.g. 2.6.14.

cd ..
mv /lib/tls /lib/tls.disabled
cp -al linux-2.6.12 linux-2.6.12-xen0
cd xen-unstable/linux-2.6-xen-sparse/
./mkbuildtree ../../linux-2.6.12-xen0/
cd ../..
echo "-xen0" > linux-2.6.12-xen0/localversion-xen
diff -Naur linux-2.6.12 linux-2.6.12-xen0 > archive/linux-2.6.12-xen0.patch

cd linux-2.6.12
patch -p1 < ../archive/linux-2.6.12-xen0.patch

3.2.2.1 Apply additional patches for Xen 3.0 (unstable) for dom0 Kernel

Patch –p1 < ~/xen/xen-unstable/patches/linux-2.6.12/smp-alts.patch

Patch –p1 < ~/xen/xen-unstable/patches/linux-2.6.12/rcu-nohz.patch

Patch –p1 < ~/xen/xen-unstable/patches/linux-2.6.12/pmd-shared.patch

Patch –p1 < ~/xen/xen-unstable/patches/linux-2.6.12/net-csum.patch

Patch –p1 < ~/xen/xen-unstable/patches/linux-2.6.12/cpu-hotplug-init.patch

cd ../
mkdir install
cd linux-2.6.12-xen0
cp arch/xen/configs/xen0_defconfig .config
ARCH=xen; INSTALL_PATH=../install; INSTALL_MOD_PATH=../install
export ARCH INSTALL_PATH INSTALL_MOD_PATH
make oldconfig
make menuconfig

In the kernel configuration menu that shows up we have to enable quota, iptables and the dummy network driver as modules. This is where you enable these modules:

File systems --> [*] Quota support
<M> Old quota format support
<M> Quota format v2 support

Device Drivers ---> Networking support ---> <M> Dummy net driver support

Device Drivers ---> Networking support ---> Networking options ---> [*] Network packet filtering (replaces ipchains) ---> IP: Netfilter Configuration ---> <M> IP tables support (required for filtering/masq/NAT)

[*] means: build into the kernel statically.
<M>
means: build as a kernel module.

Now we install the kernel to ~/xen/install:

make modules
make modules_install
make install

Finally, we copy the kernel to the "real" locations:

cd ../install/
cp boot/* /boot
cp -r lib/modules/2.6.12-xen0/ /lib/modules
cp -r usr/include/xen /usr/include

3.2.3 Configure The Bootloader And Reboot

I configured my kernel with SMP support, hence the name I have given my kernel. Make sure you change the other settings to suit as per falko’s howto.

title Xen 3.0.0 Debian SID dom0 2.6.12-6 SMP

root (hd0,0)

kernel /xen.gz dom0_mem=1024M vga=791

module /vmlinuz-2.6.12.6-xen0 root=/dev/hde2 ro console=tty0

From: Anonymous at: 2005-12-11 19:03:43

I had to make the ptmx device as well to get it up and running...

Issue the following command before mounting it:

mknod --mode=666 /dev/ptmx c 5 2

From: Anonymous at: 2005-12-05 22:47:08

Great document! Everything worked like a charm... except for one thing...

I recieved an error while running the base-config command. It constantly stopped with "Terminated" being output to the terminal. I ran strace against the command and I found that /dev/pts is not actually mounted in that file system, so it could not open the device (weird how that works). So, make sure to run the following command before running base-config to remedy this issue:

mount -t devpts -o rw,gid=5,mode=620 none /dev/pts

Also, FYI: Xen running a virtual machine inside of a VMWare GSX server does not work so well.

Thanks for the great write-up!

From: Anonymous at: 2006-02-24 15:07:16

Under Ubuntu 5.10 (breezy) instead of doing 'apt-get install localeconf' which will fail anyway unless you add the universe repository, just issue this command:

dpkg-reconfigure locales

Then you can select:

en_US ISO-8859-1

-j

From: Anonymous at: 2006-02-27 22:21:40

Some annotation to the last sentence of this page:

if you get a warning like this: umount: /vserver/vm_base: device is busy it probably means that you accidentally started some daemon out of your chroot. At least it happened to me. I chrooted into the vserver disk, installed ssh and it immediately stopped my regulary ssh daemon and started that of the chroot instead. That was the cause of the error message.

Otherwise thanks for this document!

From: Anonymous at: 2005-12-18 18:10:01

I had to create the hda2 entry under /dev in order to have the swap (I use the Xen 3.0 version):

mknod --mode=666 /dev/hda2 b 3 2 (for example)

Anyway, thanks a lot for this wonderful work!!

From: Anonymous at: 2005-11-15 08:15:20

Thx for this nice in depth article. Fine work. I would like to point out 2 things. As of Nov 13. Intel releases its VT processors[1], so you can run even an unmodifyed windows within a Xen 3.0 domain. There is another Xen related debian project called Xenophilia that is worth a look.

[1] http://www.nordichardware.com/news,2253.html
[2] http://cosi.clarkson.edu/xen/

the polarizer
http://www.codixx.de/polarizer.html




From: Anonymous at: 2006-01-30 13:15:59

needed for iptables:

apt-get install modconf module-init-tools

From: falko at: 2006-01-18 17:46:06

Yes, as soon as anybody cares to answer this question:

http://lists.xensource.com/archives/html/xen-users/2006-01/msg00432.html

It seems I'm having the same problem than you... :-(

From: Anonymous at: 2006-01-18 12:53:23

Hi there,

first of all, thanks for the really great setup tutorial. It worked out great for me.

Could you also provide help on how to set up the virtual local network in Xen 3.0, as this page seems not applicable to that version.

Kind regards

Nico

From: Anonymous at: 2006-01-27 11:42:06

Instead of dummy driver you could just use the IP alias feature (eth0:1)! correct?