新闻动态

Ubuntu删除多余内核的方法

发布日期:2022-03-21 08:16 | 文章来源:脚本之家

第一步:查看当前内核

rew $ uname -a
Linux rew 4.15.0-42-generic #45~16.04.1-Ubuntu SMP Mon Nov 19 13:02:27 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

当前使用版本为: 4.15.0-42-generic

第二步:查看所有内核

rew $ dpkg --get-selections | grep linux
console-setup-linux           install
libselinux1:amd64            install
libselinux1:i386            install
linux-base               install
linux-firmware             install
linux-generic-hwe-16.04         install
linux-headers-4.15.0-42         install
linux-headers-4.15.0-39         install
linux-headers-4.15.0-39-generic     install
linux-headers-4.15.0-42-generic     install
linux-headers-generic-hwe-16.04     install
linux-image-4.15.0-39-generic      install
linux-image-4.15.0-42-generic      install
linux-image-generic-hwe-16.04      install
linux-libc-dev:amd64          install
linux-libc-dev:i386           install
linux-modules-4.15.0-39-generic     install
linux-modules-4.15.0-42-generic     install
linux-modules-extra-4.15.0-39-generic  install
linux-modules-extra-4.15.0-42-generic  install
linux-sound-base            install
pptp-linux               install
syslinux                install
syslinux-common             install
syslinux-legacy             install
util-linux               install

第三步:移除冗余内核

所有 39 版本的对我来说都是多余的,进行删除:

rew $ sudo apt-get remove \
linux-headers-4.15.0-39 \
linux-headers-4.15.0-39-generic \
linux-image-4.15.0-39-generic \
linux-modules-4.15.0-39-generic \
linux-modules-extra-4.15.0-39-generic

卸载后重新检查:

rew $ dpkg --get-selections | grep linux
console-setup-linux           install
libselinux1:amd64            install
libselinux1:i386            install
linux-base               install
linux-firmware             install
linux-generic-hwe-16.04         install
linux-headers-4.15.0-42         install
linux-headers-4.15.0-42-generic     install
linux-headers-generic-hwe-16.04     install
linux-image-4.15.0-39-generic      deinstall
linux-image-4.15.0-42-generic      install
linux-image-generic-hwe-16.04      install
linux-libc-dev:amd64          install
linux-libc-dev:i386           install
linux-modules-4.15.0-39-generic     deinstall
linux-modules-4.15.0-42-generic     install
linux-modules-extra-4.15.0-39-generic  deinstall
linux-modules-extra-4.15.0-42-generic  install
linux-sound-base            install
pptp-linux               install
syslinux                install
syslinux-common             install
syslinux-legacy             install
util-linux               install

状态为 deinstall 即已经卸载,如果觉得看着不舒服的话可以使用 purge 连配置文件里一起彻底删除,清理内核列表

rew $ sudo apt-get purge \
linux-headers-4.15.0-39 \
linux-headers-4.15.0-39-generic \
linux-image-4.15.0-39-generic \
linux-modules-4.15.0-39-generic \
linux-modules-extra-4.15.0-39-generic

第四步:更新系统引导

删除内核后需要更新 grub 移除失效的启动项

rew $ sudo update-grub #根据情况选择grub/grub2

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持本站。

版权声明:本站文章来源标注为YINGSOO的内容版权均为本站所有,欢迎引用、转载,请保持原文完整并注明来源及原文链接。禁止复制或仿造本网站,禁止在非www.yingsoo.com所属的服务器上建立镜像,否则将依法追究法律责任。本站部分内容来源于网友推荐、互联网收集整理而来,仅供学习参考,不代表本站立场,如有内容涉嫌侵权,请联系alex-e#qq.com处理。

相关文章

实时开通

自选配置、实时开通

免备案

全球线路精选!

全天候客户服务

7x24全年不间断在线

专属顾问服务

1对1客户咨询顾问

在线
客服

在线客服:7*24小时在线

客服
热线

400-630-3752
7*24小时客服服务热线

关注
微信

关注官方微信
顶部