Compiling Kernel 2.6.32

This document currently assumes you are using Fedora/RHEL/CentOS to do the compilation. For other distributions (ie. Ubuntu/Debian), you'll need to use the respective package management software to get the packages.
== Compiling the kernel from source - Getting ready ==
To actually build the kernel from source, you’ll need to download the compilers and such. To do so, run
# yum groupinstall "Development Libraries" "Development Tools"
# yum install transfig wget texi2html libaio-devel dev86 glibc-devel e2fsprogs-devel gitk mkinitrd iasl xz-devel bzip2-devel pciutils-libs pciutils-devel SDL-devel libX11-devel gtk2-devel 
==Getting the kernel source==
Download the kernel from xen.git and checkout the long-term maintained 2.6.32.x branch:
# git clone git://git.kernel.org/pub/scm/linux/kernel/git/jeremy/xen.git linux-2.6-xen
# cd linux-2.6-xen
# git checkout -b xen/stable-2.6.32.x origin/xen/stable-2.6.32.x
Note! If "git clone" fails, it's most probably caused by a network problem on your end. Some broken firewalls, nat-routers, and proxies cause problems with the git clone.
Example output from git:
[root@f13 kernel]# git clone git://git.kernel.org/pub/scm/linux/kernel/git/jeremy/xen.git linux-2.6-xen
Cloning into linux-2.6-xen...
remote: Counting objects: 1748126, done.
remote: Compressing objects: 100% (292844/292844), done.
Receiving objects: 100% (1748126/1748126), 359.40 MiB | 34.70 MiB/s, done.
remote: Total 1748126 (delta 1452892), reused 1733298 (delta 1439822)
Resolving deltas: 100% (1452892/1452892), done.
[root@f13 kernel]# cd linux-2.6-xen/
[root@f13 linux-2.6-xen]# git checkout -b xen/stable-2.6.32.x origin/xen/stable-2.6.32.x
Branch xen/stable-2.6.32.x set up to track remote branch xen/stable-2.6.32.x from origin.
Switched to a new branch 'xen/stable-2.6.32.x'
[root@f13 linux-2.6-xen]#
==Configure the kernel==
You can run make menuconfig, and go through the config file to manually activate the relevant Xen options. (Hint: Press the '/' key to bring up a search option, and search for 'xen'.
Alternatively, download a reference config-file for the 2.6.32.x kernel. Also run "oldconfig" to adapt the configuration to current kernel version (if it's different):
# wget -O .config http://pasik.reaktio.net/xen/pv_ops-dom0-debug/config-2.6.32.25-pvops-dom0-xen-stable-x86_64
# make oldconfig
Note the example config-file above is DEBUG-enabled possibly causing big performance hits, so don't use it for performance testing!
==Building the kernel==
Next, build the kernel. 
Note: Replace "4" in "-j4" by the number of physical CPU cores you have to speed up the compilation:
# make clean
# make -j4 bzImage && make -j4 modules
After successful compilation install the the kernel modules and the kernel itself. In this example we assume the kernel version is "2.6.32.25":
# make modules_install
# depmod -a 2.6.32.25
# cp -a arch/x86/boot/bzImage /boot/vmlinuz-2.6.32.25
# cp -a System.map /boot/System.map-2.6.32.25
# cp -a .config /boot/config-2.6.32.25
# cd /boot
# dracut initramfs-2.6.32.25.img 2.6.32.25
Don't worry about the warnings from dracut. Dracut might take a couple of minutes to execute. Example dracut output:
[root@f13 boot]# dracut initramfs-2.6.32.25.img 2.6.32.25
grep: /usr/share/plymouth/themes/.plymouth/.plymouth.plymouth: No such file or directory
The default plymouth plugin () doesn't exist
[root@f13 boot]#
Category:Users
Category:Developers
Category:Tutorial
Category:Xen