Preparation
Put the packages needed for compiling the kernel:
Code: [Select]
1 |
# aptitude install kernel-package libncurses5-dev fakeroot build-essential pkg-config |
Go to the directory where you are going to assemble. (In this example, the directory will be/usr/src). Download and unpack the kernel sources:
Code: [Select]
1 |
# cd /usr/src && wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-версия-ядра.tar.bz2 && tar xjf linux-версия.tar.bz2 |
Go to the folder with source:
Code: [Select]
1 |
# cd /usr/src/linux-версия |
Overlay patches
If you are going to apply patches to the kernel, put the necessary patches to the program:
Code: [Select]
1 |
# aptitude install patch |
The patches are the following commands:
Code: [Select]
1 |
patch -p1 -i patch-версия |
If the patch is packaged in the archive, the command would look like this:
Code: [Select]
1 |
bzip2 -dc /usr/src/patch-версия | patch -p1 |
In this case, patch, packed in an archive. tar.bz2, if your case is different from mine, the team only need to change the name of the archiver bzip2 on the right, for example, to gzip the tar.gz archive.
By the way, before applying the patches, it is better to check how well they are applied to the core. The above command adds a flag-dry-run, which simulates the use of the patch:
Code: [Select]
1 |
patch -p1 -i patch-версия --dry-run |
Code: [Select]
1 |
bzip2 -dc /usr/src/patch-версия | patch -p1 --dry-run |
When you run these commands do not appear in the output lines containing something like a combination of the words “Hunk failed”, then most likely, all is well.
Configuring
Kernel configuration is read from the .config file. To create one, you can use the old kernel configuration file, which is in the/boot:
Code: [Select]
1 |
# cp /boot/config-$( uname -r ) .config |
Or create a new one.
To configure the kernel, you can use one of the following commands:
Code: [Select]
1 |
make nconfig |
This command is supported since kernel version 2.6.35, does not require the installation of additional packages.
Code: [Select]
1 |
make menuconfig |
The old analogue make nconfig
Code: [Select]
1 |
make xconfig |
The koniguracii has a graphic interface that uses qt. If going to the kernel under version 2.6.38, you set the following packages:
Code: [Select]
1 |
# aptitude install qt3-dev-tools |
If 2.6.38 or above, then:
Code: [Select]
1 |
# aptitude install libqt4-dev |
Code: [Select]
1 |
make gconfig |
Also has a graphical interface, but unlike xconfig, uses gtk instead of qt.
In order to work with it, put the following packages:
Code: [Select]
1 |
# aptitude install libgtk2.0-dev libglib2.0-dev libglade2-dev |
Code: [Select]
1 |
make oldconfig |
When you use this command, the configuration file is created automatically based on the current configuration of the kernel.
Code: [Select]
1 |
make defconfig |
When using defconfig configuration file is created based on the default values.
Code: [Select]
1 |
make localmodconfig |
When you use this command, (running in kernel 2.6.32 and newer) compares the currently loaded modules and those whose support is enabled in the kernel, if there are any extra modules, they are disabled.
Code: [Select]
1 |
make localyesconfig |
The script for the abandonment of the initrd. All necessary modules are included in the kernel.
Kernel compilation and installation packages
Compile and build the kernel package is available with the following command:
Code: [Select]
1 |
# make-kpkg --initrd --revision=mybuild.1.0 kernel_image kernel_headers |
You can also set the number of threads for compilation. In this case, the command will look like this:
Code: [Select]
1 |
# CONCURRENCY_LEVEL=N make-kpkg --initrd --revision=mybuild.1.0 kernel_image kernel_headers |
where N = number of threads.
Installation
After the kernel compile directory, create two .deb package set commands
Code: [Select]
1 |
dpkg -i linux-image-версия.deb |
Code: [Select]
1 |
dpkg -i linux-headers-версия.deb |
Then grub automatically registers them in your configuration file.
You can now boot from the new kernel. If you do not have to configure any critical errors, everything should be fine.