Linux has a modular, customisable kernel with several switchable options (e.g. support for multiple processors and device drivers for various hardware devices). It may happen that some new hardware is added to a Linux machine which requires you to recompile the kernel so that it includes device driver support (and possibly new system calls) for the new hardware. To do this, you will need to rebuild the Linux kernel from scratch as follows:
- Look in /usr/src/linux for the kernel source code. If it isn't there (or if there is just a message saying that only kernel binaries have been installed), get hold of a copy of the latest kernel source code from http://www.kernel.org and untar it into /usr/src/linux.
- Change directory to /usr/src/linux.
- To configure the kernel type either
# make config (simple text mode configuration), or
# make menuconfig (menu-driven text configuration), or
# make xconfig (graphical configuration for X)You will be asked to select which modules (device drivers, multiprocessor support etc.) you wish to include. For each module, you can chose to include it in the kernel code (y), incorporate it as an optional module that will be loaded if needed (m) or to exclude it from the kernel code (n). To find out which optional modules have actually been loaded you can run lsmod when the system reboots.
- Now type:
# make dep (to build source code dependencies)
# make clean (to delete all stale object files)
# make bzImage (to build the new kernel)
# make modules (to build the new optional modules)
# make modules_install (to install the modules)The file /usr/src/linux/arch/i386/boot/bzImage now contains your new kernel image. It remains only to install it.
- Change directory to /usr/src/linux/arch/i386/boot. In the same directory should be a script called install.sh which will copy your kernel image into /boot/vmlinuz:
# install.sh version bzImage /boot/System.map /boot
where version is the kernel version number (of form 2.2.xx).
else you can run the command #make install
- Finally, you may need to update the /etc/lilo.conf file so that lilo (the Linux boot loader) includes an entry for your new kernel. Then run
# lilo
to update the changes. When you reboot your machine, you should be able to select your new kernel image from the lilo boot loader.