Kernel/Upgrade/zh-cn

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

安装 并且使用一个新内核
A kernel upgrade may be a good idea when new kernel sources are installed. New kernel sources are sometimes installed while updating the system by running the following command:

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

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

Making a new kernel from the new sources is basically the same process as making a kernel when installing the system. The difference is that one can use the configuration of the old kernel to create a configuration for the new kernel. Using the old configuration saves the user from going through all the kernel options (like ) again.

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

要处理配置文件的更改，旧内核的配置文件需要转换为可用于新内核的配置. 本文展示了如何通过转换旧内核的配置文件来制作一个新内核.

为当前运行内核的配置文件制作一个备份
备份内核配置是明智的，这样以前的配置就不会丢失了. 毕竟许多用户花了大量的时间来配置出系统的最佳配置，同时失去内核配置是绝对不会想要的.

制作一个当前内核配置的备份很容易：

在内核源代码的链接被配置正确的情况下，这复制了正在使用的内核的配置文件到了根用户的家目录下，重命名了配置文件变成 加上现在正在运行的内核的版本号.

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


 * 1) 安装内核源代码时使用
 * 2) 用 eselect 设置链接
 * 3) 手动更新符号链接

安装使用 USE Flag 的内核源代码
这将会让 指向新安装的内核源代码.

如果有必要的话，也可以选择下面两种方法之一来进行稍后修改.

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

这将输出可用的内核源代码. 星号表示已经选择的来源.

要更改内核源，例如选第二个选项：

手动更新符号链接
手动设置符号链接：

复制以前的内核配置文件
旧内核的配置需要被复制到新的内核中. 它可以在这几个地方找到：


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


 * From the old kernel. This will only work when the old kernel was compiled with CONFIG_IKCONFIG:


 * In the directory, if the configuration was installed there:


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


 * In the directory, if   is set in  and  was previously used:

配置新的内核
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 or. Use either, not both.

制作沉默的旧的配置 (make silentoldconfig)
The following configuration is like the text based configuration with. For new configuration options, the user is asked for a decision. 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 (i.e. default) answer is capitalized (here Y). The help explains the option or driver.

Unfortunately 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 help
Use to see other conversion methods available:

编译
这一步请参考 manual configuration.

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

Packages containing kernel modules can be rebuilt using the  set:

解决编译的问题
When experiencing build problems while rebuilding the current kernel, it might help to sanitize the kernel sources. Make sure to backup the file first, as the operation will remove it. Make sure not to use a or  suffix as backup as  will clean those up as well.

删除旧内核
参考 kernel removal.

外部资源

 * kernel changelog with some explanations of new features