升级内核后如何删除旧内核

在升级新的内核后,如何删除旧的内核文件?

举例来说,假设我们刚刚运行了 apt-get dist-upgrade 升级到了仓库中最新的内核版本(如从 3.2.0-30 升级到了 3.2.0-34)

Default

$ sudo apt-get dist-upgrade
Reading package lists… Done
Building dependency tree
Reading state information… Done
Calculating upgrade… Done
The following NEW packages will be installed:
libframe6 libgeis1 libgrail5 linux-headers-3.2.0-34
linux-headers-3.2.0-34-generic linux-image-3.2.0-34-generic
The following packages will be upgraded:
libgrip0 linux-headers-generic linux-image-generic
3 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 50.9 MB of archives.
After this operation, 181 MB of additional disk space will be used.
Do you want to continue [Y/n]? y

$ sudo apt-get dist-upgrade
Reading package lists… Done
Building dependency tree
Reading state information… Done
Calculating upgrade… Done
The following NEW packages will be installed:
libframe6 libgeis1 libgrail5 linux-headers-3.2.0-34
linux-headers-3.2.0-34-generic linux-image-3.2.0-34-generic
The following packages will be upgraded:
libgrip0 linux-headers-generic linux-image-generic
3 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 50.9 MB of archives.
After this operation, 181 MB of additional disk space will be used.
Do you want to continue [Y/n]? y

首先我们需要知道已经安装了哪些内核版本,可以使用下面的命令:

Default

$ dpkg --get-selections | grep linux
fonts-linuxlibertine install
libselinux1 install
linux-firmware install
linux-headers-3.2.0-30 install
linux-headers-3.2.0-30-generic install
linux-headers-3.2.0-34 install
linux-headers-3.2.0-34-generic install
linux-headers-generic install
linux-image-3.2.0-30-generic install
linux-image-3.2.0-34-generic install
linux-image-generic install
linux-libc-dev install
linux-sound-base install
pptp-linux install
syslinux install
syslinux-common install
util-linux install

$ dpkg --get-selections | grep linux
fonts-linuxlibertine install
libselinux1 install
linux-firmware install
linux-headers-3.2.0-30 install
linux-headers-3.2.0-30-generic install
linux-headers-3.2.0-34 install
linux-headers-3.2.0-34-generic install
linux-headers-generic install
linux-image-3.2.0-30-generic install
linux-image-3.2.0-34-generic install
linux-image-generic install
linux-libc-dev install
linux-sound-base install
pptp-linux install
syslinux install
syslinux-common install
util-linux install
这样,我们就可以从中找到旧的内核文件(linux-headers-3.2.0-30 linux-headers-3.2.0-30-generic linux-image-3.2.0-30-generic),相应地将他们删除:

Default

$ sudo apt-get purge linux-headers-3.2.0-30 linux-headers-3.2.0-30-generic linux-image-3.2.0-30-generic
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following packages will be REMOVED:
linux-headers-3.2.0-30* linux-headers-3.2.0-30-generic*
linux-image-3.2.0-30-generic*
0 upgraded, 0 newly installed, 3 to remove and 0 not upgraded.
After this operation, 180 MB disk space will be freed.
Do you want to continue [Y/n]? y

$ sudo apt-get purge linux-headers-3.2.0-30 linux-headers-3.2.0-30-generic linux-image-3.2.0-30-generic
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following packages will be REMOVED:
linux-headers-3.2.0-30* linux-headers-3.2.0-30-generic*
linux-image-3.2.0-30-generic*
0 upgraded, 0 newly installed, 3 to remove and 0 not upgraded.
After this operation, 180 MB disk space will be freed.
Do you want to continue [Y/n]? y

Linux Deepin 在使用 apt-get 更新与删除旧内核后会自动调用 update-grub 更新 grub.cfg 文件,这样,我们就不用担心删除旧内核后因为 grub 的配置原因而无法从新的内核启动的问题。

重启后,我们即可在新的 grub 菜单中从新内核启动。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值