Fedora and Xen: A Quick Start Guide

Jeremy Katz katzj at redhat.com
Tue Jan 25 05:03:16 UTC 2005

As some people have noticed, Xen is now available from the Fedora
development repository.  More information on Xen itself can be found at
http://www.cl.cam.ac.uk/Research/SRG/netos/xen/index.html.  We're
following the -unstable Xen tree at the moment which does occasionally
lead to things being broken but also lets us track a lot of the more
interesting work going on there.  Since setting up to run Xen isn't
entirely straight-forward, here's a run-through of what should work for
setting up a single Xen guest running the Fedora development tree.

To run xen on a system pulling strictly from the Fedora devel
repository, all of your deps should get satisfied automatically.  But,
they are explicitly
* mkinitrd 4.2.0
* python 2.4 
* python-twisted
* Using grub as your boot loader [1]
* Probably something on the order of 256 MB of RAM with the default
setup [2]

Then, you should be able to install the xen and kernel-xen0 packages.
Once this is done, you should have an entry set up in your grub.conf to
boot the xen0 kernel.  Now, reboot into your new xen0 kernel [3]

Once you've rebooted, you should be running in the dom0 kernel.  You'll
see a slightly scary looking warning about TLS during bootup and how to
disable it, but it shouldn't make things too bad.  Then, if you start
xend with 'service xend start', you should be able to run 'xm list' and
see your domain running.  Now, we want to set up a simple base Fedora
system.  First, you'll want to install the kernel-xenU package
(unfortunately, the kernel for your guest domain must currently be kept
outside of the guest itself).

Next, let's create a file to use as the backing for our Fedora install.
For example purposes, I'll create one of a size of 1 GB.
  dd if=/dev/zero of=/root/fedora.img bs=1M count=1024
Now, create an ext3 filesystem on this image.
  mke2fs -F -j /root/fedora.img
You should now be able to mount your new temporary rootfs on a temporary
mountpoint, say /mnt
  mount -o loop /root/fedora.img /mnt
Now, we can install whatever basesystem we want into this chroot.  Make
sure that your yum configuration points to a valid repository.  Then,
decide what group(s) you want to install.  I'd recommend starting with
Base (or for the space constrained, Core, but this is more difficult).
Then, run
  yum --installroot=/mnt -y groupinstall Base

Now, go get some coffee and have a snack.  It's going to take a little
while :-)

Come back and if everything went okay, you'll have a minimal install
in /mnt.  Now, for the ugly part, we need to set up some basic bits on
the filesystem that have to be different for xen right now.  These
include a) creating some required device nodes in /dev
since we're not using an initrd  and b) setting up an /etc/fstab
  for i in console null zero ; do MAKEDEV -d /mnt -x $i ; done

For the /etc/fstab, something simple like the following should work
/dev/sda1               /                       ext3    defaults
1 1
none                    /dev/pts                devpts  gid=5,mode=620
0 0
none                    /dev/shm                tmpfs   defaults
0 0
none                    /proc                   proc    defaults
0 0
none                    /sys                    sysfs   defaults
0 0

Do any other configuration you want to on the filesystem and then
unmount it [4]
  umount /mnt{/proc,}

Now, we just have to create a config file and you should be good to go.
I go for a very simple config file like the following which
is /etc/xen/rawhide on my machine [5]
kernel ="/boot/vmlinuz-2.6.10-1.1103_FC4xenU"
memory = 64
name = "rawhide"
nics = 1
disk = ['file:/root/fedora.img,sda1,w']
root = "/dev/sda1 ro"

Now, create a new domain with 'xm create -c rawhide' and off it goes. At
the end, you should see the login prompt at which point you can login as
root and begin playing around some.

This is pretty early and rough, but it's enough to starting playing
with.  The next step (for me :) is getting to where you can do actual
installs in a Xen guest environment and then being able to boot kernels
which are on the guest's filesystem.


[1] This is required because you actually boot the Xen hypervisor and it
then starts the Linux kernel.  It does this using the MultiBoot standard
[2] You can conceivably get by with less, but you'll have to reduce the
dom0_memory line in /boot/grub/grub.conf.  The 130000 for dom0 is
currently hard-coded by mkinitrd (will get fixed before too long) and
can go a little lower.  Also, the Xen hypervisor ends up requiring ~ 32
MB.  Plus any memory for your unprivileged guests.
[3] Note, you may need to disable rhgb and switch to using runlevel 3.
There are conflicting reports about X working; I haven't tried
[4] And /proc under it, since /proc has to get mounted for a lot of
things to get done right.  But yum figures that out 
[5] Substitute /boot/vmlinuz-2.6.10-1.1090_FC4xenU with the xenU kernel
you installed.  Additionally, the device sda1 listed here as the disk is
related to the /etc/fstab you created above

More information about the fedora-devel-list mailing list