Philips Linux Kernel HowTo

Get the latest Linux Kernel!

As I could not find an easy Kernel-Update-How To and rarely information how to patch a Linux Kernel, not even on kernel.org, I wrote my own. (All below is just a proposal from me, there may be many different ways to do it. If you use this way, note, this is all without guarantee, and blame not me if your system no longer boots or data got lost.) So here is now a little HowTo which might help you to upgrade and patch the Linux Kernel, when you start from begin on. The below example is tested with Debian 6.0.0 amd64, installed from DVD. (necessary tools like gcc and make might not be on the Live-CD): First Download the latest (Full Source) Kernel from http://www.kernel.org/ (e.g. mainline: 2.6.38-rc8 from 2011-03-08; file: linux-2.6.38-rc8.tar.bz2) and if you really want the very latest, additionally the latest patch (e.g. linux-next: next-20110310; file: patch-v2.6.38-rc8-next-20110310.bz2). Note, the name of the patch should match to the downloaded kernel. Copy as superuser (root) both, the kernel sources and the patch, to /usr/src and go to this location for further steps. (extract the kernel, make a symbolic link, test and apply the patch as shown below)

cd /usr/src
tar xfv linux-2.6.38-rc8.tar.bz2
ln -s linux-2.6.38-rc8 linux
ls -l
mv patch-v2.6.38-rc8-next-20110310.bz2 linux
cd linux

Patching the Kernel

Now you should be in the directory /usr/src/linux-2.6.38-rc8, this you can check with pwd -P (the option -P means physical and avoids displaying symbolic links). It is recommended to test the patch first with a dry-run. When there occur a lot of errors it could be help to change the -p1 into -p0 or -p2. If this does not help, verify that you not have wrong patch or kernel.

pwd -P
bzip2 -d patch-v2.6.38-rc8-next-20110310.bz2
patch -p1 --dry-run < patch-v2.6.38-rc8-next-20110310
patch -p1 < patch-v2.6.38-rc8-next-20110310
If the patch was successful and you want it absolutely tidy, you can rename (mv) the kernel source path correctly and update the symbolic link /usr/src/linux (f forces here to overwrite the existing link).
cd ..
mv linux-2.6.38-rc8 linux-2.6.38-rc8-next-20110310
ln -sf linux-2.6.38-rc8-next-20110310 linux
cd linux

Configure and Compile the Kernel

Now you can begin to compile the newly patched kernel. Before it should be configured. A good starting-point is to use the old-config, which is about how your current kernel is running. It will ask you usually a lot of questions about new features; with you can chose the default proposal. After that you can make menue-config to make your special settings, or edit directly the .config file. (For menueconfig you might need to install ncurses (libncurses5-dev); this can be done via Synaptic.) To finally compile it, just execute make all. (-j is to set the numbers of simultaneous jobs. Especially if your Linux runs on more CPU cores this makes sense. For a dual-core CPU -j5 is a good value.)

make oldconfig
make menuconfig
make -j5 all

Now the hardest work for your computer is done! But the new kernel is still not ready to use. You need to install the new modules, update the initial ramdisk, and add the new things into your boot-loader configuration. If you use grup, the last can easily be done with grub-update (grub-update is just a stub for grub-mkconfig -o /boot/grub/grub.cfg to create a grub2 config file). (Or you can edit /boot/grub/grub.cfg (on older distributions before grub2 this is /boot/grub/menu.lst) with your favorite editor. (it's vi?)) If you want for any case repeat the below steps, make clean should be done before (it removes not the .config).

make modules_install
make install
update-initramfs -c -k 2.6.38-rc8-next-20110310
grub-update
Congratulations you are ready to use the latest Kernel! See yourself after a reboot...
shutdown -r now
uname -r

Stay up to date

When there comes after a while a new patch, e.g. the patch-v2.6.38-rc8-next-20110311, you have following options to use it. First assuming you have already patched your kernel with a older patch. Then you can with the parameter -R (--reverse) clean up the sources prior using the new patch. Hope you still have the old patch. Then rename the source directory and update the symbolic link.

cd /usr/src/linux
patch -p1 -R patch-v2.6.38-rc8-next-20110310
patch -p1 < patch-v2.6.38-rc8-next-20110311
cd ..
mv linux-2.6.38-rc8-next-20110310 linux-2.6.38-rc8-next-20110311
ln -sf linux-2.6.38-rc8-next-20110311 linux 

If you often update the kernel you'll see it is better to have a untouched copy of the sources. It is also recomended to make a backup of the (old) kernel modules before making new ones.

mv /lib/modules/`uname -r` /lib/modules/`uname r`.bak