开机后系统提示我都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