Usr src linux gentoo

Kernel/Configuration

This article describes the manual configuration and setup of the Linux kernel.

An alternative to manual configuration that uses ‘safe defaults’ to build a generic kernel are the distribution kernels or genkernel.

The /usr/src/linux symlink should always point to the kernel sources that is currently being used. This can be done in one of three ways:

1. Install the kernel sources with the symlink USE flag active. This will make the /usr/src/linux point to the newly installed kernel sources. If necessary, it can still be modified later with the following two methods:

2. Setting the symlink with the eselect tool:

Available kernel symlink targets: [1] linux-3.3.8-gentoo [2] linux-3.4.9-gentoo

This outputs the available kernel sources. The asterisk indicates the chosen sources. To change the kernel sources, e.g. to the second entry, do:

3. Setting the symlink manually:

lrwxrwxrwx 1 root root 11 Aug 29 22:10 /usr/src/linux -> /usr/src/linux-3.4.9-gentoo

Configuration

Tools

The kernel offers several user facing tools with which to configure itself, this following are selected highlights of the configuration, although more are available for review in the upstream documentation.

Command Description
make config Text based configuration. The options are prompted one after another. All options need to be answered, and out-of-order access to former options is not possible.
make menuconfig An ncurses-based pseudo-graphical menu (only text input). Navigate through the menu to modify the desired options.
make defconfig Generates a new config with default from the ARCH supplied defconfig file. Use this option to get back the default configuration file that came with the sources.
make nconfig Pseudo-graphical menu based on ncurses. Requires sys-libs/ncurses to be installed.
make xconfig Graphical menu using Qt5. Requires dev-qt/qtwidgets to be installed.
make gconfig Graphical menu using GTK. Requires x11-libs/gtk+, dev-libs/glib, and gnome-base/libglade to be installed.
make oldconfig Review changes between kernel versions and update to create a new .config for the kernel.
make olddefconfig Generates a new configuration with default values from the ARCH supplied defconfig file while, at the same time, maintaining all the previous options set in the .config file found at /usr/src/linux/.config . This is a fast and safe method for upgrading a config file that has all the configuration options it needs for hardware support while at the same time gaining bug fixes and security patches.
make localmodconfig Creates a config based on the current config and the currently loaded modules, as viewable via the lsmod command.
make allyesconfig Enables all configuration options in the kernel. It will set all kernel options to * . Make sure a backup of the current kernel configuration is acquired before using this option!
make allmodconfig Enables all modules in kernel. Note that this operation will consume quite a bit of disk space.
Читайте также:  Установка бинарных пакетов linux

There are also several scripts to create miscellaneous default configurations. These can make deeper configuration more time efficient. Run the following command for a full list of make targets:

The remainder of this article will describe configuration using the make menuconfig tool, but the procedure is similar for the other kernel build tools.

Usage

In the shown menu the blue bar indicates the cursor position. The ↑ and ↓ arrow keys change cursor position. The ← and → arrow keys traverse the menu bar in the bottom and define what happens when the Enter key is pressed. For the menu bar below, Select switches to a sub menu for the menu entries ending with —> while Exit exits a sub menu. As an alternative, the Esc key can be pressed twice to exit the sub menu, dialog or the entire application.

Pressing an associated letter key A — Z will move the position of the cursor lines that have characters in bold. The Y , M , N keys are excluded from navigation in this way; they are sanctified for other purposes. If a line begins with a Y, M, or N, the next character will be bold and capable of being jumped to. For example, relative to the cursor’s current position, if the next line reads «Network Device Support —>» pressing the E key will move the cursor to that line.

The following symbols can appear in front of the lines in the menus:

If the option is activated, the selected feature/driver will be built into the kernel and will always be available at boot time.

See the Kernel Modules article for differentiation.

Furthermore some menu entries have a tag at the end:

Tag Description
(NEW) This driver is new in the kernel and is maybe not stable enough.
(EXPERIMENTAL) This driver is experimental and most likely not stable enough.
(DEPRECATED) This driver is deprecated and not needed for most systems.
(OBSOLETE) This driver is obsolete and should not be activated.
Читайте также:  Astra linux терминальное подключение

Most options have a description, which see by pressing the H key or choosing Help in the menu bar.

Driver selection

See the hardware detection article and the articles in the Hardware category.

Search modules

Within menuconfig , use the / key to search modules and config options by name.

As shown below, the search result will show numbers in front of the matches. Pressing 1 in the example below would make menuconfig jump straight to the option Bluetooth device drivers in the menu structure.

Symbol: BT_HCIBTUSB [=m] Type : tristate Prompt: HCI USB driver Location: -> Networking support (NET [=y]) -> Bluetooth subsystem support (BT [=y]) (1) -> Bluetooth device drivers Defined at drivers/bluetooth/Kconfig:5 Depends on: NET [=y] && BT [=y] && USB [=m]

Enabling Gentoo Linux common settings

There is a kernel configuration option called CONFIG_GENTOO_LINUX only present in sys-kernel/gentoo-sources and other Kernel Project maintained kernels. It does nothing on its own, but sets various required configuration options for typical installations.

This setting automatically selects tmpfs and devtmpfs support, which are needed for handling /dev on Gentoo Linux, but might be expanded in the future to enable other mandatory settings for a Gentoo Linux system. For more information, read the help information available through the kernel configuration system as described earlier in this guide.

Kbuild

Warning
Be very careful of changing environment variables as it may break the kernel in unexpected ways. DO NOT MIX GNU binutils and LLVM binutils. For example make CC=gcc LD=ld.lld AR=llvm-ar will not work because LLVM’s ar and ld is not compatible with GCC.

The Kernel build system can be used to change how Kernel builds in a more advanced way than make *config , similar to GNU Make. Kbuild also support Environment Variables like LLVM=1 . For example, the kernel will be build with LLVM and with aggressive optimization flags:

Build

After configuration has been accomplished successfully, compile the kernel:

Note
Depending on system performance, building the kernel could take quite some time. If the number of logical CPU cores in the system is known, the -jN (where N is 1 plus the number of available logical cores) option can be used to dramatically speed up the compilation process. For example, a quad core processor with 2-way Simultaneous multithreading (SMT) has eight logical cores, so make can be invoked with the -j9 option: make -j9 . An easy way to determine the number of available logical cores is to run the nproc command:

Читайте также:  Установка arch linux wifi

Setup

If drivers are activated as modules, they must be installed:

The modules will be copied to a sub directory of /lib/modules by default, but can be changed using the MODLIB environment variable.

To install the actual kernel:

This command executes /sbin/installkernel , which is part of the sys-apps/debianutils package. The new kernel is installed into /boot/vmlinuz- . If a symbolic link /boot/vmlinuz already exists, it is refreshed by making a link from /boot/vmlinuz to the new kernel, and the previously installed kernel is available as /boot/vmlinuz.old . (installkernel man page). The same for config and System.map files. These symlinks are handy, because they always point to the newest kernel without changing the file path (e.g. they can be used in the bootloader configuration).

Bootloader

Change the system’s bootloader configuration to load the kernel at system boot.

When the bootloader step has been finished, restart the system with the new kernel.

Comparing current kernel configuration with default configuration

Use the following procedure to get an overview of the kernel configuration settings that deviate from the default. Keep in mind that the modification of one configuration setting may alter additional configuration settings.

The search function in make menuconfig can be used to look up the symbols and their interpretations. When you’re done, clean up:

See also

  • Genkernel — a tool created by Gentoo used to automate the build process of the kernel and initramfs.
  • Kernel — the core of the operating system.
  • Kernel Seeds — pre-made kernel configuration files.
  • Kernel/Gentoo Kernel Configuration Guide — aims to introduce the concepts of manual kernel configuration and details some of the most common configuration pitfalls.
  • Project:Distribution Kernel — aims to maintain sys-kernel/*-kernel packages.

External resources

  • Эта страница в последний раз была отредактирована 27 марта 2023 в 04:20.
  • Политика конфиденциальности
  • О Gentoo Wiki
  • Отказ от ответственности

© 2001–2023 Gentoo Authors
Gentoo is a trademark of the Gentoo Foundation, Inc. The contents of this document, unless otherwise expressly stated, are licensed under the CC-BY-SA-4.0 license. The Gentoo Name and Logo Usage Guidelines apply.

Источник

Оцените статью
Adblock
detector