This section describes the simplest possible procedure to build a custom kernel the "Debian way". It is assumed that user is somewhat familiar with kernel configuration and build process. If that's not the case, it is recommended to consult the kernel documentation and many excellent online resources dedicated to it.

The easiest way to build a custom kernel (the kernel with the configuration different from the one used in the official packages) from the Debian kernel source is to use the linux-source package and the make deb-pkg target. First, prepare the kernel tree:

# apt-get install linux-source-2.6.18
$ tar xjf /usr/src/linux-source-2.6.18.tar.bz2
$ cd linux-source-2.6.18

The kernel now needs to be configured, that is you have to set the kernel options and select the drivers which are going to be included, either as built-in, or as external modules. The kernel build infrastructure offers a number of targets, which invoke different configuration frontends. For example, one can use console-based menu configuration by invoking the command

$ make menuconfig

Instead of menuconfig one can use config (text-based line-by-line configuration frontend) or xconfig (graphical configuration frontend). It is also possible to reuse your old configuration file by placing it as a .config file in the top-level directory and running one of the configuration targets (if you want to adjust something) or make oldconfig (to keep the same configuration). Note that different frontends may require different additional libraries and utilities to be installed to function properly. For example, the menuconfig frontend requires the ncurses library, which at time of writing is provided by the libncurses5-dev package.

After the configuration process is finished, the new or updated kernel configuration will be stored in .config file in the top-level directory. The build is started using the commands

$ make clean
$ make KDEB_PKGVERSION=custom.1.0 deb-pkg


The custom.1.0 part in this command is the version identifier, which will get appended to the kernel package name. Feel free to adjust it to your liking. As a result of the build, a custom kernel package linux-image-2.6.18_custom.1.0_i386.deb (name will reflect the version of the kernel and the revision chosen in the command line above) will be created in the directory one level above the top of the tree. It may be installed using dpkg just as any other package:


# dpkg -i ../linux-image-2.6.18_custom.1.0_i386.deb

This command will unpack the kernel, generate the initrd if necessary (see Managing the initial ramfs (initramfs) archive, Chapter 7 for details), and configure the bootloader to make the newly installed kernel the default one. If this command completed without any problems, you can reboot using the

# shutdown -r now

command to boot the new kernel.

For much more information about bootloaders and their configuration please check their documentation, which can be accessed using the commands man lilo, man lilo.conf, man grub, and so on. You can also look for documentation in the /usr/share/doc/package directories, with package being the name of the package involved.

kernel-handbook.alioth.debian.org/index.html#co...

@темы: Ядра, Debian