在 Ubuntu 14.04 上执行 apt-get 操作时磁盘空间已满

在 Ubuntu 14.04 上执行 apt-get 操作时磁盘空间已满

我正在尝试在运行

$ uname -r
3.13.0-45-generic

我的机器上安装了旧内核

$ dpkg --list | grep linux-image
rc  linux-image-3.13.0-24-generic       3.13.0-24.47                     amd64        Linux kernel image for version 3.13.0 on 64 bit x86 SMP
ii  linux-image-3.13.0-45-generic       3.13.0-45.74                     amd64        Linux kernel image for version 3.13.0 on 64 bit x86 SMP
ii  linux-image-3.13.0-55-generic       3.13.0-55.94                     amd64        Linux kernel image for version 3.13.0 on 64 bit x86 SMP
ii  linux-image-3.13.0-57-generic       3.13.0-57.95                     amd64        Linux kernel image for version 3.13.0 on 64 bit x86 SMP
ii  linux-image-3.13.0-58-generic       3.13.0-58.97                     amd64        Linux kernel image for version 3.13.0 on 64 bit x86 SMP
ii  linux-image-3.13.0-59-generic       3.13.0-59.98                     amd64        Linux kernel image for version 3.13.0 on 64 bit x86 SMP
ii  linux-image-3.13.0-61-generic       3.13.0-61.100                    amd64        Linux kernel image for version 3.13.0 on 64 bit x86 SMP
rc  linux-image-extra-3.13.0-24-generic 3.13.0-24.47                     amd64        Linux kernel extra modules for version 3.13.0 on 64 bit x86 SMP
ii  linux-image-extra-3.13.0-45-generic 3.13.0-45.74                     amd64        Linux kernel extra modules for version 3.13.0 on 64 bit x86 SMP
ii  linux-image-extra-3.13.0-55-generic 3.13.0-55.94                     amd64        Linux kernel extra modules for version 3.13.0 on 64 bit x86 SMP
ii  linux-image-extra-3.13.0-57-generic 3.13.0-57.95                     amd64        Linux kernel extra modules for version 3.13.0 on 64 bit x86 SMP
ii  linux-image-extra-3.13.0-58-generic 3.13.0-58.97                     amd64        Linux kernel extra modules for version 3.13.0 on 64 bit x86 SMP
ii  linux-image-extra-3.13.0-59-generic 3.13.0-59.98                     amd64        Linux kernel extra modules for version 3.13.0 on 64 bit x86 SMP
iF  linux-image-extra-3.13.0-61-generic 3.13.0-61.100                    amd64        Linux kernel extra modules for version 3.13.0 on 64 bit x86 SMP
iU  linux-image-extra-3.13.0-62-generic 3.13.0-62.102                    amd64        Linux kernel extra modules for version 3.13.0 on 64 bit x86 SMP
iU  linux-image-generic                 3.13.0.62.69                     amd64        Generic Linux kernel image

当我尝试使用以下命令清除它们时

$ sudo apt-get purge linux-image-3.13.0-24-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.13.0-62-generic : Depends: linux-image-3.13.0-62-generic but it is not going to be installed
 linux-image-generic : Depends: linux-image-3.13.0-62-generic but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

我遇到了上述错误。

执行自动删除时出现错误

$ sudo apt-get autoremove
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.13.0-62-generic : Depends: linux-image-3.13.0-62-generic but it is not installed
 linux-image-generic : Depends: linux-image-3.13.0-62-generic but it is not installed
E: Unmet dependencies. Try using -f.

如果我运行强制安装,它会说设备上没有剩余空间。

$ sudo apt-get install -f
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.13.0-55 linux-headers-3.13.0-55-generic
  linux-headers-3.13.0-57 linux-headers-3.13.0-57-generic
  linux-headers-3.13.0-58 linux-headers-3.13.0-58-generic
  linux-headers-3.13.0-59 linux-headers-3.13.0-59-generic
  linux-image-3.13.0-55-generic linux-image-3.13.0-57-generic
  linux-image-3.13.0-58-generic linux-image-3.13.0-59-generic
  linux-image-extra-3.13.0-55-generic linux-image-extra-3.13.0-57-generic
  linux-image-extra-3.13.0-58-generic linux-image-extra-3.13.0-59-generic
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  linux-image-3.13.0-62-generic
Suggested packages:
  fdutils linux-doc-3.13.0 linux-source-3.13.0 linux-tools
The following NEW packages will be installed:
  linux-image-3.13.0-62-generic
0 upgraded, 1 newly installed, 0 to remove and 48 not upgraded.
5 not fully installed or removed.
Need to get 15.2 MB of archives.
After this operation, 42.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.voxel.net/ubuntu/ trusty-updates/main linux-image-3.13.0-62-generic amd64 3.13.0-62.102 [15.2 MB]
Fetched 15.2 MB in 4s (3,237 kB/s)                        
(Reading database ... 243451 files and directories currently installed.)
Preparing to unpack .../linux-image-3.13.0-62-generic_3.13.0-62.102_amd64.deb ...
Done.
Unpacking linux-image-3.13.0-62-generic (3.13.0-62.102) ...
dpkg: error processing archive /var/cache/apt/archives/linux-image-3.13.0-62-generic_3.13.0-62.102_amd64.deb (--unpack):
 cannot copy extracted data for './boot/vmlinuz-3.13.0-62-generic' to '/boot/vmlinuz-3.13.0-62-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.13.0-62-generic /boot/vmlinuz-3.13.0-62-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.13.0-62-generic /boot/vmlinuz-3.13.0-62-generic
Errors were encountered while processing:
 /var/cache/apt/archives/linux-image-3.13.0-62-generic_3.13.0-62.102_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

我的磁盘利用率:

$ df -k
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/sda3      955997652 5241596 911812456   1% /
none                   4       0         4   0% /sys/fs/cgroup
udev             4066160      12   4066148   1% /dev
tmpfs             815404     512    814892   1% /run
none                5120       0      5120   0% /run/lock
none             4077016       0   4077016   0% /run/shm
none              102400       0    102400   0% /run/user
/dev/sda1         190346  152098     24199  87% /boot

我如何在 Ubuntu 上腾出空间以便可以在其上安装新的应用程序?

请帮忙...

答案1

你是对的,你有足够的磁盘空间,但是当你尝试解压新图像时/它很快就会被填满,这就是你的命令失败的原因。/bootapt-get install -f

有问题的包在你的dpkg输出中,以及apt-get输出中。

您可以尝试使用,aptitude install -f看看其中一个选项是否可以为您解决问题(可能通过删除那些软件包),或者您可以尝试apt-get purge linux-image-extra-3.13.0-61-generic linux-image-extra-3.13.0-62-generic linux-image-generic 删除已安装的损坏和部分配置的软件包。

如果您迫切需要使用,dpkg请务必注意消息并在尝试删除包之前删除包上的依赖项。从上面的命令来看,如果您想走这条路,您可能应该linux-image-extra-3.13.0-55-generic在尝试删除之前先删除。linux-image-3.13.0-55-generic

请特别小心,确保不要删除正在运行的内核3.13.0-45-generic

然后,您可以apt-get autoremove删除apt-get purge剩余的不需要的内核包,然后安装您尝试安装的后续内核。

答案2

您的根文件系统(/)拥有足够的可用空间,但是/boot却没有。

仔细查看sudo apt-get install -f命令的错误输出:

Unpacking linux-image-3.13.0-62-generic (3.13.0-62.102) ...
dpkg: error processing archive /var/cache/apt/archives/linux-image-3.13.0-62-generic_3.13.0-62.102_amd64.deb (--unpack):
 cannot copy extracted data for './boot/vmlinuz-3.13.0-62-generic' to '/boot/vmlinuz-3.13.0-62-generic.dpkg-new': failed to write (No space left on device)

它正在尝试放置一个文件/boot,但文件系统没有足够的空间容纳它。

您的选择:

  1. /boot删除不再需要的文件
  2. 添加更多空间/boot。由于未使用 LVM,因此这可能很难做到。如果这是虚拟机,则可能不难。
  3. 彻底抛弃。在大多数情况下,没有必要/boot使用单独的文件系统。(/boot在考虑这个问题之前,先看看@Kassandry 的回答

如果您决定删除/boot文件系统,您可以执行以下操作。

注意:使用以下说明时请务必小心

mkdir ~/copy-of-boot-files
sudo rsync -aHS /boot/ ~/copy-of-boot-files/
sudo umount /boot
sudo rsync -AHS ~/copy-of-boot-files/ /boot/
sudo sed -i 's/.*\/boot.*/#&/' /etc/fstab

再次强调:如果你这样做,一定要非常小心。确保您有 Ubuntu 安装媒体,以便您可以启动 Linux 救援模式来修复您可能造成的任何损坏。 如果操作不当,你的系统可能会无法启动

/boot基本上,您需要创建内容的副本,卸载 /boot,将内容复制回来,并禁止/boot在启动期间挂载。

补充说明:您可能需要更新引导加载程序配置(例如update-grub,不确定该版本的 Ubuntu 使用什么)。此外,如果这是 Xen 下的半虚拟化客户机,您需要确保 domU 配置知道从新位置(sda3而不是sda1)检索内核。

相关内容