You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu 22.04服务器更新失败,依赖冲突及dpkg报错求助

Ubuntu 22.04服务器更新失败,依赖冲突及dpkg报错求助

看起来你在Ubuntu 22.04服务器上碰到了内核包依赖冲突+dpkg报错的棘手问题,尝试官方建议的apt --fix-broken install也没解决,确实让人头大。先把你的问题细节梳理清楚,再给你一套逐步排查的解决方案:

你的问题核心表现

执行更新时收到依赖冲突提示:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
linux-generic : Depends: linux-image-generic (= 5.15.0.97.92) but 5.15.0.94.91 is installed
Depends: linux-headers-generic (= 5.15.0.97.92) but 5.15.0.94.91 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

尝试修复时又触发dpkg报错:

E: Sub-process /usr/bin/dpkg returned an error code (1)
...
Errors were encountered while processing:
/tmp/apt-dpkg-install-GEMHH4/0-linux-modules-5.15.0-97-generic_5.15.0-97.107_amd64.deb
/tmp/apt-dpkg-install-GEMHH4/1-linux-image-5.15.0-97-generic_5.15.0-97.107_amd64.deb
/tmp/apt-dpkg-install-GEMHH4/2-linux-modules-extra-5.15.0-97-generic_5.15.0-97.107_amd64.deb
/tmp/apt-dpkg-install-GEMHH4/3-linux-image-generic_5.15.0.97.92_amd64.deb
/tmp/apt-dpkg-install-GEMHH4/4-linux-headers-5.15.0-97_5.15.0-97.107_all.deb
/tmp/apt-dpkg-install-GEMHH4/5-linux-headers-5.15.0-97-generic_5.15.0-97.107_amd64.deb
/tmp/apt-dpkg-install-GEMHH4/6-linux-headers-generic_5.15.0.97.92_amd64.deb
needrestart is being skipped since dpkg has failed
E: Sub-process /usr/bin/dpkg returned an error code (1)

逐步解决方案

1. 先尝试修复dpkg的未完成配置

首先让dpkg重新处理所有未配置的包:

sudo dpkg --configure -a

如果这一步能正常完成,再重新运行apt --fix-broken install试试。如果还是报错,继续下一步。

2. 强制清理损坏的内核包

针对那些报错的临时deb包对应的内核组件,强制移除它们的残留状态:

sudo dpkg -r --force-all linux-modules-5.15.0-97-generic linux-image-5.15.0-97-generic linux-modules-extra-5.15.0-97-generic linux-image-generic linux-headers-5.15.0-97 linux-headers-5.15.0-97-generic linux-headers-generic

执行时可能会有警告,不用太担心,只要能清理掉冲突状态就行。

3. 清理APT缓存并更新源

清理旧的缓存包,重新拉取最新的源信息:

sudo apt clean
sudo apt update

4. 再次尝试修复依赖

现在再跑一次依赖修复命令:

sudo apt --fix-broken install

5. 若仍失败,尝试降级内核包到当前兼容版本

如果上面的步骤都没解决,可以把linux-generic及其依赖降级到你当前已安装的5.15.0.94.91版本:

sudo apt install linux-generic=5.15.0.94.91 linux-image-generic=5.15.0.94.91 linux-headers-generic=5.15.0.94.91

完成后再尝试正常更新:

sudo apt upgrade

额外排查点

  • 检查磁盘空间:用df -h看看/tmp目录和根分区是否满了,dpkg处理包需要足够的临时空间
  • 暂时禁用第三方源:你提到安装了Plex,可以先注释掉Plex的源配置(一般在/etc/apt/sources.list.d/下),完成系统更新后再重新启用

备注:内容来源于stack exchange,提问作者Brad Purgett

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.20 08:34:36