how to Build a kernel in Debian.

Preparation
Put the packages needed for compiling the kernel:
Code: [Select]

 

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]

Go to the folder with source:
Code: [Select]


Overlay patches
If you are going to apply patches to the kernel, put the necessary patches to the program:
Code: [Select]

 

The patches are the following commands:
Code: [Select]

If the patch is packaged in the archive, the command would look like this:
Code: [Select]

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]

Code: [Select]

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]

Or create a new one.
To configure the kernel, you can use one of the following commands:
Code: [Select]

This command is supported since kernel version 2.6.35, does not require the installation of additional packages.
Code: [Select]

 

The old analogue make nconfig
Code: [Select]

 

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]

 

If 2.6.38 or above, then:
Code: [Select]

 

 

Code: [Select]

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]

 

 

Code: [Select]

When you use this command, the configuration file is created automatically based on the current configuration of the kernel.
Code: [Select]

When using defconfig configuration file is created based on the default values.
Code: [Select]

 

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]

 

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]

 

You can also set the number of threads for compilation. In this case, the command will look like this:
Code: [Select]

where N = number of threads.
Installation
After the kernel compile directory, create two .deb package set commands
Code: [Select]

 

Code: [Select]

 

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.