2010/06/11

[FAST] [XUNXO] Compiling custom kernels in Ubuntu

Sometimes you need to compile a custom kernel, but would like to install/uninstall it in a civilized manner, using packages. There goes a fast recipe for that:

cd /usr/src/my-linux
cp /boot/config-2.6.xx .config # or for somewhere else
make oldconfig
make menuconfig
make-kpkg clean
fakeroot make-kpkg --initrd kernel_image kernel_headers
cd ..
ls *.deb

Some small problems with this recipe:

Autogenerated headers bug (<= Jaunty)


edit /usr/share/kernel-package/ruleset/misc/version_vars.mk

Look for UTS_RELEASE_HEADER=$(...) and replace by

UTS_RELEASE_HEADER=$(call doit,if [ -f include/generated/utsrelease.h ]; then \
echo include/generated/utsrelease.h; \
else \
echo include/generated/utsrelease.h ; \
fi)

The change is: replace include/linux/ by include/generated/, and replace version.h by utsrelease.h.

kernel-headers contents


The build process does not copy autogenerated include/generated/*.h files to include/linux.

This is a only a problem if you want to compile e.g. VMWare Tools or a non-free driver. Solution is simple (and dirty):

cd /usr/src/linux-headers-2.6.xx-yy
cp include/generated/*.h include/linux/

Not creating initrd image at postinstall (Lucid)


Automatic creation of /boot/initrd- image works well in Jaunty but not in Lucid. Symptom is a kernel panic in very early stage of boot.

The solution is create initrd manually right after kernel package install:

update-initramfs -c -k 2.6.xx-yy
update-grub

Bonus: Grub configs that you may want to change


File: /etc/default/grub

comment the *HIDDEN* lines to have a menu at boot. I like to add

GRUB_SAVEDEFAULT=true

so the last chosen kernel becomes the default.
blog comments powered by Disqus