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/Upgrade and the translation is 50% complete.

この記事は新しいカーネルにアップグレードすることについて説明しています。

新しいカーネルのインストールと使用

新しいカーネルのソースがインストールされたときは、カーネルを更新するといいかもしれません。新しいカーネルのソースは、次のコマンドでシステムを更新するときにインストールされることがあります。

root #emerge --ask --update --deep --with-bdeps=y --newuse @world

Of course, they can be installed directly using the next command (replace gentoo-sources with hardened-sources when using a hardened profile):

root #emerge --ask --update --deep --with-bdeps=y --newuse sys-kernel/gentoo-sources

新しいカーネルのソースをインストールしても、新しいカーネルが提供されるわけではありません。新しいソースから新しいカーネルを組み立てて、インストールして、実際に新しいカーネルを稼働させるためにシステムを再起動する必要があります。

新しいソースから新しいカーネルを作成する作業は、システムをインストールするときにカーネルを作成したときと基本的には同じ流れです。異なる点は、新しいカーネルのコンフィグを作るのに古いカーネルのコンフィグを利用できるという点です。古いコンフィグを利用すれば、ユーザは make menuconfig などを使ってすべてのカーネルオプションを再度設定しなおさずに済みます。

カーネルコンフィグは、カーネルソースがあるディレクトリの下の .config という名前のファイルに保存されています。新しいカーネルは、古いカーネルにはないオプションや機能を備えていることや、古いカーネルにあったオプションや機能がなくなっていることがあります。カーネルコンフィグは、カーネルの機能やオプションが、有効か無効か、カーネルに組み込まれるか、カーネルの稼働中に必要に応じてロードできるモジュールとして構築されるかを指定するものです。したがって、新しいカーネルのコンフィグファイルには、古いカーネルのコンフィグファイルには無い新しいエントリがあったり、古いカーネルのコンフィグファイルにあったエントリがなくなっていたりすることがあります。

こうしたコンフィグファイルの変更に対応するために、古いカーネルのコンフィグファイルを新しいカーネルで使えるコンフィグに変換する必要があります。この記事では、古いカーネルのコンフィグファイルを変換して、新しいカーネルソースから新しいカーネルを作成する方法について示します。

現在のカーネル設定のバックアップ

It is wise to make a backup of the kernel configuration so that the previous configurations are not lost. After all, many users devote considerable time to figure out the best configuration for the system, and losing that information is definitely not wanted.

It is easy to make a backup of the current kernel configuration:

root #cd /usr/src/linux
root #cp .config ~/kernel-config-`uname -r`

Provided that the symlink to the kernel sources has been set correctly, this copies the configuration of the currently used kernel to the home directory of root, renaming the configuration to kernel-config- followed by the version of the current running Linux kernel.

新しいカーネルソースへのシンボリックリンク設定

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

  1. Installing the kernel sources with USE="symlink"
  2. Setting the link with eselect
  3. Manually updating the symbolic link

Installing the kernel sources with the symlink USE flag

This will make the /usr/src/linux point to the newly installed kernel sources.

If necessary, it can still be modified later with one of the other two methods.

eselectを使った設定

eselectによるシンボリックリンクの設定

root #eselect kernel list
Available kernel symlink targets:
 [1] linux-3.14.14-gentoo *
 [2] linux-3.16.3-gentoo

利用可能なカーネルソースが出力されており、*が現在使われているソースを表しています。

カーネルソースを2番に変えるには次のようにします :

root #eselect kernel set 2

シンボリックリンクの手動更新

To set the symbolic link manually:

root #ln -sf /usr/src/linux-3.16.3 /usr/src/linux
root #ls -l /usr/src/linux
lrwxrwxrwx 1 root root 19 Oct  4 10:21 /usr/src/linux -> linux-3.16.3-gentoo

現行のカーネル設定のコピー

The configuration of the old kernel needs to be copied to the new one. It can be found in several places:

  • In the procfs filesystem, if the kernel option Enable access to .config through /proc/config.gz was activated in the present kernel:
root #zcat /proc/config.gz > /usr/src/linux/.config
  • From the old kernel. This will only work when the old kernel was compiled with CONFIG_IKCONFIG:
root #/usr/src/linux/scripts/extract-ikconfig /path/to/old/kernel >/usr/src/linux/.config
  • In the /boot directory, if the configuration was installed there:
root #cp /boot/config-3.14.14-gentoo /usr/src/linux/.config
  • In the kernel directory of the currently-running kernel:
root #cp /usr/src/linux-3.14.14-gentoo/.config /usr/src/linux/
  • In the /etc/kernels/ directory, if SAVE_CONFIG="yes" is set in /etc/genkernel.conf and genkernel was previously used:
root #cp /etc/kernels/kernel-config-x86_64-3.14.14-gentoo /usr/src/linux/.config

新しいカーネルの設定

To use the configuration of the old kernel with the new kernel, it needs to be converted. The conversion can be done by running either make silentoldconfig or make olddefconfig. Use either, not both.

make silentoldconfig

The following configuration is like the text based configuration with make config. For new configuration options, the user is asked for a decision. For example:

root #cd /usr/src/linux
root #make silentoldconfig
Anticipatory I/O scheduler (IOSCHED_AS) [Y/n/m/?] (NEW)

The string (NEW) at the end of the line marks this option as new. Left to the string in square brackets are the possible answers: Yes, no, module or ? to show the help. The recommend (i.e. default) answer is capitalized (here Y). The help explains the option or driver.

Unfortunately make silentoldconfig doesn't show a lot more information for each option, such as the context, so it is sometimes difficult to give the right answer. In this case the best way to go is to remember the option name and revise it afterwards through one of the graphical kernel configuration tools.

make olddefconfig

If all new configuration options should be set to their recommended (i.e. default) values use make olddefconfig:

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

make help

Use make help to see other conversion methods available:

root #make help

ビルド

Important
When external kernel modules are installed (like nvidia or zfs), it may be necessary to run make modules_prepare as described below before building the kernel. Some modules cannot be installed or prepared before the kernel has been built.
Important
Do not forget to reconfigure the bootloader to account for the new kernel filenames, and rebuild the initramfs if one is used as well.

For this step, follow the steps in the manual configuration article.

外部のカーネルモジュールの再インストール

Any external kernel modules, such as binary kernel modules, need to be rebuilt for each new kernel. If the kernel has not been built yet, it has to first be prepared for the building of the external kernel modules:

root #make modules_prepare

Packages containing kernel modules can be rebuilt using the @module-rebuild set:

root #emerge --ask @module-rebuild

Solving build problems

When experiencing build problems while rebuilding the current kernel, it might help to sanitize the kernel sources. Make sure to backup the .config file first, as the operation will remove it. Make sure not to use a .bak or ~ suffix as backup as make distclean will clean those up as well.

root #cp .config /usr/src/kernel_config_bk
root #make distclean
root #mv /usr/src/kernel_config_bk .config

古いカーネルの削除

kernel removalを参照してください。

External resources