How to Build and Install a Custom Kernel

By eHow Computers Editor

Rate: (2 Ratings)

Using Linux allows you to customize every aspect of your operating system. There are times when you need or may want to build a custom kernel, either to add features you need, remove features you don't need or minimize your memory footprint. Compiling your own kernel also allows you to stay at the forefront, as you can install new kernel versions as they're released instead of waiting for a distribution package.

Instructions

Difficulty: Moderate

Things You’ll Need:

  • Build environment
  • Linux
  • Kernel source code

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 dep
make clean
make bzImage
make 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.

Tips & Warnings

  • Refer to your distribution documentation for instructions on how to install kernel development packages.
  • All make commands should also be run as root, either with "sudo" or "su."

Post a Comment

POST A COMMENT

Request a New How-To Article

Looking for more How To information? Chances are there’s an eHow member who knows how to do what you’re looking to do. Submit an article request now!

eHow Article: How to Build and Install a Custom Kernel

eHow Computers Editor

eHow Computers Editor

Category: Computers

Articles: See my other articles

Related Ads