linux删除旧的内核


开机后系统提示我都boot还剩4M(我擦嘞?!
打开boot发现我有三个版本的内核,每个40+M。


自动删除命令

If your system is operating without error, you should be able to remove old kernels with a simple autoremove command in shell:

sudo apt-get autoremove --purge

in 16.04 and newer

sudo apt autoremove --purge

1.遇到一个问题
执行以上命令以后,提示错误信息:

Errors were encountered while processing:
 linux-image-extra-4.8.0-36-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

2.解决方案


For anyone who comes across this issue, use this resource http://www.khattam.info/solved-subprocess-pre-removal-script-returned-error-exit-status-2-error-2009-08-04.html#more-303
It fixed the problem for me. The packages: linux-image-2.3.0-54-virtual and linux-image were in the /var/lib/dpkg/status several times, there were doubles. Just use vim or nano, whichever your favorite editor is and remove the packages. Save it and then do sudo apt-get update. Then do sudo apt-get -f install.
Everything should work now.


手动删除内核

1.查看当前存在的内核版本:

wycheng@wycheng-ThinkCentre-XXXX:~$ dpkg -l 'linux-image-*'|grep '^ii'
ii  linux-image-4.10.0-30-generic       4.10.0-30.34~16.04.1 amd64        Linux kernel image for version 4.10.0 on 64 bit x86 SMP
ii  linux-image-4.10.0-32-generic       4.10.0-32.36~16.04.1 amd64        Linux kernel image for version 4.10.0 on 64 bit x86 SMP
ii  linux-image-extra-4.10.0-30-generic 4.10.0-30.34~16.04.1 amd64        Linux kernel extra modules for version 4.10.0 on 64 bit x86 SMP
ii  linux-image-extra-4.10.0-32-generic 4.10.0-32.36~16.04.1 amd64        Linux kernel extra modules for version 4.10.0 on 64 bit x86 SMP
ii  linux-image-generic-hwe-16.04       4.10.0.32.34         amd64        Generic Linux kernel image

2.卸载老的内核之前,首先用uname -a查看当前启动的是哪个内核(防止把当前正在使用的内核卸载了):

wycheng@wycheng-ThinkCentre-XXXX:~$ uname -a
Linux wycheng-ThinkCentre-XXXX 4.10.0-32-generic #36~16.04.1-Ubuntu SMP Wed Aug 9 09:19:02 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

3.删除指定内核

wycheng@wycheng-ThinkCentre-XXXX:~$ sudo apt-get purge Linux-image-4.10.0-30-generic

参考

RemoveOldKernels
Errors were encountered while processing linux-image-3.2.0-54-virtual

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 供给定律 当某一物品的价格更高时,企业愿意生产和销售更多的该种物品。 其结果就是供给曲线向上倾斜。 考察企业行为有...
    lang_liu阅读 4,130评论 0 0
  • 天 又下起了雨 让我想起 那把 墨绿色的折叠伞 想起我和她经历过的大风大雨 那时的我 总喜欢放声歌唱 即便只有她肯...
    卷七阅读 2,047评论 2 1