Compiling Kernel   «Prev 

Configuring Linux Kernel before compilation

Question: How does one configure the Linux Kernel before compilation?
Configuring the Linux Kernel before compilation involves selecting the specific options and features that are needed for the system being built. Here are the general steps for configuring the kernel:
  1. Obtain the Kernel Source Code: Download the kernel source code from a trusted source such as the official Linux kernel website.
  2. Extract the Source Code: Extract the compressed source code archive to a directory using a command like "tar xzf linux-x.y.z.tar.gz" (where x.y.z is the version number).
  3. Configure the Kernel: Navigate to the kernel source directory and run the "make menuconfig" command to open the kernel configuration menu. This will display a text-based interface that allows the user to select various options and features. Alternatively, one can use "make xconfig" to use a graphical user interface (GUI) to configure the kernel.
  4. Select the Required Options: Browse through the available options and select the ones that are needed for the system being built. This includes selecting the hardware drivers, file systems, and other features needed for the system to function properly.
  5. Save the Configuration: After selecting the required options, save the configuration and exit the configuration menu.
  6. Compile the Kernel: Run the "make" command to compile the kernel. This process may take a while, depending on the hardware specifications of the system.
  7. Install the New Kernel: After the kernel is compiled, install it using the "make install" command. This will copy the kernel image, kernel modules, and other required files to the appropriate directories.
  8. Update the Boot Loader: Finally, update the boot loader configuration file to include the new kernel image. This ensures that the system boots using the newly installed kernel.

Note: The exact steps for configuring the kernel may vary slightly depending on the Linux distribution being used.

Red Hat Reference
1) Step one: change into the /usr/src/linux directory. All subsequent commands will run relative to this directory.

2) Step two: type make mrproper to restore the kernel sources to a clean state.

3) Step three: copy a default configuration file to the arch/i386/defconfig file. In this example, you copied an Intel 686 default profile. Because a default profile already exists, Red Hat Linux will prompt you to overwrite the existing file. It is safe to answer "y."

4) Step four: create a starting Linux kernel configuration file by typing make oldconfig. This incorporates the default configuration you copied in the previous step into your Linux kernel configuration.

5) Step five: create the kernel configuration file using one of the standard configuration utilities: make xconfig, make menuconfig, or make config. make xconfig is X-based and menu driven; make menuconfig is VGA-based and menu driven; and make config is command-line driven. Try out all three possibilities and choose the one you find most comfortable to work with. make menuconfig is easy to use and text based, and it is often the best choice.

6) The colorized menu interface for make menuconfig is very useful. You can use the arrow keys to move up and down, and the Enter key to move into submenus. To build support for an item into the kernel, highlight the item and press Y. To build modular support, highlight the item and press M. To turn off support, highlight the item and press N.

7) Save your changes before you exit the configuration program.

Once you are outside of make menuconfig, you see that it prompts you for the next steps.

Step six: update the EXTRAVERSION variable in the Linux kernel configuration makefile. You can set this to any value, but something you easily recognize and that is different from your last kernel configuration is recommended. A good choice is simply to append a revision number to Red Hat's value, e.g. 2.2.14-5.0r1. Whatever value you choose, make sure it starts with a hyphen (-).

Step seven: type make dep to create the source dependencies and propagate configuration information to all makefiles in the development tree.

Step eight: type make clean to remove old object files.