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

sou*_* c. 29 apt dpkg disk-usage inode

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

解压 linux-headers-3.13.0-62(来自 .../linux-headers-3.13.0-62_3.13.0-62.102~precise1_all.deb)...
dpkg: 错误处理 /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'):设备上
没有剩余空间没有写入报告,因为错误消息指示磁盘完全错误
 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% /  
Run Code Online (Sandbox Code Playgroud)

无论如何,我的 inode 已满,

# df -i
Filesystem     Inodes   IUsed  IFree IUse% Mounted on
/dev/sda1      458752  455214   3538  100% /
Run Code Online (Sandbox Code Playgroud)

我有十多个旧内核,但我无法删除它们,因为我apt-get自己是跛脚的。所以我无法关注这个报告类似问题的帖子

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

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

小智 42

我知道这篇文章有点旧,但我在这里为任何可能偶然发现这篇文章的人找到了答案: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 apt-get autoremove --purge
Run Code Online (Sandbox Code Playgroud)


sou*_* c. 9

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

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