Building Xen-3.4 testing and linux-2.6.31.10 domain0 kernel on Debian-testing
This is a howto on compiling and installing Xen 3.4 testing from the repository and linux kernel 2.6.31.10 for a Debian squeeze domain0.
Note: Try and do everything as root. If you do a make and then make install with different users, it will completely recompile over again.
Now even though linux-2.6.18-xen is the proper kernel to be using for a Xen domain0, the new version of udev in all the usable distros do not support the older kernels (anything before 2.6.25 I believe). So I will be using the 2.6.31.10 kernel along with the gentoo Xen patches. Lets see how this goes.
Getting the source:
Install Mercurial
Get the Xen Source
Get the Xen domain0 Linux kernel source and the patches from here and here respectively:
Now unpack them with
Apply the patches
Now you probably want to rename your kernel to indicate is has been patched. You can also modify the "Extra version" variable in make menuconfig later on if you want the kernel to have a different name to show up with 'uname'.
Get Dependencies:
There are quite a lot of dependencies. Too many to list individually, but here's how to install them all:
Grab a coffee...
Compiling:
Enter the Xen source directory
Cross your fingers and start compiling
Or if you have a fast machine with lots of cores, use the -j switch. Usually you use the number of cores you have plus 2.
This will take a long time...grab another coffee, If the build fails anywhere I may have missed a dependency. Its usually pretty obvious what the dependency is by the build error message. Just go install it and try again.
Xen is hopefully compiled so we can take care of the kernel. Onward with our linux-2.6.31.10-xen kernel.
You need to enable Xen Support (under processor type and features) as well as Priviledged Domain (under device drivers->Xen) and I also set Xen compatibility to 3.3.0 and above (under device drivers->Xen->Xen Version compatibility). Once you've enabled everything you think you'll need, start compiling.
Once its done without errors, go ahead and install it, but do not use the -j option for the install.
Also you need to install the modules
Once that is done, look in the /boot directory
You should see some files: xen-3.4.3-rc3-pre.gz and vmlinuz-2.6.31.10. If not, you need to go back and deal with the problem because nothing will work past this point.
Also check the /lib/modules directory for a directory called 2.6.31.10
Generate an initrd image:
So you've got Xen and the linux kernel compiled, now you need an initrd image to go along with the kernel. Enter the /boot directory:
Setup the dependencies for the initrd image:
Now generate an initrd image using the mkinitramfs command
There should now be a file called initrd.img-xen in /boot
Grub2:
This can be a bit of a pain because of grub2 being rather....Beta, but we cant let that stop us. (If you have grub legacy, look here)
Make sure you have a livecd available in case you make a mistake with the config file formatting and grub fails. Now open the grub config file using your favorite editor (which is probably vim because otherwise your insane) like this
Scoll down to where you see the menuentries. Add your own entry with something like this.
You may notice a few things different. You need to use multiboot and modules to pass Xen, the kernel and your initrd img into grub2. Also you may notice the parameter dummy=dummy going into the kernel, this is because at the time of writing this, there is a bug in grub2 which causes the first parameter not to be passed into the kernel. So we can create a useless one as the first parameter. That way when they fix the bug nothing horrible will happen to our bootup. Also you may not want to put your new entry at the top until you are sure everything works because grub defaults to the top entry.
Booting:
Cross your fingers and reboot! Hold shift to get grub to show you a list if it doesnt by default. If it boots congratulations.
Testing a guest domain:
Now you probably want to setup a Virtual Machine to test your setup. http://stacklet.com/ has some pre-build appliance images you can grab and test with. Check out this post for more info on starting a virtual machine.