虚假磁盘已满错误:apt-get无法安装或删除

升级我的Ubuntu 12.04服务器时遇到以下错误。 现在apt-get无法安装或删除任何包。

解压缩linux-headers-3.13.0-62(来自... / linux-headers-3.13.0-62_3.13.0-62.102~precision1_all.deb)...
 dpkg:error handling/var/cache/apt/archives/linux-headers-3.13.0-62_3.13.0-62.102~precise1_all.deb(--unpack):
 无法创建`/usr/src/linux-headers-3.13.0-62/arch/arm/include/asm/ptrace.h.dpkg-new' 
 (在处理`./usr/src/linux-headers-3.13.0-62/arch/arm/include/asm/ptrace.h'时): 设备上没有剩余空间
没有写入apport报告,因为错误消息表明磁盘已满错误
  dpkg-deb:错误:子进程粘贴被信号杀死(断管)
处理时遇到错误:
  /var/cache/apt/archives/linux-headers-3.13.0-62_3.13.0-62.102~precise1_all.deb
 E:子进程/ usr / bin / dpkg返回错误代码(1)

虽然我不是真的没有磁盘空间,

 # df -h Filesystem Size Used Avail Use% Mounted on /dev/sda1 6.8G 4.7G 1.8G 69% / 

无论如何我的inode已满,

 # df -i Filesystem Inodes IUsed IFree IUse% Mounted on /dev/sda1 458752 455214 3538 100% / 

我有十多个旧内核,但我无法删除它们,因为我的apt-get本身就是蹩脚的。 所以我无法关注报道此类问题的post 。

唯一的选择似乎是手动删除一些较旧的内核。 它会引起任何问题吗?

还有更好的出路吗? 我可以暂时使用保留空间用于root并删除较旧的内核吗?

我知道这篇文章有点陈旧,但我找到了一个答案,对于任何可能偶然发现这篇文章的人: https : //help.ubuntu.com/community/RemoveOldKernels

如果链接断开,这里是相关的片段:

安全地删除旧内核

对于LVM系统,加密系统或有限存储系统的用户,最常见的问题是/ boot分区已满。 由于空间不足,程序包管理器无法安装挂起的升级。 此外,由于依赖性破坏,apt-get无法删除包。

可以从shell快速轻松地修复此问题。 只需识别一个或两个旧内核即可手动删除,这将为软件包管理器提供足够的空间来安装排队的升级。

$ sudo rm -rv ${TMPDIR:-/var/tmp}/mkinitramfs-* ## In Ubuntu 16.04 and earlier there may be leftover temporary ## files to delete. ## See: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=814345 $ uname -r ## This command identifies the currently-running kernel 4.2.0-21-generic ## This is the current kernel. ## DO NOT REMOVE it! $ dpkg -l | tail -n +6 | grep -E 'linux-image-[0-9]+' | grep -Fv $(uname -r) ## This command lists all the kernels excluding the booted ## kernel in the package database, and their status. rc linux-image-4.2.0-14-generic ## The oldest kernel in the database ## Status 'rc' means it's already been removed ii linux-image-4.2.0-15-generic ## The oldest installed kernel. Eligible for removal. ## Status 'ii' means Installed. ii linux-image-4.2.0-16-generic ## Another old installed kernel. Eligible for removal ii linux-image-4.2.0-18-generic ## Another old installed kernel. Eligible for removal ii linux-image-4.2.0-19-generic ## The previous good kernel. Keep iU linux-image-4.2.0-22-generic ## DO NOT REMOVE. Status 'iU' means it's not installed, ## but queued for install in apt. ## This is the package we want apt to install. ## Purge the oldest kernel package using dpkg instead of apt. ## First you need to remove the image initrd.img file manually ## due to Bug #1678187. $ sudo update-initramfs -d -k 4.2.0-15-generic $ sudo dpkg --purge linux-image-4.2.0-15-generic linux-image-extra-4.2.0-15-generic ## If the previous command fails, some installed package ## depends on the kernel. The output of dpkg tells the name ## of the package. Purge it first. ## Also purge the respective header package. $ sudo dpkg --purge linux-headers-4.2.0-15-generic ## Try also purging the common header package. $ sudo dpkg --purge linux-headers-4.2.0-15 ## Do not worry, if the previous command fails. $ sudo apt-get -f install ## Try to fix the broken dependency.
$ sudo rm -rv ${TMPDIR:-/var/tmp}/mkinitramfs-* ## In Ubuntu 16.04 and earlier there may be leftover temporary ## files to delete. ## See: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=814345 $ uname -r ## This command identifies the currently-running kernel 4.2.0-21-generic ## This is the current kernel. ## DO NOT REMOVE it! $ dpkg -l | tail -n +6 | grep -E 'linux-image-[0-9]+' | grep -Fv $(uname -r) ## This command lists all the kernels excluding the booted ## kernel in the package database, and their status. rc linux-image-4.2.0-14-generic ## The oldest kernel in the database ## Status 'rc' means it's already been removed ii linux-image-4.2.0-15-generic ## The oldest installed kernel. Eligible for removal. ## Status 'ii' means Installed. ii linux-image-4.2.0-16-generic ## Another old installed kernel. Eligible for removal ii linux-image-4.2.0-18-generic ## Another old installed kernel. Eligible for removal ii linux-image-4.2.0-19-generic ## The previous good kernel. Keep iU linux-image-4.2.0-22-generic ## DO NOT REMOVE. Status 'iU' means it's not installed, ## but queued for install in apt. ## This is the package we want apt to install. ## Purge the oldest kernel package using dpkg instead of apt. ## First you need to remove the image initrd.img file manually ## due to Bug #1678187. $ sudo update-initramfs -d -k 4.2.0-15-generic $ sudo dpkg --purge linux-image-4.2.0-15-generic linux-image-extra-4.2.0-15-generic ## If the previous command fails, some installed package ## depends on the kernel. The output of dpkg tells the name ## of the package. Purge it first. ## Also purge the respective header package. $ sudo dpkg --purge linux-headers-4.2.0-15-generic ## Try also purging the common header package. $ sudo dpkg --purge linux-headers-4.2.0-15 ## Do not worry, if the previous command fails. $ sudo apt-get -f install ## Try to fix the broken dependency. 

我跟着这个:

 sudo apt-get autoremove --purge 

我现在找到了解决问题的方法,并从/usr/src删除了几个较旧的内核以摆脱这种情况。 幸运的是一切顺利,并开始重新开始工作。

强烈建议在生产计算机上删除旧内核之前进行备份。