由于依赖性和配置问题导致内核安装失败导致apt和dpkg失败

我见过一些类似的问题,但我见过的都没有解决我的问题。 在Ubuntu 12.04上从linux-image-3.2.0-36-genericlinux-image-3.2.0-38-generic进行内核升级时发生错误。 使用3.2.0-38启动时,引导时会发生内核3.2.0-38

在3.2.0-36下启动,系统正常启动。 但是,当我尝试删除干净或配置受影响的内核包时,它会引发以下错误:

 Reading package lists... Done Building dependency tree Reading state information... Done You might want to run 'apt-get -f install' to correct these: The following packages have unmet dependencies: initramfs-tools : Depends: initramfs-tools-bin (< 0.99ubuntu13.1~) but 0.99ubuntu13.1 is to be installed E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution). 

尝试sudo apt-get -f install ,在包retrevial​​之后没有成功引用依赖和配置问题:

 dpkg: dependency problems prevent configuration of initramfs-tools: initramfs-tools depends on initramfs-tools-bin (<= 0.36ubuntu6); however: Package initramfs-tools is not configured yet. dpkg: error processing linux-image-3.2.0-38-generic (--configure): dependency problems - leaving unconfigured No apport report written because the error message indicates its a followup error from a previous failure. No apport report written because the error message indicates its a followup error from a previous failure. dpkg: dependency problems prevent configuration of casper: casper depends on initramfs-tools (>= 0.92bubuntu55); however: Package initramfs-tools is not configured yet. dpkg: error processing casper (--configure): dependency problems - leaving unconfigured No apport report written because the error message indicates its a followup error from a previous failure. Errors were encountered while processing: initramfs-tools linux-image-3.2.0-38-generic casper E: Sub-process /usr/bin/dpkg returned an error code (1) 

运行dpkg -- configure -a时会收到类似的错误dpkg -- configure -aapt-get -f dist-upgradeapt-get -f autoremove

关于内核升级期间究竟损坏的内容以及如何在不使用Apt-get或Dpkg的情况下回滚内核版本的任何想法?

从这个问题中恢复的过程是临时删除所有有问题的包:

  dpkg --force-depends --purge  

之后修复缺少的依赖项

 apt-get install -f 

确保您的系统不在3.2.0-38内核上运行

 uname -r 

然后我建议做一个:

 dpkg --force-depends --purge linux*3.2.0-38* apt-get install -f 

导致所有这些麻烦的软件包是initramfs-tools和initramfs-tools-bin。 它们的版本在精确存储库中为0.99ubuntu13,在精确更新存储库中为0.99ubuntu13.1。 以某种方式,包列表处于不一致状态,使得尝试从每个存储库安装一个版本。

删除包列表:

 sudo rm /var/cache/apt/*.bin /var/lib/apt/lists/* /var/lib/apt/lists/partial/* 

然后运行apt-get update下载新的软件包列表,然后再次尝试apt-get -f install

这帮助我解决了这个问题:

 sudo apt-get remove grub* 

其次是

 sudo apt-get update && sudo apt-get upgrade 

希望这对你也有帮助。

用西class牙语原始答案自动翻译。