Installing Xen 3.3 With Kernel 2.6.27 On Ubuntu 8.10 (x86_64)

Want to support HowtoForge? Become a subscriber!
 
Submitted by falko (Contact Author) (Forums) on Sun, 2009-02-22 19:26. :: Ubuntu | Xen | Virtualization

Installing Xen 3.3 With Kernel 2.6.27 On Ubuntu 8.10 (x86_64)

Version 1.0
Author: Falko Timme <ft [at] falkotimme [dot] com>
Last edited 02/13/2009

This tutorial shows how you can install Xen 3.3 on an Ubuntu 8.10 host (dom0). Xen 3.3 is available from the Ubuntu 8.10 repositories, but the Ubuntu 8.10 kernels (2.6.27-x) are domU kernels, i.e., they work for Xen guests (domU), but not for the host (dom0). Therefore we need to build our own dom0 kernel. This guide explains how to do this with a 2.6.27 kernel.

I do not issue any guarantee that this will work for you!

 

1 Preliminary Note

I'm using an Ubuntu 8.10 x86_64 system with the hostname server1.example.com and the IP address 192.168.0.100 as the host system (dom0). I will use Debian Lenny for the virtual machines (domU).

This guide will explain how to set up image-based virtual machines and also LVM-based virtual machines.

I'm running all the steps in this tutorial with root privileges, so make sure you're logged in as root:

sudo su

 

2 Installing Xen

First upgrade your system...

apt-get upgrade

... and install the latest kernel from the Ubuntu repositories:

apt-get install linux-image-server linux-server

Next we install Xen 3.3 and the prerequisites for building our dom0 kernel:

apt-get install ubuntu-xen-server build-essential libncurses5-dev gawk mercurial

Now we download the sources of the 2.6.27 Xen kernel...

mkdir -p ~/build/linux-2.6.27-xen
cd /usr/src/
hg clone http://xenbits.xensource.com/ext/linux-2.6.27-xen.hg

... and configure the kernel:

cd linux-2.6.27-xen.hg
make O=~/build/linux-2.6.27-xen/ menuconfig

In the kernel configuration menu, make sure that you select the following options:

General setup ---> Choose SLAB allocator (SLUB (Unqueued Allocator)) ---> (X) SLAB

Processor type and features ---> Subarchitecture Type (PC-compatible) ---> (X) Enable Xen compatible kernel

Bus options (PCI etc.)  ---> [*] PCI support
                             [*]   Xen PCI Frontend
                             [ ]     Xen PCI Frontend Debugging (NEW)

Change <M> 802.1d Ethernet Bridging to <*> 802.1d Ethernet Bridging:

Networking support ---> Networking options ---> <*> 802.1d Ethernet Bridging

Disable 10000 Mbit Ethernet (otherwise the build process will most likely fail):

Device Drivers ---> [*] Network device support ---> [ ] Ethernet (10000 Mbit) --->

Make the Xen section look as follows (make sure you select Xen version compatibility (3.0.4 and later) instead of Xen version compatibility (3.0.2 and later)):

Device Drivers  ---> XEN  ---> [*] Privileged Guest (domain 0)
                               <*> Backend driver support (NEW)
                               <*>   Block-device backend driver (NEW)
                               <*>   Block-device tap backend driver (NEW)
                               <*>   Network-device backend driver (NEW)
                               (8)     Maximum simultaneous transmit requests (as a power of 2) (NEW)
                               [ ]     Pipelined transmitter (DANGEROUS) (NEW)
                               < >     Network-device loopback driver (NEW)
                               <*>   PCI-device backend driver (NEW)
                                       PCI Backend Mode (Virtual PCI)  --->
                               [ ]     PCI Backend Debugging (NEW)
                               < >   TPM-device backend driver (NEW)
                               <M>   SCSI backend driver (NEW)
                               <M> Block-device frontend driver
                               <M> Network-device frontend driver
                               <M>   Network-device frontend driver acceleration for Solarflare NICs (NEW)
                               <M> SCSI frontend driver (NEW)
                               <*> User-space granted page access driver (NEW)
                               <*> Framebuffer-device frontend driver (NEW)
                               <*>   Keyboard-device frontend driver (NEW)
                               [*] Disable serial port drivers (NEW)
                               <*> Export Xen attributes in sysfs (NEW)
                               (256) Number of guest devices (NEW)
                                   Xen version compatibility (3.0.4 and later)  --->

Afterwards we build and install the kernel as follows:

make O=~/build/linux-2.6.27-xen/
make O=~/build/linux-2.6.27-xen/ modules_install install

Now take a look at the /boot directory:

ls -l /boot/

root@server1:~# ls -l /boot
total 78364
-rw-r--r-- 1 root root   504280 2009-01-29 22:23 abi-2.6.27-11-server
-rw-r--r-- 1 root root   503560 2008-11-04 22:22 abi-2.6.27-7-server
-rw-r--r-- 1 root root    85313 2009-01-29 22:23 config-2.6.27-11-server
-rw-r--r-- 1 root root    87256 2009-02-12 20:51 config-2.6.27.5
-rw-r--r-- 1 root root    85319 2008-11-04 22:22 config-2.6.27-7-server
drwxr-xr-x 2 root root     4096 2009-02-12 22:28 grub
-rw-r--r-- 1 root root  8983433 2009-02-12 22:28 initrd.img-2.6.27-11-server
-rw-r--r-- 1 root root  8979323 2009-02-12 22:26 initrd.img-2.6.27-7-server
drwx------ 2 root root    16384 2009-02-12 19:30 lost+found
-rw-r--r-- 1 root root   124152 2008-09-11 22:11 memtest86+.bin
-rw-r--r-- 1 root root  1354638 2009-01-29 22:23 System.map-2.6.27-11-server
-rw-r--r-- 1 root root  1258568 2009-02-12 20:51 System.map-2.6.27.5
-rw-r--r-- 1 root root  1351952 2008-11-04 22:22 System.map-2.6.27-7-server
-rw-r--r-- 1 root root     1130 2009-01-29 22:27 vmcoreinfo-2.6.27-11-server
-rw-r--r-- 1 root root     1129 2008-11-04 22:25 vmcoreinfo-2.6.27-7-server
-rw-r--r-- 1 root root  2341536 2009-01-29 22:23 vmlinuz-2.6.27-11-server
-rw-r--r-- 1 root root  2192827 2009-02-12 20:51 vmlinuz-2.6.27.5
-rw-r--r-- 1 root root  2338976 2008-11-04 22:22 vmlinuz-2.6.27-7-server
-rw-r--r-- 1 root root   470144 2008-10-06 20:15 xen-3.3.gz
root@server1:~#

As you see, there's a new kernel, 2.6.27.5, but no ramdisk for it; therefore we build one...

depmod 2.6.27.5
update-initramfs -c -k 2.6.27.5

... and update our bootloader:

update-grub

Afterwards we open /etc/modules and make sure that we have the line loop max_loop=64 in it (this step is needed only if you want to create image-based virtual machines - you can skip it if you want to create LVM-based virtual machines):

vi /etc/modules

[...]
loop max_loop=64

Then reboot the system:

reboot

Run

uname -r

after the reboot and your new Xen kernel should show up:

root@server1:~# uname -r
2.6.27.5
root@server1:~#


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by Anonymous (not registered) on Wed, 2010-05-26 17:54.

I am having problem in this step "hg clone http://xenbits.xensource.com/ext/linux-2.6.27-xen.hg". I am behind proxy. I am getting error "destination directory: linux-2.6.27-xen.hg
abort: error: Connection timed out". Should i set http_proxy or anything else.

 Thank you.

Submitted by Taner (not registered) on Sat, 2009-07-25 08:42.

Hi,

I used your instruction  to install Xen 3.3 on top of my Ubuntu 9.04 Desktop amd64 (ext4). Unfortunately my Xen Kernel didn't boot up. There are the following errors.

Begin: Running /scripts/local-premount ...
19+0 records in
19+0 records out

kinit: name_to_dev_t(/dev/disk/by-uuid/874b696f-fd43-4c6d-9493-a8a01941bbc0) = dev(8,4)
kinit: trying to resume from /dev/disk/by-uuid/874b696f-fd43-4c6d-9493-a8a01941bbc0
kinit: No resume image, doing normal boot...
Done.
mount: mounting /dev/sda1 on /root failed: No such file or directory
Done.
mount: mounting /dev on /root/dev failed: No such file or directory
Done.
mount: mounting /sys on /root/sys failed: No such file or directory
mount: mounting /proc on /root/proc failed: No such file or directory
Target filesystem doesn't have /sbin/init.
No init found. Try passing init= bootarg.


Submitted by Detlef (not registered) on Thu, 2009-03-19 18:33.

I followed this very useful description and successfully made my new XEN kernel for amd_64. However after compilation the kernel didn't boot on my rented webserver. As I have no console access during the bootphase the cause was not directly visible.

When I compared the size of the /lib/modules directory and the original initrd files  I realized that it was probably due to missing drivers (raid support etc). So I modified the kernel generation by copying the original kernel config file 

cp /boot/config-2.6.27-11-server ~/build/linux-2.6.27-xen/.config

before running the menuconfig. So all the kernel setting were similar to the normal Ubuntu kernel and the similar modules were compiled and added. However with the default setting the created initrd was 50 Mbytes in size compared to the normal 9Mbytes.

This can be controlled by changing the /etc/initramfs-tools/initramfs.conf The change of

MODULES=most

to 

MODULES=dep

before creating the new initrd let the system only included the used modules in the initrd.

Here the size of my installation

ls -la /boot/*2.6.27.5* /boot/*2.6.27-11*

-rw-r--r-- 1 root root 1258976 Mar 19 14:47 /boot/System.map-2.6.27.5
-rw-r--r-- 1 root root   87245 Mar 19 14:47 /boot/config-2.6.27.5
-rw-r--r-- 1 root root 9208093 Mar 19 14:49 /boot/initrd.img-2.6.27.5
-rw-r--r-- 1 root root 2195195 Mar 19 14:47 /boot/vmlinuz-2.6.27.5

-rw-r--r-- 1 root root 1354638 Jan 29 21:23 /boot/System.map-2.6.27-11-server
-rw-r--r-- 1 root root  504280 Jan 29 21:23 /boot/abi-2.6.27-11-server
-rw-r--r-- 1 root root   85313 Jan 29 21:23 /boot/config-2.6.27-11-server
-rw-r--r-- 1 root root 8984287 Mar 19 07:45 /boot/initrd.img-2.6.27-11-server
-rw-r--r-- 1 root root    1130 Jan 29 21:27 /boot/vmcoreinfo-2.6.27-11-server
-rw-r--r-- 1 root root 2341536 Jan 29 21:23 /boot/vmlinuz-2.6.27-11-server

 

 

Submitted by Anonymous (not registered) on Mon, 2009-03-09 14:08.

I get an error when building the kernel :(

WARNING: modpost: Found 1 section mismatch(es).
To see full details build your kernel with:
'make CONFIG_DEBUG_SECTION_MISMATCH=y'
  GEN     .version
  CHK     include/linux/compile.h
  UPD     include/linux/compile.h
  CC      init/version.o
  LD      init/built-in.o
  LD      .tmp_vmlinux1
arch/x86/kernel/built-in.o: In function `timer_interrupt':
/usr/src/linux-2.6.27-xen.hg/arch/x86/kernel/time_32-xen.c:469:
undefined reference to `__udivdi3'
make: *** [.tmp_vmlinux1] Error 1

Submitted by amir (not registered) on Wed, 2009-11-18 10:53.
root@ubunzzo:/usr/src/linux-2.6.29.2-xen# vi /usr/src/linux-2.6.29.2-xen/arch/x86/kernel/time_32-xen.c

My attempt after reading reference (2) was successful, I inserted the asm(“”:”+r”(delta)) to the timer_interrupt function at the while scope at line number around 500.

        /* System-wide jiffy work. */
        if (delta >= NS_PER_TICK) {
                do_div(delta, NS_PER_TICK);
                processed_system_time += delta * NS_PER_TICK;
                while (delta > HZ) {

                        asm("":"+r"(delta));

                        do_timer(HZ);
                        delta -= HZ;
                }
                do_timer(delta);
        }

* This works because this asm fools gcc compiler not to use optimization.

source : http://mulps.wordpress.com/2009/05/29/compiling-xen-kernel-2-6-29-2/

Submitted by Tapas (not registered) on Mon, 2009-11-09 12:00.
I also had the same issue here is the solution some one from community helped
Submitted by Anonymous (not registered) on Wed, 2009-03-11 13:41.

you need to use older (e.g. gcc-4.2) 

if it is possible dont use Ubuntu 8.10 as system where you would be compile xen kernel 

Submitted by Wodin (not registered) on Mon, 2009-03-02 20:20.
No need for "sudo su" when "sudo -i" will do.
Submitted by Ranjan (not registered) on Mon, 2010-04-05 18:08.

Hi, I am able to compile successfully but when I do an ls -l I can't see an entry like the one below which means that for some reason this has not been downloaded into /boot. As such I can't boot into any kernel since this has to be loaded first.

-rw-r--r-- 1 root root 470144 2008-10-06 20:15 xen-3.3.gz

 

Has anyone faced this problem ?

Thanks

Ranjan