Software-Installation

dpkg:依賴問題阻止了 initramfs-tools 的配置

  • April 27, 2016

我像往常一樣使用這個命令開始升級我的 Kubuntu 12.04 系統:

sudo apt-get --show-upgraded dist-upgrade

後來我回來了,但失敗了:

Preconfiguring packages ...
(Reading database ... 478306 files and directories currently installed.)
Preparing to replace  ...
Unpacking replacement base-files ...
Processing triggers for man-db ...
Processing triggers for install-info ...
...
Processing triggers for initramfs-tools ...
update-initramfs: Generating /boot/initrd.img-3.8.0-32-lowlatency

gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-3.8.0-32-lowlatency with 1.
dpkg: error processing initramfs-tools (--unpack):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
initramfs-tools
E: Sub-process /usr/bin/dpkg returned an error code (1)

這是問題: $ df -h 輸出:

Filesystem                    Size  Used Avail Use% Mounted on
/dev/sda1                     894M  879M     0 100% /boot

手動刪除舊文件,現在有一些空間可用

Filesystem                    Size  Used Avail Use% Mounted on
/dev/sda1                     894M  129M  717M  16% /boot

我接下來執行了這個:

sudo apt-get autoremove

下一個:

sudo apt-get -f install輸出:

The following extra packages will be installed:
 initramfs-tools
The following packages will be upgraded:
 initramfs-tools

dpkg: dependency problems prevent configuration of initramfs-tools:
initramfs-tools depends on initramfs-tools-bin (<< 0.99ubuntu13.3.1~); however:
 Version of initramfs-tools-bin on system is 0.99ubuntu13.4.
dpkg: error processing initramfs-tools (--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
E: Sub-process /usr/bin/dpkg returned an error code (1)

sudo apt-get install initramfs-tools

以上失敗

dpkg -l initramfs-tools輸出:

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version        Description
+++-==============-==============-============================================
iF  initramfs-tool 0.99ubuntu13.3 tools for generating an initramfs

sudo apt-get install --reinstall initramfs-tools輸出:

The following packages will be upgraded:
 initramfs-tools
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 0 B/49.2 kB of archives.
After this operation, 0 B of additional disk space will be used.
dpkg: dependency problems prevent configuration of initramfs-tools:
initramfs-tools depends on initramfs-tools-bin (<< 0.99ubuntu13.3.1~); however:
 Version of initramfs-tools-bin on system is 0.99ubuntu13.4.
dpkg: error processing initramfs-tools (--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
E: Sub-process /usr/bin/dpkg returned an error code (1)

這是輸出apt-cache policy initramfs-tools-bin initramfs-tools

initramfs-tools-bin:
 Installed: 0.99ubuntu13.4
 Candidate: 0.99ubuntu13.4
 Version table:
*** 0.99ubuntu13.4 0
       500 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main amd64 Packages
       100 /var/lib/dpkg/status
    0.99ubuntu13 0
       500 http://us.archive.ubuntu.com/ubuntu/ precise/main amd64 Packages
initramfs-tools:
 Installed: 0.99ubuntu13.3
 Candidate: 0.99ubuntu13.4
 Version table:
    0.99ubuntu13.4 0
       500 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main amd64 Packages
*** 0.99ubuntu13.3 0
       100 /var/lib/dpkg/status
    0.99ubuntu13 0
       500 http://us.archive.ubuntu.com/ubuntu/ precise/main amd64 Packages

如下所示,這是我接下來的步驟:

$ sudo apt-get update
$ sudo apt-get -f install initramfs-tools=0.99ubuntu13 initramfs-tools-bin=0.99ubuntu13

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
 ...
Use 'apt-get autoremove' to remove them.
The following packages will be DOWNGRADED:
 initramfs-tools initramfs-tools-bin
0 upgraded, 0 newly installed, 2 downgraded, 0 to remove and 4 not upgraded.
1 not fully installed or removed.
Need to get 59.2 kB of archives.
After this operation, 2,048 B disk space will be freed.
Do you want to continue [Y/n]? 
Get:1 http://us.archive.ubuntu.com/ubuntu/ precise/main initramfs-tools all 0.99ubuntu13 [49.2 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ precise/main initramfs-tools-bin amd64 0.99ubuntu13 [9,988 B]
Fetched 59.2 kB in 0s (124 kB/s)            
dpkg: warning: downgrading initramfs-tools-bin from 0.99ubuntu13.4 to 0.99ubuntu13.
(Reading database ... 478624 files and directories currently installed.)
Preparing to replace initramfs-tools-bin 0.99ubuntu13.4 (using .../initramfs-tools-bin_0.99ubuntu13_amd64.deb) ...
Unpacking replacement initramfs-tools-bin ...
Setting up initramfs-tools-bin (0.99ubuntu13) ...
dpkg: dependency problems prevent configuration of initramfs-tools:
initramfs-tools depends on initramfs-tools-bin (>= 0.99ubuntu13.3); however:
 Version of initramfs-tools-bin on system is 0.99ubuntu13.
dpkg: error processing initramfs-tools (--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
E: Sub-process /usr/bin/dpkg returned an error code (1)

接下來我嘗試了 Giles 的建議:

sudo dpkg --configure -a --force-depends
sudo apt-get install -f
sudo apt-get dist-upgrade

您的系統處於我認為不應該發生的狀態:您的新版本依賴項initramfs-tools-bin處於已安裝狀態,但舊版本的依賴initramfs-tools項處於半安裝狀態。我不確定問題是否在於 APT 讓系統進入無法恢復的狀態,dpkg 讓系統進入無法恢復的狀態,包維護者使用了依賴項的組合不支持,或者我有限的理解不包括這種情況。

嘗試dpkg直接使用:

dpkg --configure -a

如果這仍然抱怨依賴關係,請嘗試

dpkg --configure -a --force-depends

如果這可行,則您的 dpkg 數據庫處於一致狀態。您需要使 APT 處於良好狀態(不需要破壞依賴項):

apt-get -f install

在此之後,您可以恢復正常升級。


如果您的清除/boot是刪除軟體包中的舊核心,您將無法再刪除核心軟體包。您必須重新創建文件。touch cat /var/lib/dpkg/info/linux-image-1.2.3-foo``如果您要刪除linux-image-1.2.3-foo軟體包並手動刪除了其中的一些文件,則可以創建空文件 ( )。

引用自:https://unix.stackexchange.com/questions/109698