Ubuntu删除多余的内核
Posted 阳光与叶子
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Ubuntu删除多余的内核相关的知识,希望对你有一定的参考价值。
第一步:查看当前的内核
root@linux:~# uname -a Linux linux 4.15.0-96-generic #97-Ubuntu SMP Wed Apr 1 03:25:46 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
第二步:查看当前系统中所有内核
root@linux:~# dpkg --get-selections |grep linux console-setup-linux install libselinux1:amd64 install linux-base install linux-firmware install linux-generic install linux-headers-4.15.0-72 install linux-headers-4.15.0-72-generic install linux-headers-4.15.0-91 install linux-headers-4.15.0-91-generic install linux-headers-4.15.0-96 install linux-headers-4.15.0-96-generic install linux-headers-4.15.0-97 install linux-headers-4.15.0-97-generic install linux-headers-generic install linux-image-4.15.0-54-generic deinstall linux-image-4.15.0-55-generic deinstall linux-image-4.15.0-58-generic deinstall linux-image-4.15.0-60-generic deinstall linux-image-4.15.0-62-generic deinstall linux-image-4.15.0-64-generic deinstall linux-image-4.15.0-65-generic deinstall linux-image-4.15.0-66-generic deinstall linux-image-4.15.0-70-generic deinstall linux-image-4.15.0-72-generic install linux-image-4.15.0-74-generic deinstall linux-image-4.15.0-76-generic deinstall linux-image-4.15.0-88-generic deinstall linux-image-4.15.0-91-generic install linux-image-4.15.0-96-generic install linux-image-4.15.0-97-generic install linux-image-generic install linux-modules-4.15.0-54-generic deinstall linux-modules-4.15.0-55-generic deinstall linux-modules-4.15.0-58-generic deinstall linux-modules-4.15.0-60-generic deinstall linux-modules-4.15.0-62-generic deinstall linux-modules-4.15.0-64-generic deinstall linux-modules-4.15.0-65-generic deinstall linux-modules-4.15.0-66-generic deinstall linux-modules-4.15.0-70-generic deinstall linux-modules-4.15.0-72-generic install linux-modules-4.15.0-74-generic deinstall linux-modules-4.15.0-76-generic deinstall linux-modules-4.15.0-88-generic deinstall linux-modules-4.15.0-91-generic install linux-modules-4.15.0-96-generic install linux-modules-4.15.0-97-generic install linux-modules-extra-4.15.0-54-generic deinstall linux-modules-extra-4.15.0-55-generic deinstall linux-modules-extra-4.15.0-58-generic deinstall linux-modules-extra-4.15.0-60-generic deinstall linux-modules-extra-4.15.0-62-generic deinstall linux-modules-extra-4.15.0-64-generic deinstall linux-modules-extra-4.15.0-65-generic deinstall linux-modules-extra-4.15.0-66-generic deinstall linux-modules-extra-4.15.0-70-generic deinstall linux-modules-extra-4.15.0-72-generic install linux-modules-extra-4.15.0-74-generic deinstall linux-modules-extra-4.15.0-76-generic deinstall linux-modules-extra-4.15.0-88-generic deinstall linux-modules-extra-4.15.0-91-generic install linux-modules-extra-4.15.0-96-generic install linux-modules-extra-4.15.0-97-generic install selinux-utils install util-linux install
第三步:移除多余的内核
对于当前没有用的内核都是多余的,进行删除
root@linux:~# sudo apt-get remove linux-headers-4.15.0-70 linux-headers-4.15.0-70-generic linux-image-4.15.0-70-generic linux-modules-4.15.0-70-generic linux-modules-extra-4.15.0-70-generic
这样删除后会还会在列表中显示存在,不过是状态显示为已经卸载,如果想不显示彻底清除的话:
root@linux:~# sudo apt-get purge linux-headers-4.15.0-74 linux-headers-4.15.0-74-generic linux-image-4.15.0-74-generic linux-modules-4.15.0-74-generic linux-modules-extra-4.15.0-74-generic
卸载后进行检查:
root@linux:~# dpkg --get-selections |grep linux console-setup-linux install libselinux1:amd64 install linux-base install linux-firmware install linux-headers-4.15.0-96 install linux-headers-4.15.0-96-generic install linux-image-4.15.0-54-generic deinstall linux-image-4.15.0-55-generic deinstall linux-image-4.15.0-58-generic deinstall linux-image-4.15.0-60-generic deinstall linux-image-4.15.0-62-generic deinstall linux-image-4.15.0-64-generic deinstall linux-image-4.15.0-65-generic deinstall linux-image-4.15.0-66-generic deinstall linux-image-4.15.0-70-generic deinstall linux-image-4.15.0-72-generic deinstall linux-image-4.15.0-74-generic deinstall linux-image-4.15.0-76-generic deinstall linux-image-4.15.0-88-generic deinstall linux-image-4.15.0-91-generic deinstall linux-image-4.15.0-96-generic install linux-image-4.15.0-97-generic deinstall linux-modules-4.15.0-54-generic deinstall linux-modules-4.15.0-55-generic deinstall linux-modules-4.15.0-58-generic deinstall linux-modules-4.15.0-60-generic deinstall linux-modules-4.15.0-62-generic deinstall linux-modules-4.15.0-64-generic deinstall linux-modules-4.15.0-65-generic deinstall linux-modules-4.15.0-66-generic deinstall linux-modules-4.15.0-70-generic deinstall linux-modules-4.15.0-72-generic deinstall linux-modules-4.15.0-74-generic deinstall linux-modules-4.15.0-76-generic deinstall linux-modules-4.15.0-88-generic deinstall linux-modules-4.15.0-91-generic deinstall linux-modules-4.15.0-96-generic install linux-modules-4.15.0-97-generic deinstall linux-modules-extra-4.15.0-54-generic deinstall linux-modules-extra-4.15.0-55-generic deinstall linux-modules-extra-4.15.0-58-generic deinstall linux-modules-extra-4.15.0-60-generic deinstall linux-modules-extra-4.15.0-62-generic deinstall linux-modules-extra-4.15.0-64-generic deinstall linux-modules-extra-4.15.0-65-generic deinstall linux-modules-extra-4.15.0-66-generic deinstall linux-modules-extra-4.15.0-70-generic deinstall linux-modules-extra-4.15.0-72-generic deinstall linux-modules-extra-4.15.0-74-generic deinstall linux-modules-extra-4.15.0-76-generic deinstall linux-modules-extra-4.15.0-88-generic deinstall linux-modules-extra-4.15.0-91-generic deinstall linux-modules-extra-4.15.0-96-generic install linux-modules-extra-4.15.0-97-generic deinstall selinux-utils install util-linux install
状态为deinstall即为已经卸载
第四步:更新系统引导
删除内核后需要更新grup移除失效的启动项
root@linux:~# sudo update-grub #根据情况选择grub/grub2
======================================================
为什么要删除多余的内核,ubuntu默认自动更新内核,多余生产环境来说存在不稳定因素,有时候重启后进入不到系统提示:not syncing : VFS: Unable to mount root
解决办法就是开机的时候选择高级模式,选择之前的低版本的内核,试试那个可以进入到系统中。然后把那个高版本的内核删除掉,就能解决这个问题。
删除内核后虽然可以正常就如到系统中,但是系统默认自动更新内核的,为了避免这个情况,我们要关闭内核自动更新,
以上是关于Ubuntu删除多余的内核的主要内容,如果未能解决你的问题,请参考以下文章