Keep it simple: as simple as possible, but no simpler. - A. Einstein

How to use a computer

Kernel (re)compilation made easy

Although a linux kernel remains functional well beyond the life-span of modern computers, there are occasions where a kernel rebuild is appropriate: add a new hardware, require a particular functionality, update your security…

If you do not already have them, download the latest kernel sources (get the file linux-X.Y.Z.tar.bz2 with X=2, Y=6, and Z as high as possible) and unpack them into /usr/src as /usr/src/linux-X.Y.Z. It may be a good idea to check ownership of files in /usr/src/linux-X.Y.Z and to run

chown root.root -R *

if necessary.

All the steps to make a fully functional kernel from source are then carried out by the script compkernel. The EXTRAVERSION=$DATE option assigns a unique name to the new kernel and ensures that existing kernel modules will not be overwritten.

The only command that requires user input is make menuconfig. Here you customize the kernel components and decide which features and drivers to include. This requires a precise knowledge of your hardware. If you are unfamiliar with module loading/unloading, it is recommended to go for a non-modular kernel and configure all features as built-in (choose [*] instead of modular [M]). When compiling a new kernel for the first time, you may get lost among the thousands of configuration options. Although it is very instructive to read all the “Help”, it is much faster to load an already existing configuration file (second last line in the main menu from make menuconfig) and then to tailor it to your specific needs. The compkernel script saves the configuration files as something like dot_config-20061231_2359 so that it can be reused later. When compiling a kernel for the first time you may look up your system for one of /proc/config.gz or /usr/src/linux-XXX/.config or /usr/src/linux-XXX/arch/i386/defconfig or search the web for config options relevant to your hardware.

When the compkernel script finishes, any modules are installed in /lib/modules/ (thus not overwriting existing ones) and the kernel image linux- with its associated System.map is copied to /boot.

After updating your boot loader configuration (for lilo, add a new entry to the file /etc/lilo.conf and rerun lilo; for grub, add a new entry to the file /boot/grub/menu.list and rerun grub) you are ready to reboot your system with the new kernel. Of course you should not erase your old kernel nor remove your old boot loader entries until you have checked that the new one works with all your hardware. (I tend to keep all old versions, there is no need to erase them unless you run out of disk space.) After a successful reboot, the command

uname -r

displays the running kernel version, someting like If errors are encountered, reboot into your old kernel, rerun compkernel, load the unsatisfactory dot_config-20061231_2359 and try out a variation on it.

For more information see for example the Kernel-HOWTO.

Copyleft © all rights reversed  —  http://www.lmfa.fr/perso/Benoit.Pier/computing/kernel.php viewed by - 02/10/2022 - 07:30:00