Monday, December 6, 2010

Installing Xen 4.0.1 and testing on Ubuntu 10.04

Several of my colleagues have recently had a great time trying to install Xen on Ubuntu. I've seen various locations where the task has been partially done, but the authors always leave something missing. I guess in their cases, the goal is to get their job done and not make a very generic tutorial. The goal of this tutorial is to be generic, so that the process can be repeated easily without going having to return to google to figure out what the contents of this tutorial are expressing.

So here's a rough outline:

Install or having a working Ubuntu 10.04. If you are doing a fresh install, I recommend using ext3 on your hard disks otherwise you'll have to reconfigure the Xen-Linux kernel.

Install the necessary utilities to download, compile, and install Xen:apt-get install bcc bin86 gawk bridge-utils iproute libcurl3 libcurl4-openssl-dev bzip2 module-init-tools transfig tgif texinfo texlive-latex-base texlive-latex-recommended texlive-fonts-extra texlive-fonts-recommended pciutils-dev mercurial build-essential make gcc libc6-dev zlib1g-dev python python-dev python-twisted libncurses5-dev patch libvncserver-dev libsdl-dev libjpeg62-dev iasl libbz2-dev e2fslibs-dev git-core uuid-dev ocaml libx11-dev

If you are using 32-bit install libc6-xen (This will get rid of the annoying TLS segmentation message): apt-get install libc6-xen

If you are using 64-bit install 32-bit utils: apt-get install gcc-multilib

Download Xen, either get the Xen 4.0.1 source or get testing. If you want the 4.0.1 source, its faster to download the tar.gz than the entire mecurial repository!

4.0.1 source: wget http://bits.xensource.com/oss-xen/release/4.0.1/xen-4.0.1.tar.gz

Testing source: hg clone http://xenbits.xen.org/xen-4.0-testing.hg

Build Xen, this includes building all tools but not the Xen-Linux Kernel:
cd into the Xen dir
make xen
make tools
make stubdom
make install-xen
make install-tools PYTHON_PREFIX_ARG=
make install-stubdom

Build the Xen-Linux Kernel (if you need to configure the kernel see the bottom of this post):

make prep-kernels
Optionally configure the kernel especially if you are using ext4 (see below)
make kernels
make install-kernels

Figure out kernel version by looking at the .config file in the kernel build path (typically starts with: build-linux-2.6-pvops_), so typing "head build-linux-2.6-pvops_x86_32/.config" in 32-bit case will print out the "Linux kernel version" near the top (the current version is 2.6.32.26)

update-initramfs -c -k [kernel version]

Making Xend auto-start:

update-rc.d xend defaults 20 21

Update Grub

Place this in /etc/grub/40_custom:

menuentry "Xen-Testing - Linux 2.6.32.26" {
insmod ext2
set root="(hd0,1)"
multiboot /boot/xen.gz dom0_mem=256M
module /boot/vmlinuz-2.6.32.26 ro nomodeset root=UUID=24aece87-9b12-4966-8c04-4bd59d5808ae
module /boot/initrd.img-2.6.32.26
}
Note: you can obtain your disks partition (hd0,1) by running blkid on the device, the default device will usually be /dev/sda1 (e.g., blkid /dev/sda1). Also feel free to adjust dom0_mem

Finally update grub:
update-grub

Reboot into Xen. While testing you should leave the default boot into your regular kernel. Hold shift during reboot to access a grub menu and select Xen. Determine which grub entry Xen, hint, they are incremented in order from 0 to N. In my case, it was 6, so edit the /etc/default/grub and replace 0 with 6 on the line "GRUB_DEFAULT". The next step is to create a domU!

11 comments:

  1. By The way, you can use 'blkid' to get device UUIDs instead of looking into your grub.cfg

    ReplyDelete
  2. Yogesh : hi
    I have follow all steps but I cant found any xen.gz file in /boot directory
    please Can you give any suggestion over this?
    thanking in anticipation

    ReplyDelete
  3. Thanks Timo, great point, I'll fix that.

    Yogesh, did you miss the "make install-xen" That should cover your issue. Are there any xen* files in /boot?

    ReplyDelete
  4. Hi.
    Great tutorial by the way.
    I followed your tutorial exactly.
    But I cannot boot into the Xen-kernel.
    Is this because of wrong configuration in the .config file??
    Can you please post how to configure the .config to enable the ext4 support?
    Please help.

    ReplyDelete
  5. Ram, the easiest way to do this is after make prep-kernels, cd into the build dir (build-linux-2.6-pvops_x86_32) and type make menuconfig. Enable ext4 from the file systems menu. There are a plethora of tutorials for make menuconfig if you run into any problems.

    ReplyDelete
  6. Hi David

    Nice blog.


    While executing make xen installation i am getting the following:
    grant_table.c:733:22: error: variable ‘old_pin’ set but not used [-Werror=unused-but-set-variable]
    cc1: all warnings being treated as errors
    make[4]: *** [grant_table.o] Error 1
    make[4]: Leaving directory `/root/xen-4.0.1/xen/common'
    make[3]: *** [/root/xen-4.0.1/xen/common/built_in.o] Error 2
    make[3]: Leaving directory `/root/xen-4.0.1/xen/arch/x86'
    make[2]: *** [/root/xen-4.0.1/xen/xen] Error 2
    make[2]: Leaving directory `/root/xen-4.0.1/xen'
    make[1]: *** [install] Error 2
    make[1]: Leaving directory `/root/xen-4.0.1/xen'
    make: *** [install-xen] Error 2

    Please look into this. I have searched around on google, couple of more people got this error, but the resolution was not given anywhere.
    Kindly suggest.

    Many Thanks

    ReplyDelete
  7. You should carefully examine errors. This is a rather trivial compiler error that says in your makefile you've specified -Werror. Unset that and you should be good to go.

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. Hello David,

    I am just posting to say thanks for this awesome tutorial !

    It was the only one helping me finally install XEN on ubuntu 10.04... !! but when i boot on it ( holding shift and choosing it ) I get some messages (no errors) and then a black screen and nothing happens.. :/ Am i missing something ? i am totally new into this.

    Many thanks again ..

    ReplyDelete
  10. Unfortunately I haven't played with Xen in years and your computer's output isn't very helpful. If the computer isn't panicing and rebooting, I'm not sure I can offer you much advice. I would try using a virtual machine and see if you can succeed there. Also I would hope that you can find a modern distribution that works well with Xen, 10.04 is nearly 5 years old :).

    ReplyDelete
  11. I managed to boot and make it work :-) but not with 10.04 with 12.04! Indeed 10.04 were way too old . .

    Thanks again !

    ReplyDelete