This is Gentoo's testing wiki. It is a non-operational environment and its textual content is outdated.

Please visit our production wiki at https://wiki.gentoo.org

カーネル/コンフィグレーション

From Gentoo Wiki (test)
< Kernel
Jump to:navigation Jump to:search
This page is a translated version of the page Kernel/Configuration and the translation is 51% complete.
Outdated translations are marked like this.

この記事では、Linux カーネル のコンフィグレーションとセットアップを手作業で行う方法について説明しています。自動的に行う方法は、genkernel の記事を参照してください。

シンボリックリンクの作成

/usr/src/linux のシンボリックリンクは常に、現在使用中のカーネルのソースへ張られるべきです。このシンボリックリンクを張るのは、以下の3つの方法のいずれかで可能です。

1. symlink USE フラグを有効にして、カーネルソースをインストールする。この方法では、新たにインストールするカーネルソースを指す /usr/src/linux が作成されます。もしも必要ならば、以下の2つの方法で後ほど変更することもできます:

2. eselect でシンボリックリンクを設定する:

root #eselect kernel list
Available kernel symlink targets:
[1] linux-3.3.8-gentoo
[2] linux-3.4.9-gentoo

eselect は、利用可能なカーネルソースのリストを出力します。アスタリスクは、選択中のソースを示します。カーネルソースを、例えば2つ目の項目に変更するには:

root #eselect kernel set 2

3. 手作業でシンボリックリンクを設定する:

root #ln -sf /usr/src/linux-3.4.9-gentoo /usr/src/linux
root #ls -l /usr/src/linux
lrwxrwxrwx 1 root root 11 Aug 29 22:10 /usr/src/linux -> /usr/src/linux-3.4.9-gentoo


コンフィグレーションツール

カーネルは、自身のコンフィグレーションのためにいくつかのツールを提供しています。

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 Qt4. Requires dev-qt/qtgui 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 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 experimentally using it!

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:

root #make help

コンフィグレーション

This article describes the configuration using the make menuconfig tool, but the procedure is similar for the other menus.

root #cd /usr/src/linux
root #make menuconfig

操作方法

In the shown menu the blue bar indicates the position of the cursor. With the and arrow keys change the position of the cursor. 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 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:

Symbol(s) Description
[ ], [*] Options in square brackets can be activated or deactivated. The asterisk marks the menu entry as activated. The value can be changed with the space key. It is also possible to press Y key (Yes) to activate or N key (No) to deactivate the selected entry.


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

< >, <M>, <*> Options in angle brackets can be activated or deactivated, but also activated as module (indicated by a M). The values can be modified by pressing Y/N keys as before or by pressing the M key to activate the feature/driver as a module.


See the Kernel Modules article for differentiation.

{M}, {*} Options in curly brackets can be activated or activated as module but not be deactivated. This happens because another feature/driver is dependent on this feature.
-M-, -*- Options between hyphens are activated in the shown way by another feature/driver. There is no choice.

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.

ほとんどのオプションには解説がついていて、H キーを押すかメニューバーの Help を選ぶことで見ることができます。

ドライバの選択

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

モジュールの検索

menuconfigを使って, /の文字を押すとカーネルモジュールを検索事ができます.

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.

KERNEL Example output after searching for HCIBTUSB
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.

ビルド

After configuration has been accomplished successfully, compile the kernel:

root #make

For processors with multiple cores, make all the cores do the work. Add the option -j(<NUMBER_OF_CORES> + 1). For example, a dual core processor contains two logical cores plus one (2 + 1):

root #make -j3

A quad core system contains four logical cores plus one (4 + 1):

root #make -j5

セットアップ

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

root #make modules_install

The modules will be copied to a sub directory of /lib/modules.

To install the actual kernel:

root #make install

This command executes /sbin/installkernel, which is part of the sys-apps/debianutils package. The new kernel is installed into {{Path|/boot/vmlinuz-{version}}}. 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).

ブートローダ

Change the system's bootloader configuration to pick up at boot the new kernel.

Finally 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.

root #cd /usr/src/linux
root #cp .config ../.config.working
root #make defconfig
root #mv .config ../.config.default
root #cp ../.config.working .config
root #cd ..
root #/usr/src/linux/scripts/diffconfig .config.working .config.default > .config.diff

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

root #cd /usr/src/
root #rm .config.working .config.default .config.diff

See also