configuration

▶ The kernel configuration and build system is based on multiple Makefiles ▶ One only interacts with the main Makefile, present at the top directory of the kernel source tree ▶Interaction takes place ▶using the make tool, which parses the Makefile ▶through various targets, defining which action should be done (configuration, compilation, installation, etc.). Run make help to see all available targets.

▶ The kernel contains thousands of device drivers, filesystem drivers, network protocols and other configurable items ▶ Thousands of options are available, that are used to selectively compile parts of the kernel source code ▶ The kernel configuration is the process of defining the set of options with which you want your kernel to be compiled ▶ The set of options depends ▶ On your hardware (for device drivers, etc.) ▶ On the capabilities you would like to give to your kernel (network capabilities, filesystems, real-time, etc.)

▶ The configuration is stored in the .config file at the root of kernel sources ▶ Simple text file, key=value style ▶ As options have dependencies, typically never edited by hand, but through graphical or text interfaces: ▶ make xconfig, make gconfig (graphical) ▶ make menuconfig, make nconfig (text) ▶ You can switch from one to another, they all load/save the same .config file, and show the same set of options ▶ To modify a kernel in a GNU/Linux distribution: the configuration files are usually released in /boot/, together with kernel images: /boot/config-3.2.0-31-generic

Kernel or module?

▶ The kernel image is a single file, resulting from the linking of all object files that correspond to features enabled in the configuration ▶ This is the file that gets loaded in memory by the bootloader ▶ All included features are therefore available as soon as the kernel starts, at a time where no filesystem exists ▶ Some features (device drivers, filesystems, etc.) can however be compiled as modules ▶ These are plugins that can be loaded/unloaded dynamically to add/remove features to the kernel ▶ Each module is stored as a separate file in the filesystem, and therefore access to a filesystem is mandatory to use modules ▶This is not possible in the early boot procedure of the kernel, because no filesystem is available

Kernel option types

There are different types of options bool options, they are either true (to include the feature in the kernel) or false (to exclude the feature from the kernel) tristate options, they are either true (to include the feature in the kernel image) or module (to include the feature as a kernel module) or false (to exclude the feature) int options, to specify integer values hex options, to specify hexadecimal values string options, to specify string values

Kernel option dependencies

  • There are dependencies between kernel options
  • For example, enabling a network driver requires the network stack to be enabled
  • Two types of dependencies
    • depends on dependencies. In this case, option A that depends on option B is not visible until option B is enabled
    • select dependencies. In this case, with option A depending on option B, when option A is enabled, option B is automatically enabled
    • make xconfig allows to see all options, even the ones that cannot be selected because of missing dependencies. In this case, they are displayed in gray.

xconfig

make xconfig

  • The most common graphical interface to configure the kernel.
  • Make sure you read help -> introduction: useful options!
  • File browser: easier to load configuration files
  • Search interface to look for parameters
  • Required Debian / Ubuntu packages: libqt4-dev g++

Looks for a keyword in the parameter name. Allows to select or unselect found parameters.

Options are grouped by sections and are prefixed with CONFIG_.

gconfig

make gconfig

  • GTK based graphical configuration interface. Functionality similar to that of make xconfig.
  • Just lacking a search functionality.
  • Required Debian packages: libglade2-dev

menuconfig

make menuconfig

  • Useful when no graphics are available. Pretty convenient too!
  • Same interface found in other tools: BusyBox, Buildroot...
  • Required Debian packages: libncurses-dev

nconfig

make nconfig

  • A newer, similar text interface
  • More user friendly (for example, easier to access help information).
  • Required Debian packages: libncurses-dev

oldconfig

make oldconfig

Needed very often!

  • Useful to upgrade a .config file from an earlier kernel release
  • Issues warnings for configuration parameters that no longer exist in the new kernel.
  • Asks for values for new parameters (while xconfig and menuconfig silently set default values for new parameters).

If you edit a .config file by hand, it's strongly recommended to run make oldconfig afterwards!

Undoing configuration changes

A frequent problem:

  • After changing several kernel configuration settings, your kernel no longer works.
  • If you don't remember all the changes you made, you can get back to your previous configuration: $ cp .config.old .config
  • All the configuration interfaces of the kernel (xconfig, menuconfig, oldconfig...) keep this .config.old backup copy.

Configuration per architecture

  • The set of configuration options is architecture dependent
    • Some configuration options are very architecture-specific
    • Most of the configuration options (global kernel options, network subsystem, filesystems, most of the device drivers) are visible in all architectures.
  • By default, the kernel build system assumes that the kernel is being built for the host architecture, i.e. native compilation
  • The architecture is not defined inside the configuration, but at a higher level

results matching ""

    No results matching ""