前言:在linux使用好几个月后,开机的时候总是会提醒/boot 空间不足,我当时想下次重装系统的时候一定给/boot 分配个几个G,100多M不大够用,可是我点linux对应的报告问题的时候,Linux提示这是已知问题,已解决,然后学习了一下解决方法。

参考链接:https://help.ubuntu.com/community/RemoveOldKernels

1. 问题产生原因

LVM installs and encrypted installs use a separate /boot partition. The partition by default is capable of holding only four or five kernels, and can fill to capacity quickly. To prevent your /boot partition from getting full, you need to configure automatic removal of old kernels, or manually remove old kernels regularly.

Changing the kernel providing packages on your system requires commands with root access, so please read RootSudo.

简单说来就是随着linux kernel的更新,系统中包含的kernel越来越多,最后会将本来就不大的/boot空间填满。解决方法有两个,一个是配置自动移除老的kernels,另外是手动移除。

如下图所示,标红处在我进行kernel清除之前都是installed的状态,都占着/boot的空间,导致新的kernel版本安装不了。

PS:

1.查看自己kernel所处版本命令

jiatai@jiatai:~$ uname -r
4.13.0-39-generic

2.查看历史kernel安装命令

dpkg --get-selections|grep linux

3.卸载某个kernel版本

sudo apt-get remove linux-image-4.13.0-32(版本号见上面历史kernel获取)

这个方法是从网上找到的,参考链接中有提到安全卸载方法:

$ sudo update-initramfs -d -k 4.2.0-15-generic
$ sudo dpkg --purge linux-image-4.2.0-15-generic linux-image-extra-4.2.0-15-generic
                                  ## If the previous command fails, some installed package
                                  ## depends on the kernel. The output of dpkg displays the name
                                  ## of the package. Purge it first.
$ sudo apt-get -f install         ## Try to fix the broken dependency.

2. 解决方法

2.1 手动解决

sudo apt-get autoremove --purge

看下这个命令的作用:

所以这个命令的作用应该是卸载所有自动安装且不再使用的软件包并且卸载和清除对应软件包的配置。

2.2 自动解决

14.04有两个步骤,16.04只有第二步,第一步默认实现。

2.2.1 Enable Unattended Upgrades (Ubuntu 14.04)

简单说来就是打开软件自动更新和安装。


对应英文段落:

In Ubuntu 16.04 and later unattended-upgrades is enabled by default, however in Ubuntu 14.04 you will need to enable it either via the GUI or a command-line.

GUI WAY

Enable unattended upgrades using Software & Updates application's "Updates" tab:

  • Check the box for *-security (and/or any other repositories you wish)
  • Automatically check for updates: Set to any frequency (except 'Never')
  • When there are security updates: Set to Download and Install Automatically

SHELL WAY

sudo dpkg-reconfigure -plow unattended-upgrades

2.2.2 Configure Unattended Upgrades to Remove Unneeded Kernels Automatically

第二步是配置自动升级的时候移除不再需要的kernels,但是配置会将所有不再需要的依赖都移除,其中包括kernels。

修改文件/etc/apt/apt.conf.d/50unattended-upgrades 中如下所示,去除注释以及将默认的false改成true。

同时有提及说上面的文件不要包含如下语句,我检查了下没有。

Unattended-Upgrade::Remove-New-Unused-Dependencies "false"


对应英文段落:

Note: The following methods will only remove kernels that are marked as being automatically installed as described above. In Ubuntu 16.04 kernels installed by Software Updater are marked as being automatically installed. In Ubuntu 14.04 only kernels installed by unattended-upgrades are marked as being automatically installed. See bug #1439769 for details.

Note: This way will not remove all automatically installed old kernel providing packages as fallback versions are kept; the list of kept kernels is maintained and automatically updated in the file /etc/apt/apt.conf.d/01autoremove-kernels as a list of matching regular expressions.

The second step is to edit the configuration file /etc/apt/apt.conf.d/50unattended-upgrades to enable automatic removal. It's owned by root, so remember to use sudo!

Option for All Ubuntu Releases

The following setting configures unattended-upgrade to remove unused dependencies after an unattended upgrade.

Make sure /etc/apt/apt.conf.d/50unattended-upgrades contains line

Unattended-Upgrade::Remove-Unused-Dependencies "true";

and that it is not commented out. Comments start with '//' in this file.

Thereafter unattended-upgrades will remove automatically remove packages providing old kernels as part of unattended upgrade. (It does not purge them, however.) It also removes other unneeded packages, as well.

Option for Ubuntu 16.04 and newer

Unattended-upgrades version 0.90 supports a new configuration variable that makes it possible to automatically remove only packages that become excessive during a run of unattended-upgrades. It is enabled i.e. "true" by default, so make sure /etc/apt/apt.conf.d/50unattended-upgrades does not contain:

Unattended-Upgrade::Remove-New-Unused-Dependencies "false"

The way this is designed, it is important that you let unattended-upgrades handle installion of security updates. Otherwise unattended-uprades will not remove old kernels and you may have to do some manual removing of kernels.

后面还有一段手动移除的讲了比较复杂,遇到问题的小伙伴可以对照修改。

(三十) Ubuntu解决/boot 空间不足问题相关推荐

  1. Ubuntu 提示boot空间不足的解决办法

    系统用久了就会出现各种问题,这一点windows表现的格外明显,Linux也不例外,当然啦,在稳定性方面Linux肯定是远胜于windows.我电脑的Ubuntu系统已经使用了有快两年了,刚刚出现了卷 ...

  2. Ubuntu提示boot空间不足

    Ubuntu会经常更新内核,内核都储存在\boot分区中,当储存的版本过多空间不够的时候就会出现boot空间不足的提示 解决办法:卸载不使用的内核. 1.为避免卸载到当前使用的内核要先使用 uname ...

  3. linux系统解决boot空间不足

    有时候更新Linux系统是会碰到boot空间不足的错误,原因基本上是安装时boot空间设置问题可以通过删除旧的内核来释放boot空间. ubuntu: 1.查看当前使用内核版本号 uname -a(完 ...

  4. linux扩大 boot分区大小,Ubuntu扩大boot空间

    Ubuntu安装时按一般情况,BOOT分配了100MB,不久升级就显示空间不足. 刚开始还能删除旧的内核解决问题,后来删了旧内核也不够. 决定扩大一下BOOT分区大小. 用GParted工具发现,不好 ...

  5. Ubuntu扩大boot空间

    2019独角兽企业重金招聘Python工程师标准>>> Ubuntu安装时按一般情况,BOOT分配了100MB,不久升级就显示空间不足. 刚开始还能删除旧的内核解决问题,后来删了旧内 ...

  6. SpringBoot:三十五道SpringBoot面试题及答案!

    SpringBoot面试 前言 今天博主将为大家分享三十五道SpringBoot面试题及答案,不喜勿喷,如有异议欢迎讨论! Spring Boot 是微服务中最好的 Java 框架. 我们建议你能够成 ...

  7. linux空间不足 进不了系统更新,ubuntu更新时提示/boot空间不足的解决方法

    很多同学都是在自己的机器上安装双系统,也就是说用来装linux的空间不会很多.在装的过程中都喜欢把boot挂单独挂分区,一般设置100M, 可随着linux升级,往往会攒下好几个内核,某一天系统会提示 ...

  8. ubuntu boot空间不足_安装 Ubuntu 双系统

    在很久以前就想试一试Linux了,一直没有实践.一是觉得太麻烦,二是怕把电脑弄坏.后来实践了一次后发现,其实并没有想象中那么难,这是一个完全独立的系统,与隔壁的Windows半毛钱关系都没有.把引导搞 ...

  9. 精选Spring Boot三十五道必知必会知识点!

    Spring Boot 是微服务中最好的 Java 框架. 我们建议你能够成为一名 Spring Boot 的专家.本文精选了三十五个常见的Spring Boot知识点,祝你一臂之力! 问题一 Spr ...

最新文章

  1. ORACLE 日期查询
  2. 在 Redis 中设置了过期时间的 Key,需要注意哪些问题?
  3. 近世代数--置换群--置换permutation分解成什么?置换的级如何计算?
  4. Android7.0 PowerManagerService亮灭屏分析(二)
  5. React开发(249):react项目理解 ant design input loading
  6. 基于Tablestore管理海量快递轨迹数据架构实现
  7. 怎么知道eclipse的workspace的路径
  8. nignx解决vue部署服务器刷新页面出现404问题
  9. 第一个自动化运维程序
  10. 孔夫子旧书网接口:实现输入ISBN获取图书信息
  11. Java实验14 计算多个二维图形的面积之和
  12. 视频聊天软件的快速开发(QT5.3)
  13. Android 去掉标题栏
  14. 远程桌面连接时无法访问远程计算机的计算机属性提示系统调用失败,远程过程调用失败【应对技巧】...
  15. python爬取微信公众号文章(包含文章内容和图片)
  16. 【Auto.js】QQ名片点赞
  17. 提高农业品牌互联网曝光度的“四个一工程”
  18. WordPress升级后,新版编辑器不能使用解决办法
  19. 计算机公司经营范围安防监控,监控安防在个体经营范围怎么写?
  20. 从面试官的角度,来聊聊培训班对程序员的帮助!

热门文章

  1. 半对数坐标matlab实现
  2. FPGA AD0809 Verilog implement
  3. 51单片机Proteus仿真+Keil工程-实验7-单片机AD和DA实验
  4. 小学认识计算机课件ppt课件,小学生认识计算机PPT教育课件.ppt
  5. 网络报修信息管理代码java_javaweb在线报修维修系统、java+ssh+mysql实现
  6. c语言在线答疑,C语言程序设计问题答疑材料(辅导老
  7. Windows Server 2008 显示隐藏文件 扩展名
  8. sql server数据库怎样收缩数据库?
  9. 【爱加密】Android App应用安全加固详细步骤
  10. 《世界因你而不同-李开复自传》读书笔记(2/3)