Kernel/Upgrade/zh-cn

这篇文章描述了升级到新内核步骤.

安装 并且使用一个新内核
当安装新的内核源代码后，升级您的内核或许是一个很棒的主意. 当您运行 emerge -a --update --deep --with-bdeps=y --newuse @world 时，新的内核源代码有时会随着系统的更新而安装，或者直接被安装.

安装新的内核源代码并不会给使用者提供一个新的内核. 从新内核源代码编译和安装一个新的内核，然后重启系统从而真正的运行新的内核是有必要的.

从新的源代码制作一个新的内核基本上和安装系统时的制作内核是一样的. 不同之处在于可以基于旧内核的配置文件来为新内核制作一个配置文件. 使用旧的配置文件可以让使用者不从头到尾再做一次内核选项（像 make menuconfig 一样）.

内核的配置文件 保存在内核源代码的目录下面. 一个新的内核或许会旧内核没有的特性或选项，新内核也有可能没有现存于旧内核的特性或选项. 内核配置文件指定了是否开启内核的功能和选项，或许内嵌入内核，或许以模块形式构建从而允许在内核运行需要时被加载. 因此，新内核的配置文件可能有新的但是旧内核的配置文件没有的选项，同时新内核的配置文件可能没有旧内核的配置文件现有的选项.

To deal with such changes of the configuration file, the configuration file of the old kernel needs to be converted to a configuration that can be used with the new kernel. This article shows how to make a new kernel from new kernel sources with converting the configuration file of the old kernel.

为当前运行内核的配置文件制作一个备份
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:

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 followed by the version of the current running Linux kernel.

设置一个链接到新的内核源代码
符号链接 应该始终指向正在运行的内核的源代码的目录. 下面三种方法中任意一个可以实现这一点：


 * 1) Installing the kernel sources with
 * 2) Setting the link with eselect
 * 3) Manually updating the symbolic link

安装使用 USE Flag 的内核源代码
This will make the point to the newly installed kernel sources.

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

使用 eselect 设置链接
To set the symlink with eselect:

This outputs the available kernel sources. The asterisk indicates the chosen sources.

To change the kernel sources, e.g. to the second entry, do:

手动更新符号链接
To set the symbolic link manually:

复制以前的内核配置文件
The configuration of the old kernel needs to be copied to the new one. It can be found in several places:


 * 如果在当前内核中选项Enable access to .config through /proc/config.gz是激活的，配置文件在procfs 文件系统：


 * 目录,如果你把配置文件安装到了这里:


 * 当前运行的内核的源代码目录：

配置新的内核
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.

make silentoldconfig gives choices for new options, make olddefconfig does not. Use either, not both.

制作沉默的旧的配置 (make silentoldconfig)
The following configuration is like the text based configuration with make config. For new configuration options, it gives a choice. For example:

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 answer is capitalized (here Y). The help explains the option or driver.

Unfortunately make silentoldconfig</tt> doesn't show - next to the help - a lot more information for each option, like the context, so that 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 interactivity is not wanted (no questions should be asked), then use make olddefconfig</tt>:

编译
这一步请参考 manual configuration.

重新安装外部内核模块
任何外部的内核模块，像 binary kernel modules, 需要为新的内核重新编译. 如果新内核还没有编译，需要首先为编译外部内核模块做准备：

你可以使用"@module-rebuild"命令重新编译包：

解决编译的问题
当重新编译当前内核的时候遇到问题，这也许有助于净化内核源代码. 确保首先备份了文件，因为操作过程会删除它. 确保备份文件不要以 或者  为后缀，因为  make distclean</tt> 同样会删除这些文件.

删除旧内核
参考 kernel removal.

外部资源

 * kernel changelog with some explanations of new features