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

这篇文章描述如何移除旧的kernel

移除内核源代码

在安装新的内核并正常工作之后,旧的内核就可以移除了。emerge的 "--depclean" 选项(缩写为 "-c" )可以用来移除所有旧的或者不用的软件版本,例如sys-kernel/gentoo-sources

root #emerge --ask --depclean gentoo-sources

请确保不要移除正在运行的内核(关于如何升级请参考文章内核升级)。

保护内核源代码不被删除

在安装了新的内核文件之后,如果切换到新的内核之前你运行了 "--depclean",那么当前的内核源文件就会被移除。要是你需要这些源文件,比如升级外部的内核模块,所以并不想移除当前的内核,而是想保留它。为了不让 "--depclean" 操作删除它,你最好可以把指定版本的内核加入到你的 world 文件中。

root #emerge --ask --noreplace gentoo-sources:3.3.8

注意 slot 符号,使用冒号而不是破折号。每个内核版本有自己的 slot。

移除内核残留文件

使用 eclean-kernel

app-admin/eclean-kernel是一个简单的工具,用来移除/清理旧的内核。它移除编译的内核文件和内核编译目录,如果这些目录文件都被再被任何保留的内核使用的话。

例如,保留最新的三个内核:

root #eclean-kernel -n 3

手动移除

Portage只移除它安装的文件——在内核编译和安装时候产生的文件。他们可以被安全的删除。

  • 当内核在源文件目录编译的时候,在编译过程中生成的文件会保留,不会被Portage删除。
root #rm -r /usr/src/linux-3.X.Y
  • 在内核配置过程中,内核模块会被拷贝到 /lib/modules/ 子目录中:
root #rm -r /lib/modules/3.X.Y
  • /boot中的旧文件也可以删除:
root #rm /boot/vmlinuz-3.X.Y
root #rm /boot/System.map-3.X.Y
root #rm /boot/config-3.X.Y
  • 最后,删除在你的引导程序的配置文件中的旧的条目。