Compiling and installing a kernel can be described in three stages.
Configuring the kernel
Here we need to decide what kind of hardware and network support needs to
be included in the kernel as well as which type of kernel we wish to
compile (modular or monolithic). These choices will be saved in a single
file: /usr/src/linux/.config
Table 1.1. Creating the .config file
| Command | Description |
|---|---|
| make config | Edit each line of .configone at a
time |
| make menuconfig | Edit .config browsing through menus
(uses ncurses) |
| make xconfig | Edit .config browsing through menus
(uses GUI widgets) |
When editing the .config file using any of the
above methods the choices available for most kernel components are:
Do not use the module (n)
Statically compile the module into the kernel (y)
Compile the module as dynamically loadable (M)
Notice that some kernel components can only be statically compiled into the kernel. One cannot therefore have a totally modular kernel.
When compiling a monolithic kernel none of the components should be compiled dynamically.
Compiling the modules and the kernel
The next table outlines the various 'makes' and their function during this stage. Notice that not all commands actually compile code and that the make modules_install has been included.
Table 1.2. Compiling the kernel
| Command | Description |
|---|---|
| make clean | makes sure no stale .o files have
been left over from a previous build |
| make dep | adds a .depend with headers specific
to the kernel components |
| make | build the kernel |
| make modules | build the dynamic modules |
| make modules_install | install the modules in /lib/modules/ |
Installing the kernel image
This stage has no script and involves copying the kernel image manually to the boot directory and configuring the bootloader (LILO or GRUB) to find the new kernel.