Ubuntu无法启动、无法更新、boot 100%修复办法

Ubuntu无法启动、无法更新、boot 100%修复办法

背景

今天在去开一台好久没用的Ubuntu的时候,发现系统启动不了,报“Kernel panic – not syncing: VFS: Unable to mount root fs on unknown-block(0,0)” 这个错误,出现一个的一般原因是由于boot分区满了导致的,这个时候,可以尝试启动一下以前的内核版本,通过Grub的Ubuntu advance,去选一个尽可能早的版本来可用的版本来启动。

修复方式

1.尝试进入恢复模式,然后尽可能的腾出来一点空间

进入恢复模式后,选择clean,dpkg,grub,fsck执行之后,重启,看一下能不能进入,如果能进入到当前内核的版本了,那么恭喜你,可以尝试去直接看下面的清理boot的方法

2.选择一个Ubuntu advance中版本号最大的一个能进去的

选择一个旧版本中最新的版本,能进入系统的进去
进入后,直接查看下boot的空间df -h

清理boot分区的方式

1.常规方式

直接卸载旧版本的内核

  1. uname -a 查看目前在用的内核版本
  2. dpkg --get-selections|grep linux-image 显示所有的内核版本
  3. sudo apt remove linux-image-XXXX-generic 卸载旧内核,注意只保留最新的 两个 版本
  4. sudo apt autoremove 清理无用的依赖

2.暴力方式

但是有很多人可能跟我一样,在删除内核时提示

Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'linux-image-5.0.0-23-generic' for regex 'linux-image-5.0.0-23'
Note, selecting 'linux-image-5.0.0-23-lowlatency' for regex 'linux-image-5.0.0-23'
Package 'linux-image-5.0.0-23-lowlatency' is not installed, so not removed
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 linux-image-generic-hwe-18.04 : Depends: linux-image-5.3.0-46-generic but it is not going to be installed
 linux-modules-extra-5.0.0-23-generic : Depends: linux-image-5.0.0-23-generic but it is not going to be installed or
                                                 linux-image-unsigned-5.0.0-23-generic but it is not going to be installed
 linux-modules-extra-5.3.0-46-generic : Depends: linux-image-5.3.0-46-generic but it is not going to be installed or
                                                 linux-image-unsigned-5.3.0-46-generic but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

核心就是Unmet dependencies
那问题来了,这不死循环了嘛。想删除需要保持完整的依赖关系,但是没有空间啊,那就导致旧的删不掉,新的安装不上。

只好手动删除了,直接进入到``/boot`分区,将旧版本的image移动到一个别的分区,别删除,移动一下。备份保留。

然后现在看boot的空间,肯定会有空间的了,然后强制安装最新版本的内核apt-get install -f

然后,移除掉旧版本的apt-get autoremove linux-image-XXXX-generic

到这里应该就解决了

最后

建议取消掉Ubuntu的自动更新,或者将/boot空间做大一些。因为Ubuntu是会自动更新的。

关闭自动更新:

sudo apt-mark hold linux-image-x.xx.x-xx-generic
sudo apt-mark hold linux-image-extra-x.xx.x-xx-generic
原文地址:https://www.cnblogs.com/zfcode/p/12706112.html