Build and Install a Custom Kernel in Linux
Step1
Install a build environment. Before you can build a custom kernel, you have to install the development tools needed to compile the kernel. This includes packages like "gcc," "make" and "libc-dev."
Step2
Download the Linux kernel source code. If your distribution doesn't have a way of downloading the kernel source, download source code from The Linux Kernel Archive (see Resources below).
Step3
Extract the source code. Make a directory in your home directory for working and move the kernel source code "tarball" (the tar.gz file) into that directory. Run the following command, replacing the current version with the version of the kernel you downloaded:
"tar -xzvf linux-2.6.22.tar.gz"
Step4
Confirm the files were extracted. You should see a long list of files scroll by after you run the tar command that includes every file that was extracted. Change the directory to the new directory created by tar, confirm the files are there and check the end of the output of tar to make sure no errors were reported.
Step5
Import your distribution's .config file. Most modern Linux distributions need some very specific kernel configuration flags to run. In order to make a kernel that's compatible with your distribution, you should copy your kernel's .config file into the kernel directory now, as this will give you a configuration to which you can make changes, as opposed to having to create a whole new configuration.
Step6
Build a configuration program. There are multiple ways of running the Linux kernel config program. The first and most simple is simply
"make config". This will build and launch a small text-based program that allows you to select kernel options. A graphical program is included in the form of
"make xconfig." Other graphical programs may be available in the form of
"make gconfig" or
"make kconfig."
Step7
Apply patches to the kernel. Patches can be obtained to fix certain hardware problems, boost kernel performance or to try experimental features.
Step8
Change the configuration options. Add or remove the features you want to, but be aware that removing some features might make your distribution malfunction.
Step9
Build the kernel and modules, using the following commands:
"make depmake cleanmake bzImagemake modules". If any errors are reported, you'll have to go back and diagnose them before the kernel will build. When the make commands are finished, the kernel will be built and the modules will be built and installed. The make process will take some time.