| Compiling the kernel with the Debian way |
|
|
|
| Written by PiloZ | |
| giovedì, 12 aprile 2007 | |
|
Necessary tools before going on:
$ apt-get install make gcc kernel-package libncurses5-dev module-init-tools
(the following example uses the 2.6.9 kernel)
$ cd /usr/src $ tar jxvf linux-2.6.9.tar.bz2 create a symlink for the uncompressed source directory, called linux: $ ln -sf linux-2.6.9 linux $ cd linux
In order to prevent a kernel panic you're going to start from the current kernel's configuration taking the files in /boot . Assuming you are in /usr/src/linux, the commands are: $ cp /boot/config-2.6.8 .config $ make oldconfig
explain: the cp command copy into the new sources the 2.6.8 kernel's configuration by renaming the file from config-2.6.8 to .config; afterwards, the $ make oldconfig command will adapt, modify and make this .config compatible with the 2.6.9 kernel sources you're going to compile. Obviously a newer kernel contains new features, thus this last command will ask you some little question on the terminal (for most them, just confirm the default proposed setting by pressing Enter). This happens according to news in the kernel and to the age of the previous configuration file (config-2.6.8)
As an example we assume a 2.6.8 kernel, of course change the numbering for your needs. Assuming the fact you are in /usr/src/linux type these commands:
$ cp /boot/config-2.6.8 .config $ make menuconfig what it does : the cp command copy into the sources the same current kernel configuration by simply renaming from config-2.6.8 in .config; afterwards the $ make menuconfig command will help you doing the desired changings to the kernel configuration through a ncurses interface. Once you added what you need or deleted what you don't want exit and save the file when the dialog window will ask you.
$ make menuconfig
Now the following steps are the same: $ make-kpkg clean $ make-kpkg kernel_image the make-kpkg clean command cleans the source directories and starts make distclean, while make-kpkg kernel_image creates the .deb package . You will obtain a .deb to be installed with "dpkg -i file.deb" $ dpkg -i ../kernel-image-2.6.x....Custom_i386.deb $ ENTER $ ENTER
N.B.: the initrd image (RamDisk) is a portion of memory allocated as a partition, that is, it takes the memory and uses it as an hard disk, saving there some files. This technique is usually used to load some modules before installing the definitive filesystem, for example when the kernel requires a special module to access a filesystem; sometimes this happens, expecially on a scsi disk or raid controller. Thus you'd better add --initrd when you create the kernel image, so ue$ make-kpkg --initrd kernel_image insted of $ make-kpkg kernel_image that I wrote above. You have also the possibility to create the initrd image later with the mkinitrd tool contained in initrd-tools, just type:
$ mkinitrd -o initrd.img-2.6.x p.s. when you recompile the same kernel in /usr/lib/ the modules are already present, I suggest you to recompile with the --append_to_version -xxx flag too, for ex: $ make-kpkg --initrd --append_to_version -xxx kernel_image that create a subversion of the kernel and it's very comfortable. Indeed, it's enough to manually remove the old modules before installing kernel-image.deb (with dpkg -i) with: $rm -rf /lib/modules/2.6.x |
|
| Last Updated ( lunedì, 26 gennaio 2009 ) |
| Next > |
|---|




