Uncategorized

Building Xen from source on Ubuntu 8.04

After struggling with XEN‘s source for around two weeks, I’ve finally managed to get it working on a Ubuntu 8.04. It was fairly straight forward with a few bits and pieces of trouble. That is mainly due to the problems of incompatibility between different versions of the hypervisor and dom0 kernels.

So, here’s how I did it. This is more for archiving purposes than for teaching. So, use whatever you can. Post any queries and I’ll see if I can help.

First, though, you need to get the prerequisites installed on your system.  I had a lot of trouble with the compilation because xen build scripts don’t check for prereqs before starting. It kept stopping in the middle of the build because of missing packages. So, here’s the complete list of all the packages you need for building this version of xen. Just execute:

# sudo apt-get install build-essential mercurial gawk zlib1g-dev libzzip-dev libcurl4-openssl-dev xorg-dev gettext libncurses5-dev python2.5-dev texinfo texlive-latex-base texlive-latex-recommended texlive-fonts-extra texlive-fonts-recommended transfig bridge-utils uuid-dev

Xen also requires Dev86. Get that from here (You only need the binary, not the source. I got Dev86bin-0.16.17.tar.gz) Copy the .tar.gz file to / — your filesystem root and extract it.

Now, get the xen-unstable source. In my case, this was xen-4.0.0-rc3.

# hg clone http://xenbits.xensource.com/xen-unstable.hg

That might take just a little while. This only gets the hypervisor source. The dom0 kernel source will be downloaded by the build script. Start the building process:

# make world

In the future, if you wish to rebuild the code without losing all the configuration change, just make dist .

This builds the hypervisor, downloads the associated dom0 kernel source (which might take a lot of time), builds xen-tools and other smaller packages. Install the whole thing using:


# ./install.sh

After all that, you should have xen.gz and the kernel (which in my case was 2.6.31.6) in the /boot directory.

It’s a good idea to create an initrd image. To do so, execute the following two commands:


# depmod -a 2.6.31.6
# update-initramfs -c -k 2.6.31.6

You now need to add the following directives to /boot/grub/menu.lst to enable booting into xen:


title Xen 4.0 w/ Linux 2.6.31.6
root (hd0,1)
kernel /boot/xen.gz dom0_mem=524288
module /boot/vmlinuz-2.6.31.6 root=/dev/hda1 ro
module /boot/initrd.img-2.6.31.6

Where /dev/hda1 is your linux partition. (You can get that from sudo fdisk -l.)

Reboot and you should be in Xen. Start the Xen daemon and take a look at your brand new dom0.


# /etc/init.d/xend start
# xm list

Next tutorial on how to create a domU and then move on to more exciting stuff such as DRTM!

Advertisements

25 thoughts on “Building Xen from source on Ubuntu 8.04”

  1. This is fairly simple. I had a tough time with the compatibility of dom0 kernel. By the way isn’t the hypervisor dom0 kernel? Haven’t read most of the theory but I thought dom0 was for hypervisor and it’s management and the other dom’s were for usual VMs.

    Take care.

  2. The hypervisor runs in RING 0, dom0 is the management domain that is a proper operation system (with XEN compatibility). Dom0 kernel runs in RING 1. So do domUs.

  3. why not use xen package for ubuntu . you’d only have to do apt-get to install xen on your machine…

  4. Because you wouldn’t be able to modify Xen source according to your needs. If you just need to use Xen, then yes, apt-get is the way to go.

  5. Prakash… keep trying. We had the same problem with many many repos. Try using a fast internet connection that is stable. I’m not sure what the problem here is but I’m sure that it will go away after a few tries.

  6. Thank u for this fast reply.
    I tried thrice. It gave same error with varying bytes. At last try it failed after getting 5200 odd bytes.
    Ok.. will try and report with whatever yields..

  7. One more thing,
    in the packages to be installed (first step) u have listed a package zliblg-dev, instead its zlib1g-dev (1 not l)
    Took a quite time to figure what the error was..

  8. Pertaining to previous,fonts of
    both l (j k l) and 1 (one) appear the same.
    May be my misconception too.

  9. I could not succeed with many tries.
    Does it matter with wired or wireless connection?
    If there is any other alternate then do suggest. Can i download the source from xen and continue with the build?

  10. If i can download and use from xen source the latest version, is there any specific directory that it has to be placed before starting the build?
    like tmp or var/tmp or desktop etc.
    Do suggest.

  11. Prakash: First of all, thanks for the correction. I got the package name wrong. I’ve corrected it now.

    I’m not sure you should be having this trouble for so long. I’m not very comfortable with mercurial (having worked with Git for a long time). Let me boot into my linux machine and see if I can reproduce the efforts. In the meanwhile, how about mailing the problem to the Xen community list?

  12. I just cloned without any error. What version of mercurial (and Linux) are you using? There must be some compatibility issue.

  13. Thank u for the suggestions. Am not a very regular linux user. am getting into it these days and wanna continue.
    i had used subversion earlier. nt familiar with git or hg. only came to knw after this.

    i stay in college hostel. we have some restrictions. may me i will talk to admin once. that could be a problem.

  14. For getting linux version is it not uname command? how to know mercurial version?

    if i download 3.4.2, should i unzip it in any specific directory and start the build?

  15. Thanks a lot for all the help.. we are stuck in project from past many days.. and hope i will be able to set up xen sooner times..

  16. I downloaded xen unstable from xen site. it was version 3.0
    when i did make world,
    i got following error.

    /xen-unstable/xen/common/built_in.o: In function `do_domctl’:
    /xen-unstable/xen/common/domctl.c:656: undefined reference to `__stack_chk_fail’
    /xen-unstable/xen/common/built_in.o: In function `cmdline_parse’:
    /xen-unstable/xen/common/kernel.c:84: undefined reference to `__stack_chk_fail’
    /xen-unstable/xen/common/built_in.o: In function `do_xen_version’:
    /xen-unstable/xen/common/kernel.c:230: undefined reference to `__stack_chk_fail’
    /xen-unstable/xen/common/built_in.o: In function `dump_domains’:
    /xen-unstable/xen/common/keyhandler.c:189: undefined reference to `__stack_chk_fail’
    /xen-unstable/xen/common/built_in.o: In function `__print_symbol’:
    /xen-unstable/xen/common/symbols.c:158: undefined reference to `__stack_chk_fail’
    /xen-unstable/xen/common/built_in.o:/xen-unstable/xen/common/sysctl.c:142: more undefined references to `__stack_chk_fail’ follow
    make[4]: *** [/xen-unstable/xen/xen-syms] Error 1
    make[4]: Leaving directory `/xen-unstable/xen/arch/x86′
    make[3]: *** [/xen-unstable/xen/xen] Error 2
    make[3]: Leaving directory `/xen-unstable/xen’
    make[2]: *** [install] Error 2
    make[2]: Leaving directory `/xen-unstable/xen’
    make[1]: *** [install-xen] Error 2
    make[1]: Leaving directory `/xen-unstable’
    make: *** [world] Error 2

    can u suggest what could be the reason for this?

  17. I solved that error..
    But after an hour of compilation some more new errors showed up.. will post if i wont be able to debug..
    😦

  18. I could not debug this error..
    Any help??

    make[4]: Entering directory `/xen-unstable/linux-2.6.16.29-xen’
    Makefile:344: *** commands commence before first target. Stop.
    make[4]: Leaving directory `/xen-unstable/linux-2.6.16.29-xen’
    make[3]: *** [linux-2.6.16.29-xen/include/linux/autoconf.h] Error 2
    make[3]: Leaving directory `/xen-unstable’
    make[2]: *** [linux-2.6-xen-install] Error 2
    make[2]: Leaving directory `/xen-unstable’
    make[1]: *** [install-kernels] Error 1
    make[1]: Leaving directory `/xen-unstable’
    make: *** [world] Error 2

  19. AoA.

    I wanted to test a Xen based setup for Eucalyptus. Can you give some tips on the exact versions you built because it is difficult to find working Xen based packages and kernels for Ubuntu. With Fedora things are much better for Xen. Although Fedora is also throwing out Xen for KVM.

    Thanks.

  20. Thanks for this how to; appreciate your effort.
    I need to compile Xen for Kemari following this (http://www.osrg.net/kemari/usage.html) along with your post. However, I got this error in make:

    cc1: warnings being treated as errors
    symbols.c: In function ‘read_symbol’:
    symbols.c:84:9: error: ignoring return value of ‘fgets’, declared with attribute warn_unused_result
    make[5]: *** [symbols] Error 1

    It could be that I am using xen-3.3-testing.hg, or the fact that I am on Ubuntu 11.04 ; or that I am using Python3.2-dev instead python2.5-dev since the later is not available in repository anymore.

    I wonder if you faced any such problem?

    Best Regards;
    Shahzad

  21. Thanks for this how to; appreciate your effort.
    I need to compile Xen for Kemari following this (http://www.osrg.net/kemari/usage.html) along with your post. However, I got this error in make:

    cc1: warnings being treated as errors
    symbols.c: In function ‘read_symbol’:
    symbols.c:84:9: error: ignoring return value of ‘fgets’, declared with attribute warn_unused_result
    make[5]: *** [symbols] Error 1

    It could be that I am using xen-3.3-testing.hg, or the fact that I am on Ubuntu 11.04 ; or that I am using Python3.2-dev instead python2.5-dev since the later is not available in repository anymore.

    I wonder if you faced any such problem?

    Best Regards;
    Shahzad

Comments are closed.