Gentoo Linux卸载无用内核

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

Gentoo Linux卸载无用内核

移除内核源代码

在安装新的内核并正常工作之后,旧的内核就可以移除了。

emerge的 "--depclean" 选项(缩写为 "-c" )可以用来移除所有旧的或者不用的软件版本,

例如sys-kernel/gentoo-sources

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
  • 最后,删除在引导程序的配置文件中的旧的条目。

参考文献:

相关文章
|
2月前
|
安全 网络协议 Linux
深入理解Linux内核模块:加载机制、参数传递与实战开发
本文深入解析了Linux内核模块的加载机制、参数传递方式及实战开发技巧。内容涵盖模块基础概念、加载与卸载流程、生命周期管理、参数配置方法,并通过“Hello World”模块和字符设备驱动实例,带领读者逐步掌握模块开发技能。同时,介绍了调试手段、常见问题排查、开发规范及高级特性,如内核线程、模块间通信与性能优化策略。适合希望深入理解Linux内核机制、提升系统编程能力的技术人员阅读与实践。
257 1
|
2月前
|
Ubuntu Linux
Ubuntu 23.04 用上 Linux 6.2 内核,预计下放到 22.04 LTS 版本
Linux 6.2 带来了多项内容更新,修复了 AMD 锐龙处理器设备在启用 fTPM 后的运行卡顿问题,还增强了文件系统。
|
2月前
|
Ubuntu Linux
Ubuntu 23.10 现在由Linux内核6.3提供支持
如果你想在你的个人电脑上测试一下Ubuntu 23.10的最新开发快照,你可以从官方下载服务器下载最新的每日构建ISO。然而,请记住,这是一个预发布版本,所以不要在生产机器上使用或安装它。
|
2月前
|
传感器 监控 Ubuntu
10 月发布,Ubuntu 23.10 已升级到 Linux Kernel 6.3 内核
硬件方面,Linux 6.3 引入了在 HID 中引入了原生的 Steam Deck 控制器接口,允许罗技 G923 Xbox 版赛车方向盘在 Linux 上运行;改善 8BitDo Pro 2 有线控制器的行为;并为一系列华硕 Ryzen 主板添加传感器监控。
|
2月前
|
Ubuntu Linux
Ubuntu24.04LTS默认采用Linux 6.8内核,实验性版本可通过PPA获得
IT之家提醒,当下的 Ubuntu 23.10 也是一个“短期支持版本”,该版本将在今年 7 月终止支持,而今年 4 月推出的 Ubuntu 24.04 LTS 长期支持版本将获得 5 年的更新支持。
|
2月前
|
监控 Ubuntu Linux
什么Linux,Linux内核及Linux操作系统
上面只是简单的介绍了一下Linux操作系统的几个核心组件,其实Linux的整体架构要复杂的多。单纯从Linux内核的角度,它要管理CPU、内存、网卡、硬盘和输入输出等设备,因此内核本身分为进程调度,内存管理,虚拟文件系统,网络接口等4个核心子系统。
224 0
|
2月前
|
Web App开发 缓存 Rust
|
2月前
|
Ubuntu 安全 Linux
Ubuntu 发行版更新 Linux 内核,修复 17 个安全漏洞
本地攻击者可以利用上述漏洞,攻击 Ubuntu 22.10、Ubuntu 22.04、Ubuntu 20.04 LTS 发行版,导致拒绝服务(系统崩溃)或执行任意代码。
|
2月前
|
Ubuntu 机器人 物联网
Linux Ubuntu 22.04 LTS 测试版实时内核已可申请
请注意,在启用实时内核后您需要手动配置 grub 以恢复到原始内核。更多内容请参考: