总结我的问题是我的 /boot 分区几乎已满,但由于某些依赖循环,我无法释放它。
详细说明:
我正在运行 Ubuntu 14.04.2 LTS,它的 /boot 分区几乎满了
/boot is using 97.9% of 235MB
我的内核:
$ uname -r
3.16.0-39-generic
这些是我安装的内核(由于某种原因,我使用的内核不是最新的):
$ sudo dpkg --list 'linux-image*'
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 Architecture Description
+++-=======================================-========================-========================-===================================================================================
un linux-image <none> <none> (no description available)
un linux-image-3.0 <none> <none> (no description available)
ii linux-image-3.16.0-30-generic 3.16.0-30.40~14.04.1 amd64 Linux kernel image for version 3.16.0 on 64 bit x86 SMP
ii linux-image-3.16.0-33-generic 3.16.0-33.44~14.04.1 amd64 Linux kernel image for version 3.16.0 on 64 bit x86 SMP
ii linux-image-3.16.0-34-generic 3.16.0-34.47~14.04.1 amd64 Linux kernel image for version 3.16.0 on 64 bit x86 SMP
ii linux-image-3.16.0-36-generic 3.16.0-36.48~14.04.1 amd64 Linux kernel image for version 3.16.0 on 64 bit x86 SMP
ii linux-image-3.16.0-37-generic 3.16.0-37.51~14.04.1 amd64 Linux kernel image for version 3.16.0 on 64 bit x86 SMP
ii linux-image-3.16.0-38-generic 3.16.0-38.52~14.04.1 amd64 Linux kernel image for version 3.16.0 on 64 bit x86 SMP
ii linux-image-3.16.0-39-generic 3.16.0-39.53~14.04.1 amd64 Linux kernel image for version 3.16.0 on 64 bit x86 SMP
ii linux-image-3.16.0-41-generic 3.16.0-41.55~14.04.1 amd64 Linux kernel image for version 3.16.0 on 64 bit x86 SMP
in linux-image-3.16.0-43-generic <none> amd64 (no description available)
ii linux-image-extra-3.16.0-30-generic 3.16.0-30.40~14.04.1 amd64 Linux kernel extra modules for version 3.16.0 on 64 bit x86 SMP
ii linux-image-extra-3.16.0-33-generic 3.16.0-33.44~14.04.1 amd64 Linux kernel extra modules for version 3.16.0 on 64 bit x86 SMP
ii linux-image-extra-3.16.0-34-generic 3.16.0-34.47~14.04.1 amd64 Linux kernel extra modules for version 3.16.0 on 64 bit x86 SMP
ii linux-image-extra-3.16.0-36-generic 3.16.0-36.48~14.04.1 amd64 Linux kernel extra modules for version 3.16.0 on 64 bit x86 SMP
ii linux-image-extra-3.16.0-37-generic 3.16.0-37.51~14.04.1 amd64 Linux kernel extra modules for version 3.16.0 on 64 bit x86 SMP
ii linux-image-extra-3.16.0-38-generic 3.16.0-38.52~14.04.1 amd64 Linux kernel extra modules for version 3.16.0 on 64 bit x86 SMP
iF linux-image-extra-3.16.0-39-generic 3.16.0-39.53~14.04.1 amd64 Linux kernel extra modules for version 3.16.0 on 64 bit x86 SMP
iU linux-image-extra-3.16.0-41-generic 3.16.0-41.57~14.04.1 amd64 Linux kernel extra modules for version 3.16.0 on 64 bit x86 SMP
iU linux-image-extra-3.16.0-43-generic 3.16.0-43.58~14.04.1 amd64 Linux kernel extra modules for version 3.16.0 on 64 bit x86 SMP
iU linux-image-generic-lts-utopic 3.16.0.43.34 amd64 Generic Linux kernel image
到目前为止一切顺利,现在您可以认为“只需删除不需要的内核就可以了”,但事实证明我无法清除:
$ sudo apt-get -y purge
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.
linux-image-extra-3.16.0-43-generic : Depends: linux-image-3.16.0-43-generic but it is not installed
linux-image-generic-lts-utopic : Depends: linux-image-3.16.0-43-generic but it is not installed
E: Unmet dependencies. Try using -f.
当我尝试删除一个包时,得到的结果几乎相同:
$ sudo apt-get remove --purge linux-image-3.16.0-30-generic
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.
linux-image-extra-3.16.0-30-generic : Depends: linux-image-3.16.0-30-generic but it is not going to be installed
linux-image-extra-3.16.0-43-generic : Depends: linux-image-3.16.0-43-generic but it is not going to be installed
linux-image-extra-3.16.0-45-generic : Depends: linux-image-3.16.0-45-generic but it is not going to be installed
linux-image-generic-lts-utopic : Depends: linux-image-3.16.0-45-generic but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
哦,好的,那么让我们按照 Ubuntu 的建议执行命令“apt-get -f install”...但是它不允许我这样做,因为我没有足够的空间:
$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
linux-headers-3.16.0-30 linux-headers-3.16.0-30-generic
linux-headers-3.16.0-33 linux-headers-3.16.0-33-generic
linux-headers-3.16.0-34 linux-headers-3.16.0-34-generic
linux-headers-3.16.0-37 linux-headers-3.16.0-37-generic
linux-headers-3.16.0-38 linux-headers-3.16.0-38-generic
linux-headers-3.16.0-41 linux-headers-3.16.0-41-generic
linux-headers-3.16.0-43 linux-headers-3.16.0-43-generic
linux-image-3.16.0-30-generic linux-image-3.16.0-33-generic
linux-image-3.16.0-34-generic linux-image-3.16.0-37-generic
linux-image-3.16.0-38-generic linux-image-3.16.0-41-generic
linux-image-3.16.0-43-generic linux-image-extra-3.16.0-30-generic
linux-image-extra-3.16.0-33-generic linux-image-extra-3.16.0-34-generic
linux-image-extra-3.16.0-37-generic linux-image-extra-3.16.0-38-generic
linux-image-extra-3.16.0-41-generic linux-image-extra-3.16.0-43-generic
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
linux-generic-lts-utopic linux-headers-3.16.0-45
linux-headers-3.16.0-45-generic linux-headers-generic-lts-utopic
linux-image-3.16.0-43-generic linux-image-3.16.0-45-generic
linux-image-extra-3.16.0-45-generic linux-image-generic-lts-utopic
Suggested packages:
fdutils linux-lts-utopic-tools
The following NEW packages will be installed
linux-headers-3.16.0-45 linux-headers-3.16.0-45-generic
linux-image-3.16.0-43-generic linux-image-3.16.0-45-generic
linux-image-extra-3.16.0-45-generic
The following packages will be upgraded:
linux-generic-lts-utopic linux-headers-generic-lts-utopic
linux-image-generic-lts-utopic
3 to upgrade, 5 to newly install, 0 to remove and 78 not to upgrade.
21 not fully installed or removed.
Need to get 63.5 MB/79.6 MB of archives.
After this operation, 325 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://gb.archive.ubuntu.com/ubuntu/ trusty-updates/main linux-image-3.16.0-45-generic amd64 3.16.0-45.60~14.04.1 [16.2 MB]
Get:2 http://gb.archive.ubuntu.com/ubuntu/ trusty-updates/main linux-image-extra-3.16.0-45-generic amd64 3.16.0-45.60~14.04.1 [37.6 MB]
Get:3 http://gb.archive.ubuntu.com/ubuntu/ trusty-updates/main linux-generic-lts-utopic amd64 3.16.0.45.36 [1,802 B]
Get:4 http://gb.archive.ubuntu.com/ubuntu/ trusty-updates/main linux-image-generic-lts-utopic amd64 3.16.0.45.36 [2,280 B]
Get:5 http://gb.archive.ubuntu.com/ubuntu/ trusty-updates/main linux-headers-3.16.0-45 all 3.16.0-45.60~14.04.1 [9,052 kB]
Get:6 http://gb.archive.ubuntu.com/ubuntu/ trusty-updates/main linux-headers-3.16.0-45-generic amd64 3.16.0-45.60~14.04.1 [708 kB]
Get:7 http://gb.archive.ubuntu.com/ubuntu/ trusty-updates/main linux-headers-generic-lts-utopic amd64 3.16.0.45.36 [2,268 B]
Fetched 63.5 MB in 1s (50.7 MB/s)
Selecting previously unselected package linux-image-3.16.0-45-generic.
(Reading database ... 290402 files and directories currently installed.)
Preparing to unpack .../linux-image-3.16.0-45-generic_3.16.0-45.60~14.04.1_amd64.deb ...
Done.
Unpacking linux-image-3.16.0-45-generic (3.16.0-45.60~14.04.1) ...
dpkg: error processing archive /var/cache/apt/archives/linux-image-3.16.0-45-generic_3.16.0-45.60~14.04.1_amd64.deb (--unpack):
cannot copy extracted data for './boot/vmlinuz-3.16.0-45-generic' to '/boot/vmlinuz-3.16.0-45-generic.dpkg-new': failed to write (No space left on device)
No apport report written because the error message indicates a disk full error
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 3.16.0-45-generic /boot/vmlinuz-3.16.0-45-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.16.0-45-generic /boot/vmlinuz-3.16.0-45-generic
Selecting previously unselected package linux-image-extra-3.16.0-45-generic.
Preparing to unpack .../linux-image-extra-3.16.0-45-generic_3.16.0-45.60~14.04.1_amd64.deb ...
Unpacking linux-image-extra-3.16.0-45-generic (3.16.0-45.60~14.04.1) ...
Preparing to unpack .../linux-generic-lts-utopic_3.16.0.45.36_amd64.deb ...
Unpacking linux-generic-lts-utopic (3.16.0.45.36) over (3.16.0.43.34) ...
Preparing to unpack .../linux-image-generic-lts-utopic_3.16.0.45.36_amd64.deb ...
Unpacking linux-image-generic-lts-utopic (3.16.0.45.36) over (3.16.0.43.34) ...
Selecting previously unselected package linux-headers-3.16.0-45.
Preparing to unpack .../linux-headers-3.16.0-45_3.16.0-45.60~14.04.1_all.deb ...
Unpacking linux-headers-3.16.0-45 (3.16.0-45.60~14.04.1) ...
Selecting previously unselected package linux-headers-3.16.0-45-generic.
Preparing to unpack .../linux-headers-3.16.0-45-generic_3.16.0-45.60~14.04.1_amd64.deb ...
Unpacking linux-headers-3.16.0-45-generic (3.16.0-45.60~14.04.1) ...
Preparing to unpack .../linux-headers-generic-lts-utopic_3.16.0.45.36_amd64.deb ...
Unpacking linux-headers-generic-lts-utopic (3.16.0.45.36) over (3.16.0.43.34) ...
Preparing to unpack .../linux-image-3.16.0-43-generic_3.16.0-43.58~14.04.1_amd64.deb ...
Done.
Unpacking linux-image-3.16.0-43-generic (3.16.0-43.58~14.04.1) ...
dpkg: error processing archive /var/cache/apt/archives/linux-image-3.16.0-43-generic_3.16.0-43.58~14.04.1_amd64.deb (--unpack):
cannot copy extracted data for './boot/vmlinuz-3.16.0-43-generic' to '/boot/vmlinuz-3.16.0-43-generic.dpkg-new': failed to write (No space left on device)
No apport report written because the error message indicates a disk full error
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 3.16.0-43-generic /boot/vmlinuz-3.16.0-43-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.16.0-43-generic /boot/vmlinuz-3.16.0-43-generic
Errors were encountered while processing:
/var/cache/apt/archives/linux-image-3.16.0-45-generic_3.16.0-45.60~14.04.1_amd64.deb
/var/cache/apt/archives/linux-image-3.16.0-43-generic_3.16.0-43.58~14.04.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
您知道解决这个问题的任何方法吗?
答案1
我设法按照以下示例自动化了该过程http://ubuntuforums.org/showthread.php?t=1927867&p=11706655#post11706655
dpkg -l linux-* | awk '/^ii/{ print $2 }' | grep "\-3.5." | xargs dpkg --purge --dry-run
在我的例子中,要删除所有旧的 3.5* 内核 - 用 dpkg --purge 替换 apt-get remove,因为它只是与 apt-get 进入了一个循环。
测试结果后,我删除了 --dry-run
dpkg -l linux-* | awk '/^ii/{ print $2 }' | grep "\-3.5." | xargs dpkg --purge
然后
apt-get -f install
完成损坏的安装。
答案2
我已设法通过使用以下命令逐个删除具有未满足依赖关系的软件包来修复此问题:
sudo dpkg --purge package-name
进而
sudo apt-get autoremove