In this article, compiling the kernel under Linux is explained.
The following explanations are based on version 2.4.20 of kernel, i.e. the most recent version of the kernel at the time this article was written (March 2003). The sources of the most recent version can be downloaded from http://www.kernel.org.
![]() |
The sources "weigh" between 25 et 30 Mo. |
Once the sources have been obtained, you will find a file named tar.bz2 pr tar.gz, depending on the case. Copy them into the directory /usr/src/ of your Linux machine, but do not decompress them immediately.
In the above-mentioned directory, type the following command:
castor@linuxbox:/usr/src$ ls -al total 8 drwxrwsr-x 2 root src 4096 Feb 8 2002 . drwxr-xr-x 13 root root 4096 May 1 1980 .. lrwxrwxrwx 1 root src 12 Feb 25 15:39 linux -> linux-2.4.18 drwxr-sr-x 2 root src 4096 Feb 25 15:38 linux-2.4.18 -rw-r--r-- 1 root root 27421046 Feb 25 15:37 linux-2.4.20.tar.bz2 castor@linuxbox:/usr/src$
The result may be different on your machine. The first thing to do is to replace the symbolic link linux with the command rm linux.
Then, decompress the tarball which was recovered prior thereto. Make sure you have enough space, the decompressed sources are approx. 200 Mo !!
Then we create a symbolic link linux pointing to the new directory. As the case may be, the directory in which the decompressed sources will be located is already called linux, and it is therefore advisable to rename it with the command mv linux linux-2.4.20.
root@linuxbox:/usr/src# rm linux rm: remove `linux'? y root@linuxbox:/usr/src# tar -xjf linux-2.4.20.tar.bz2 root@linuxbox:/usr/src# ln -s linux-2.4.20 linux root@linuxbox:/usr/src# ls -hal total 27M drwxrwsr-x 4 root src 4.0k Feb 25 15:49 . drwxr-xr-x 13 root root 4.0k May 1 1980 .. lrwxrwxrwx 1 root src 12 Feb 25 15:49 linux -> linux-2.4.20 drwxr-sr-x 2 root src 4.0k Feb 15 15:38 linux-2.4.18 drwxr-xr-x 14 root src 4.0k Nov 29 00:53 linux-2.4.20 -rw-r--r-- 1 root src 26M Feb 25 15:37 linux-2.4.20.tar.bz2 root@linuxbox:/usr/src#
The Linux kernel is "modular", i.e. certain options, defined as "modules" are only loaded at the time this is requested by the kernel. This allows it to save memory,
to the detriment of loading speed. For example, when printing a page every
six months, it is not useful to keep the printing templates (parallel port, printer, etc.) permanently in memory.
They will only be loaded once the user requests printing.
Before starting the configuration of the kernel, it is therefore important to familiarize oneself with the intended use of the machine under Linux.
There are three commands to configure the sources: make config, make menuconfig, and make xconfig.
The first two are in text mode, the third one requires the X-window system. The choise is yours: the three options are fully equivalent. Only the first option is somewhat more restrictive since it requires a full review of the options.
As to myself, my preference is make menuconfig.
root@linuxbox:/usr/src/linux# make menuconfig ( cd include ; ln -sf asm-i386 asm) make -C scripts/lxdialog all make[1]: Entering directory `/usr/src/linux-2.4.20/scripts/lxdialog' gcc -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -DLOCALE -DCURSES_LOC="<ncurses.h>" -c -o checklist.o checklist.c gcc -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -DLOCALE -DCURSES_LOC="<ncurses.h>" -c -o menubox.o menubox.c gcc -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -DLOCALE -DCURSES_LOC="<ncurses.h>" -c -o textbox.o textbox.c gcc -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -DLOCALE -DCURSES_LOC="<ncurses.h>" -c -o yesno.o yesno.c gcc -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -DLOCALE -DCURSES_LOC="<ncurses.h>" -c -o inputbox.o inputbox.c gcc -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -DLOCALE -DCURSES_LOC="<ncurses.h>" -c -o util.o util.c gcc -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -DLOCALE -DCURSES_LOC="<ncurses.h>" -c -o lxdialog.o lxdialog.c gcc -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -DLOCALE -DCURSES_LOC="<ncurses.h>" -c -o msgbox.o msgbox.c gcc -o lxdialog checklist.o menubox.o textbox.o yesno.o inputbox.o util.o lxdialog.o msgbox.o -lncurses ...
It is strongly advised to read the online help for each option.
The information provided below may vary depending on the version of the kernel and the options that were chosen before.
/dev/cpu/microcode - Intel IA32 CPU microcode support /dev/cpu/*/msr - Model-specific register support /dev/cpu/*/cpuid - CPU information supportThese three options may be used without risk; they can optimize management of the processor.