Ubuntu 9.10 domU on CentOS 5.4 Dom0 using debootstrap

Essentially, create LVs and format them (look at the previous posts for the how to), and have debootstrap installed on the CentOS host.

Mount the LV in which you’re going to install Ubuntu on by running mount <LV location> <mount location>. I did mount /dev/domU/ubuntu /mnt/ubuntu.

The command to run is debootstrap --arch ARCH karmic <mount location of LV> <mirror to download from>. For me, this should be debootstrap --arch i386 --include=linux-image-virtual,libc6-xen,grub --components=main,universe,multiverse karmic /mnt/ubuntu http://sg.archive.ubuntu.com/ because my local mirror (by local, I mean Singapore) is sg.archive.ubuntu.com. (Note: Don’t use the ‘release’ mirrors – they won’t work.)

Create a Xen enabled kernel – download the kernel source from the Ubuntu repos and set it up for Xen. (See below for the current steps.)

Kill the hardware clock, apparently it causes the domU to lock up – update-rc.d -f hwclockfirst remove && update-rc.d -f hwclock remove
Add a user – adduser myusername
Create an admin group if you want – addgroup --system admin && adduser myusername admin – this doesn’t add you to the sudoers file though. Still have to add yourself manually. I just added my user account to the sudo usergroup, and allowed the sudo group to run all commands with sudo. (From the chroot environment, run visudo.)

Modify /boot/grub/menu.lst and change the “indomU” to “true”. (Also, enable memtest as a boot option if you want, but it’s not much use in a domU system.)

Then, run update-grub to update the bootloader to use the Xen-enabled kernel.

ALSO: The Xen domU configuration file needs to be changed – this will store the MAC address of the network interface, script used to create the interface, and the bridge to which the interface will be joined As well as all the memory sizes and what not.

Find the version of the kernel source in the apt repo. Using the “$(uname -r)” trick doesn’t work because we’re in a chrooted environment.apt-cache search linux-image
In my case, it was linux-image-2.6.31-14. So,apt-get build-dep --no-install-recommends linux-image-2.6.31-14-virtual
mkdir kernel && cd kernel && apt-get source linux-image-2.6.31-14-virtual
apt-get install libncurses5-dev
cd linux-2.6.31
make menuconfig
Go to Processor type and features -> High Memory Support and change it to something other than 4GB. (The xen option won’t appear till you do so.)
Then, go back to Paravirtualised Guest Support and enable Xen support.
Now, just keep searching for Xen options (Hint: Hit ‘/’ and type ‘xen’) and enabling all of them. Also, you can probably disable stuff that you don’t need and set the processor architecture too, while you’re at it.
As a note, for some strange reason, Xen doesn’t show up under the Virtualization sub menu in the root menu. My guess is that the Virtualization menu refers to stuff that the OS will virtualize, as in the newly created kernel will be the dom0. Ubuntu doesn’t support this in its sources, so makes sense that it’s not included.

Once the config’s finished, run make-kpkg clean
If you have a multi-core system, run export CONCURRENCY_LEVEL=(1+number of cores) I have a 4 core system (dual dual core P4 era Xeons), so I ran export CONCURRENCY_LEVEL=5
Finally, create the kernel. fakeroot make-kpkg --initrd --append-to-version=-xen-p4xeon kernel-image kernel-headers
Once the packages are created, do dpkg -i ../*.deb

I tried to setup this for a long time. I “guessed” all the steps (including the XEN console…) but I can’t compile kernel to run as a domU, so if it’s possible, please submit you guide for kernel compilation – thanks!