升级内核时“gzip:stdout:设备上没有剩余空间”

Sha*_*jun 36 dpkg

我在尝试运行下面显示的命令时看到以下错误。我在某处读到我的 /boot 分区磁盘空间不足。如何增加 /boot 分区的大小以便安装更多软件?我有一个 500GB 的硬盘,所以有足够的空间来玩。

sudo apt-get install libdvdread4

gzip: stdout: No space left on device                                                                                                                                                                              
   E: mkinitramfs failure cpio 141 gzip 1                                                                                                                                                                             
   update-initramfs: failed for /boot/initrd.img-3.2.0-33-generic with 1.                                                                                                                                             
   run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1                                                                                                                                        
   Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-3.2.0-33-generic.postinst line 1010.                                                                                                    
   dpkg: error processing linux-image-3.2.0-33-generic (--configure):                                                                                                                                                 
    subprocess installed post-installation script returned error exit status 2                                                                                                                                        
   dpkg: dependency problems prevent configuration of linux-image-server:                                                                                                                                             
   linux-image-server depends on linux-image-3.2.0-33-generic; however:                                                                                                                                              
     Package linux-image-3.2.0-33-generic is not configured yet.
   dpkg: error processing linux-image-server (--configure):
    dependency problems - leaving unconfigured
   dpkg: dependency problems prevent configuration of linux-server:
    linux-server depends on linux-image-server (= 3.2.0.33.36); however:
     Package linux-image-server is not configured yet.
   dpkg: error processing linux-server (--configure):
    dependency problems - leaving unconfigured
   No apport report written because the error message indicates its a followup error from a   previous failure.
                                                                                                          No apport report written because the error message indicates its a followup error from a previous failure.
 Errors were encountered while processing:
 linux-image-3.2.0-33-generic
 linux-image-server
 linux-server
N: Ignoring file 'michael-gruz-canon-precise.list.1' in directory '/etc/apt/sources.list.d/' as it has an invalid filename extension
N: Ignoring file 'michael-gruz-canon-precise.list.1' in directory '/etc/apt/sources.list.d/' as it has an invalid filename extension
Run Code Online (Sandbox Code Playgroud)

下面列出的是输出 du

Filesystem              1K-blocks      Used Available Use% Mounted on
/dev/mapper/ubuntu-root 712660664 104095912 572363692  16% /
udev                      3964792         4   3964788   1% /dev
tmpfs                     1591012      1064   1589948   1% /run
none                         5120         0      5120   0% /run/lock
none                      3977528       684   3976844   1% /run/shm
/dev/sda1                  233191    219821       929 100% /boot
Run Code Online (Sandbox Code Playgroud)

tho*_*ter 69

您有一个单独的分区/boot,大小仅为 227MB 左右。此分区已满。

Ubuntu 为您提供了一个单独的 /boot 分区的原因似乎是您在驱动器的其余部分使用了 LVM 和/或“完整”磁盘加密。

/boot目录包含您的所有内核映像,因此此问题的可能原因是您安装了太多以前的内核。Ubuntu 发布内核更新,即使对于长期稳定版本,也会相当频繁地增加包名称中的版本号,所以随着时间的推移,如果您使系统保持最新,/boot目录将会增长。

您应该能够列出已安装的内核

aptitude search ~ilinux-image
Run Code Online (Sandbox Code Playgroud)

(请注意,这也可能会返回非内核的包)。

通常不需要安装两个以上的内核 - 当前正在使用的内核和以前已知的工作内核(作为后备)。所以你可以开始一个一个地删除旧的,像这样:

sudo apt-get autoremove linux-image-3.2.0-23-generic
Run Code Online (Sandbox Code Playgroud)

确保将“3.2.0-23-generic”替换为要删除的实际内核版本!另外,不要删除诸如linux-image-generic. 您必须非常小心,不要删除当前正在运行的内核,否则您将无法启动(Ubuntu 可能会也可能不会警告您这样做)。

您可以使用以下命令找到当前正在运行的内核:

uname -r
Run Code Online (Sandbox Code Playgroud)

这是我刚刚解释的内容的图解指南。本文使用的工具略有不同,但方法基本相同。

  • 要在 Ubintu 16.04 上列出已安装的内核:------ apt list --installed | sed -rn 's|^(linux-image-[0-9].*-generic)|\1 |p' ------- 上面的“能力搜索...”没有正常工作。非常有帮助的答案,谢谢。 (3认同)