Compiling Kernel   «Prev  Next»

Lesson 8Configuring the kernel
ObjectiveConfigure Linux Kernel Options before Compilation

Configure Linux Kernel Options before Compilation

Configuring your kernel correctly is crucial. Not only must you decide what kernel options to include, you must also decide if they are modular or built into the kernel. Linux makes it easy to set kernel options, but you must make sure you choose your options wisely.
Question: How do configure Linux Kernel options before compilation when using Red Hat Linux?
To configure Linux Kernel options before compilation when using Red Hat Linux, you can use the menuconfig tool, which is a graphical user interface (GUI) that allows you to select and configure kernel options.
Here are the steps to use menuconfig to configure kernel options before compilation:
  1. Download the kernel source code from the Red Hat website or via a package manager.
  2. Extract the kernel source code to a directory on your system.
  3. Open a terminal window and navigate to the directory containing the kernel source code.
  4. Run the following command to start menuconfig:
    make menuconfig
    
    This will open the menuconfig GUI, which displays a list of kernel options that can be configured.
  5. Use the arrow keys to navigate through the list of options and the spacebar to select or deselect options.
  6. Use the Enter key to enter submenus and configure specific options within each submenu.
  7. Once you have finished configuring the kernel options, select the "Save" option to save your changes.
  8. Exit the menuconfig GUI and run the following command to start the kernel compilation process:
    make
    

    This will compile the kernel with the options that you have configured.
  9. Once the compilation process is complete, install the new kernel using your package manager or by manually copying the compiled kernel image to the appropriate location.

By configuring kernel options before compilation using menuconfig, you can customize the kernel to meet your specific needs and requirements. This can include enabling or disabling certain features, optimizing performance, and improving security.

Hardware Considerations

When choosing kernel options, consider the specific hardware on your system and your need for protocols and services. Here are some general guidelines to follow.
  1. Under Code Maturity Level Options, check Prompt for development and/or incomplete code/drivers. If you do not check this option, certain essential services (most notably rpc.nfsd) may not work correctly.
  2. Optimize for your computer's processor family.
  3. Turn off math emulation when your system has a dedicated math coprocessor. Intel 386 and 486 systems with a coprocessor, Pentiums, and Alphas all have on-processor math coprocessors.
  4. Turn off SMP (Symmetric Multi-Processor) support when your system only has a single CPU.
  5. Modularize as much hardware support as possible.
  6. Turn off ISDN [1] IrDA[2], and old CD-ROM drivers support, unless you have these capabilities or devices.
  7. Don't change the default sound configuration.

Configuring the kernel

To configure the kernel, follow the following four steps.
  1. Change to the /usr/src/linux directory.
  2. Type make mrproper to restore the sources to a clean state.
  3. Copy one of Red Hat's default configuration files from the configs/ directory to arch/i386/defconfig. Red Hat provides these default configurations for a variety of hardware platforms. The settings inside of each make configuring the kernel easier.
  4. Type make oldconfig to create a starting Linux kernel configuration file from the default configuration copied in the previous step.
  5. Create the kernel configuration file using one of the standard configuration utilities: make xconfig, make menuconfig, or make config.
  6. Update the EXTRAVERSION= line in /usr/src/linux/Makefile.
  7. Type make dep to create the source dependencies and propagate configuration information to all makefiles in the development tree.
  8. Type make clean to remove old object files.

  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
  4. Step four: create a starting Linux kernel configuration file by typing make oldconfig.
  5. Step five: create the kernel configuration file using one of the standard configuration utilities: make xconfig, make menuconfig, or make config.
  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.
  7. Save your changes before you exit the configuration program.
  8. Once you are outside of make menuconfig, you see that it prompts you for the next steps.
  9. Step six: update the EXTRAVERSION variable in the Linux kernel configuration makefile.
  10. Step seven: type make dep to create the source dependencies and propagate configuration information to all makefiles in the development tree.
  11. Step eight: type make clean to remove old object files.
Pre Compilation Kernel
If you build the kernel in the future and use the same configuration, you do not need to perform steps two, three, and four.
You need to do these steps only the first time you are rebuilding a Red Hat Linux kernel. The next lesson presents the kernel and modules build and install procedures.

[1]ISDN: An acronym for Integrated Services Digital Network, ISDN is a standards specification for data transmission over telephone wires and other land-based media.
[2]IrDA: An acronym for Infrared Data Association, IrDA is an international standards body that plans the hardware and software requirements for wireless, infrared data communication.