Building a Debian Kernel with OpenVZ

There was an entry about vswap in the OpenVZ blogs and i love that new feature. So i decided to build my own kernel in debian with those patches to get that functionality. Continue to read if you’re interested in VSWAP and how to setup your kernel to make use of it.


As always you’re doing everything here at your own risk. You’ve been warned.

Links:

  1. 042test002.1 kernel is based on final RHEL6 and contains VSwap.
  2. news from the VSwap front
  3. Development OpenVZ Kernel branch RHEL6

first go to /usr/src then grab the kernel source you want to use, in my example:

wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.32.tar.bz2

Now grab the openvz patchset you want to use, in my example:

wget http://download.openvz.org/kernel/branches/rhel6-2.6.32/042test008.1/patches/patch-042test008.1-combined.gz

now get the openvz config by issuing:

wget http://download.openvz.org/kernel/branches/rhel6-2.6.32/042test008.1/configs/config-2.6.32-042test008.1.x86_64

and let’s start. First unpack the kernel source and unpack the patch, then switch into the dir, patch the kernel and get the config.

tar -xjvf linux-2.6.32.tar.bz2
gunzip patch-042test008.1-combined.gz
cd linux-2.6.32
patch -Np1 < ../patch-042test008.1-combined
cp ../config-2.6.32-042test008.1.x86_64 .config

Fine - Now issue make menuconfig and configure stuff you need. You might want to compare the current kernel configuration with the one you got. You can do so using diff. For example:

zcat /proc/config.gz > currentkernelconfig.txt
diff config-2.6.32-042test008.1.x86_64 currentkernelconfig.txt

If /proc/config.gz is not there, you can look for the current config in /boot/. Finished with make menuconfig? So save config and exit. Now you can do:

make-kpkg clean
fakeroot make-kpkg --initrd --revision=custom.1.0 kernel_image

if you see any error, issue make clean and repeat the above steps starting with make menuconfig. Really make sure that you dont have any errors - Most likely you did something wrong with make menuconfig. for example i got an error if i use slub instead of slab. if you just copy over your current config this shouldnt happen. Another hint: if you just use ext3/ext4 you might want to enable it, instead of taking it as a module - That'll solve a lot of initrd related problems (if you got
some, which shouldnt happen)

Now after your compile is done and package was created, let's install it:

dpkg -i kernel_image-2.6.32_custom.1.0_x86_64.deb

All fine? that was it. Maybe issue grub-install /dev/sda but that shouldn't be needed. Reboot, and check whether everything works.

No Comments

Post a Comment