Friday, December 4, 2009

Experimental Xen and Ubuntu. Part 2: hypervisor

This is second part of a two-part HOWTO. See Experimental Xen and Ubuntu. Part 1: kernel.

In this part we're going to compile the hypervisor and tools. You can install Ubuntu-provided binaries if you're happy with an older version. In that case, jump to Grub2 configuration. I'll again assume your compilation directory is ~/src.

Warning: You're about to install an experimental software. It might not work. The instructions might be outdated. In fact, I wrote this Howto over the course of 3 days and I had to update them. Use at your own risk.


0. Prerequisites

You'll need:
  • An hour or two
  • Some more development tools and libraries in addition to what you've already installed in part 1


    aptitude install mercurial xorg-dev python-dev zlib1g-dev python-openssl python-pam libssl-dev uuid-dev bcc bison flex checkinstall
    



1. Get ACPICA

You'll need one more tool: Intel's ACPI Component Architecture compiler. It's not in the distribution. Download it from http://acpica.org/downloads/ to ~/src, then:
cd ~/src
tar -xvzf acpica-unix*.tar.gz
cd acpica*/compiler
make
sudo chown root.root iasl
sudo mv iasl /usr/local/bin
There's no "make install", so you need to use last two lines to put the binary in place.


2. Get the sources

Download latest Xen from repository into your compilation directory.
hg clone http://xenbits.xensource.com/xen-unstable.hg
To update the sources later, use:
cd ~/src/xen-unstable.hg
hg pull
hg update



3. Compile hypervisor and tools

cd xen-unstable.hg
make xen
make tools
Do not use "make all" or you'll also get another kernel and docs (which require TeX and take ages to compile).

4. Create packages

Now you're supposed to to type "make install". That would put the compiled files into right places, but without any traces in your package system and without easy way to uninstall. There's a "make uninstall" target, but not guaranteed to work. So I decided to make a primitive .deb with checkinstall. It won't have all the features of a real deb package: proper dependency information, pre/post install scripts etc. But it works.
sudo checkinstall make install-xen
sudo checkinstall make install-tools
Checkinstall will ask you a few questions. Set version number to 3.5 (anything numeric will do, but autodetected unstable.hg won't). Set the package name and "provides" to "xen-hypervisor" for the first package, "xen-utils" (not xen-tools!) for the second.


5. Install packages

cd ~/src/xen-unstable.hg
sudo dpkg -i xen-* system_1-2_all.deb 

6. Update your Grub2 configuration

You'll need to boot Xen instead of Linux. Our primitive package won't modify Grub2 configuration. Create file /etc/grub.d/08_xen, make it executable and insert the following contents:
#!/bin/sh 

cat << EOF 
menuentry "Xen 3.5 / Ubuntu, 2.6.31.6-xen1" { 
    insmod ext2 
    set root=(hd0,1) 
    multiboot /boot/xen-3.5.gz 
    module /boot/vmlinuz-2.6.31.6-xen1 dummy=dummy dom0_mem=1024M root=/dev/sda1 ro 
    module /boot/initrd.img-2.6.31.6-xen1 
} 

EOF

Substitute root=(hd0,1) and root=/dev/sda1 with the right information (get one from /boot/grub/grub.cfg). Provide the right path for the Xen kernel you compiled with the previous Howto. Note the argument "dummy=dummy" for the Linux kernel - it's needed because some versions of Grub2 swallow the first argument. Command "insmod ext2" is also correct for ext3 and ext4.
You should also change /etc/default/grub and comment the lines starting with GRUB_HIDDEN_TIMEOUT. It'll make Grub2 display menu and wait for a few seconds. This way, it'll be easier to select another entry if the default won't boot. When you're ready, run:
update-grub

7. Run Xen daemon at boot

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

Troubleshooting

Unfortunately, chances of getting an unbootable system are high. My advice is to narrow down the problem. Try installing the Ubuntu-provided hypervisor or another kernel. Try updating and compiling again the kernel or Xen, new changes are commited every day. Search Xen mailing lists.

0 komentarze:

Post a Comment