Gentoo Linux卸载无用内核
移除内核源代码
在安装新的内核并正常工作之后,旧的内核就可以移除了。
emerge的 “--depclean” 选项(缩写为 “-c” )可以用来移除所有旧的或者不用的软件版本,
root # emerge --ask --depclean gentoo-sources:xx.yy.zzz
请确保不要移除正在运行的内核(关于如何升级请参考文章内核升级)。
保护内核源代码不被删除
在安装了新的内核文件之后,如果切换到新的内核之前运行了 “--depclean”,那么当前的内核源文件就会被移除。
要是要这些源文件,比如升级外部的内核模块,所以并不想移除当前的内核,而是想保留。
为了不让 “--depclean” 操作删除,可以把指定版本的内核加入到 world 文件中。
移除内核残留文件
使用 eclean-kernel
app-admin/eclean-kernel是一个简单的工具,用来移除/清理旧的内核。
移除编译的内核文件和内核编译目录,如果这些目录文件都被再被任何保留的内核使用的话。
See eclean-kernel --help post-installation for usage instructions:
user $ eclean-kernel --help
usage: eclean-kernel [-h] [-V] [-A] [-l] [-p] [-b BOOTLOADER] [-L LAYOUT] [-r ROOT] [-a] [-d] [-n NUM] [-s SORT_ORDER]
[-D] [-M] [--no-bootloader-update] [--no-kernel-install] [-x EXCLUDE]
Remove old kernel versions, keeping either N newest kernels (with -n) or only those which are referenced by a bootloader
(with -a).
optional arguments:
-h, --help show this help message and exit
-V, --version show program's version number and exit
action control:
-A, --ask Ask before removing each kernel
-l, --list-kernels List kernel files and exit
-p, --pretend Print the list of kernels to be removed and exit
system configuration:
-b BOOTLOADER, --bootloader BOOTLOADER
Bootloader used (auto, lilo, grub2, grub, yaboot, symlinks)
-L LAYOUT, --layout LAYOUT
Layout used (auto, blspec, std)
-r ROOT, --root ROOT Alternate filesystem root to use
kernel selection:
-a, --all Remove all kernels unless used by bootloader
-d, --destructive Destructive mode: remove kernels even when referenced by bootloader
-n NUM, --num NUM Leave only newest NUM kernels (see also: --sort-order)
-s SORT_ORDER, --sort-order SORT_ORDER
Kernel sort order (mtime, version); default: version
misc options:
-D, --debug Enable debugging output
-M, --no-mount Disable (re-)mounting /boot if necessary
--no-bootloader-update
Do not update bootloader configuration after removing kernels (if supported by the bootloader
--no-kernel-install Do not call kernel-install while removing kernels (if installed)
-x EXCLUDE, --exclude EXCLUDE
Exclude kernel parts from being removed (comma-separated, supported parts: vmlinuz, systemmap,
config, initramfs, modules, build, misc, emptydir)
例如,保留最新的三个内核:
手动移除
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
root #rm /boot/initramfs-X.Y.Z
- 最后,删除在引导程序的配置文件中的旧的条目。
文章介绍了如何在GentooLinux系统中安全地卸载旧内核。首先,使用emerge的--depclean选项移除内核源代码,但需确保不删除正在运行的内核。然后,通过eclean-kernel工具清理旧的内核文件和编译目录。此外,提供了手动删除内核残留文件的方法,包括删除/vmlinuz、/System.map、/config等文件以及引导程序配置文件中的旧条目。
450

被折叠的 条评论
为什么被折叠?



