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

Azure虚拟机中Ubuntu 18.04升级至20.04失败,依赖问题无法解决

Azure虚拟机中Ubuntu 18.04升级至20.04失败,依赖问题无法解决

看起来你在Azure虚拟机上升级Ubuntu 18.04到20.04时碰到了相当棘手的依赖阻塞问题,我先帮你梳理下目前的操作轨迹和遇到的核心问题:

背景与初始尝试

因为Ubuntu 18.04已停止支持,你需要升级到20.04,但最直接的升级命令sudo do-release-upgrade意外失败(没有终端响应输出),于是转而尝试手动更新包管理流程。

已执行操作及对应结果

  1. 执行sudo apt update
    更新过程正常完成,最终提示有2个可升级包:

    Hit:1 http://azure.archive.ubuntu.com/ubuntu focal InRelease
    Get:2 http://azure.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
    Get:3 http://azure.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
    Hit:4 http://security.ubuntu.com/ubuntu focal-security InRelease
    Get:5 http://azure.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [2917 kB]
    Get:6 http://azure.archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [2419 kB]
    Fetched 5558 kB in 2s (2538 kB/s)
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    2 packages can be upgraded. Run 'apt list --upgradable' to see them.
    
  2. 执行sudo apt upgrade
    触发依赖未满足错误,提示几个linux-tools包缺少对应的linux-azure-tools依赖:

    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    You might want to run 'apt --fix-broken install' to correct these.
    The following packages have unmet dependencies:
    linux-tools-5.4.0-1059-azure : Depends: linux-azure-tools-5.4.0-1059 but it is not installed
    linux-tools-5.4.0-1100-azure : Depends: linux-azure-tools-5.4.0-1100 but it is not installed
    linux-tools-5.4.0-1109-azure : Depends: linux-azure-tools-5.4.0-1109 but it is not installed
    E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
    
  3. 执行sudo apt --fix-broken install
    系统尝试自动修复依赖,准备安装缺失的linux-azure-tools包,但最终执行失败:

    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    Correcting dependencies... Done
    # 此处省略自动安装可清理包列表
    The following additional packages will be installed:
    linux-azure-tools-5.4.0-1059 linux-azure-tools-5.4.0-1100 linux-azure-tools-5.4.0-1109
    The following NEW packages will be installed:
    linux-azure-tools-5.4.0-1059 linux-azure-tools-5.4.0-1100 linux-azure-tools-5.4.0-1109
    0 upgraded, 3 newly installed, 0 to remove and 2 not upgraded.
    3 not fully installed or removed.
    Need to get 0 B/15.8 MB of archives.
    After this operation, 74.0 MB of additional disk space will be used.
    Do you want to continue? [Y/n]
    
    E: Sub-process /usr/bin/dpkg exited unexpectedly
    
  4. 执行sudo dpkg --configure -a
    依然无法解决依赖问题,三个linux-tools包因缺失依赖无法完成配置:

    dpkg: dependency problems prevent configuration of linux-tools-5.4.0-1059-azure:
    linux-tools-5.4.0-1059-azure depends on linux-azure-tools-5.4.0-1059; however:
    Package linux-azure-tools-5.4.0-1059 is not installed.
    
    dpkg: error processing package linux-tools-5.4.0-1059-azure (--configure):
    dependency problems - leaving unconfigured
    # 此处省略另外两个包的类似错误信息
    Errors were encountered while processing:
    linux-tools-5.4.0-1059-azure
    linux-tools-5.4.0-1109-azure
    linux-tools-5.4.0-1100-azure
    
  5. 尝试sudo apt autoremove
    同样被未满足的依赖阻塞,无法执行:

    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    You might want to run 'apt --fix-broken install' to correct these.
    The following packages have unmet dependencies:
    linux-tools-5.4.0-1059-azure : Depends: linux-azure-tools-5.4.0-1059 but it is not installed
    linux-tools-5.4.0-1100-azure : Depends: linux-azure-tools-5.4.0-1100 but it is not installed
    linux-tools-5.4.0-1109-azure : Depends: linux-azure-tools-5.4.0-1109 but it is not installed
    E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
    

可能的解决方向

  1. 强制移除有问题的包后再修复
    先尝试强制移除那些因依赖缺失无法配置的linux-tools包,再重新修复依赖:

    sudo dpkg --remove --force-remove-reinstreq linux-tools-5.4.0-1059-azure linux-tools-5.4.0-1100-azure linux-tools-5.4.0-1109-azure
    sudo apt --fix-broken install
    

    完成后再重新运行sudo apt update && sudo apt upgrade,之后尝试sudo do-release-upgrade。

  2. 手动下载缺失的依赖包安装
    针对三个缺失的linux-azure-tools包,从Ubuntu官方包仓库找到对应amd64架构的.deb文件(版本号分别为5.4.0-1059、5.4.0-1100、5.4.0-1109),用dpkg手动安装:

    sudo dpkg -i linux-azure-tools-5.4.0-1059_*.deb linux-azure-tools-5.4.0-1100_*.deb linux-azure-tools-5.4.0-1109_*.deb
    sudo apt --fix-broken install
    
  3. 重置包管理状态
    如果上面的方法都无效,可以尝试清理dpkg的缓存并重新初始化:

    sudo rm /var/lib/dpkg/lock-frontend
    sudo rm /var/cache/apt/archives/lock
    sudo dpkg --configure -a
    sudo apt clean && sudo apt update
    

备注:内容来源于stack exchange,提问作者Piotr Śródka

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.21 10:58:48