内核升级时出现 update-initramfs 错误怎么办?

内核升级时出现 update-initramfs 错误怎么办?

我刚刚跑了:

sudo apt-get update && sudo apt-get dist-upgrade

这是我从第二个命令得到的输出:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following NEW packages will be installed
  linux-headers-4.4.0-38 linux-headers-4.4.0-38-generic
  linux-image-4.4.0-38-generic linux-image-extra-4.4.0-38-generic
  linux-signed-image-4.4.0-38-generic
The following packages will be upgraded:
  linux-generic linux-headers-generic linux-image-generic linux-libc-dev
  linux-signed-generic linux-signed-image-generic
6 to upgrade, 5 to newly install, 0 to remove and 0 not to upgrade.
Need to get 69.3 MB of archives.
After this operation, 296 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-image-4.4.0-38-generic amd64 4.4.0-38.57 [18.7 MB]
Get:2 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-image-extra-4.4.0-38-generic amd64 4.4.0-38.57 [39.0 MB]
Get:3 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-generic amd64 4.4.0.38.40 [1,790 B]
Get:4 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-image-generic amd64 4.4.0.38.40 [2,300 B]
Get:5 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-signed-image-4.4.0-38-generic amd64 4.4.0-38.57 [3,990 B]
Get:6 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-signed-generic amd64 4.4.0.38.40 [1,820 B]
Get:7 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-signed-image-generic amd64 4.4.0.38.40 [2,332 B]
Get:8 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-headers-4.4.0-38 all 4.4.0-38.57 [9,948 kB]
Get:9 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-headers-4.4.0-38-generic amd64 4.4.0-38.57 [785 kB]
Get:10 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-headers-generic amd64 4.4.0.38.40 [2,274 B]
Get:11 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-libc-dev amd64 4.4.0-38.57 [838 kB]
Fetched 69.3 MB in 1min 26s (806 kB/s)                                         
Selecting previously unselected package linux-image-4.4.0-38-generic.
(Reading database ... 248254 files and directories currently installed.)
Preparing to unpack .../linux-image-4.4.0-38-generic_4.4.0-38.57_amd64.deb ...
Done.
Unpacking linux-image-4.4.0-38-generic (4.4.0-38.57) ...
Selecting previously unselected package linux-image-extra-4.4.0-38-generic.
Preparing to unpack .../linux-image-extra-4.4.0-38-generic_4.4.0-38.57_amd64.deb ...
Unpacking linux-image-extra-4.4.0-38-generic (4.4.0-38.57) ...
Preparing to unpack .../linux-generic_4.4.0.38.40_amd64.deb ...
Unpacking linux-generic (4.4.0.38.40) over (4.4.0.36.38) ...
Preparing to unpack .../linux-image-generic_4.4.0.38.40_amd64.deb ...
Unpacking linux-image-generic (4.4.0.38.40) over (4.4.0.36.38) ...
Selecting previously unselected package linux-signed-image-4.4.0-38-generic.
Preparing to unpack .../linux-signed-image-4.4.0-38-generic_4.4.0-38.57_amd64.deb ...
Unpacking linux-signed-image-4.4.0-38-generic (4.4.0-38.57) ...
Preparing to unpack .../linux-signed-generic_4.4.0.38.40_amd64.deb ...
Unpacking linux-signed-generic (4.4.0.38.40) over (4.4.0.36.38) ...
Preparing to unpack .../linux-signed-image-generic_4.4.0.38.40_amd64.deb ...
Unpacking linux-signed-image-generic (4.4.0.38.40) over (4.4.0.36.38) ...
Selecting previously unselected package linux-headers-4.4.0-38.
Preparing to unpack .../linux-headers-4.4.0-38_4.4.0-38.57_all.deb ...
Unpacking linux-headers-4.4.0-38 (4.4.0-38.57) ...
Selecting previously unselected package linux-headers-4.4.0-38-generic.
Preparing to unpack .../linux-headers-4.4.0-38-generic_4.4.0-38.57_amd64.deb ...
Unpacking linux-headers-4.4.0-38-generic (4.4.0-38.57) ...
Preparing to unpack .../linux-headers-generic_4.4.0.38.40_amd64.deb ...
Unpacking linux-headers-generic (4.4.0.38.40) over (4.4.0.36.38) ...
Preparing to unpack .../linux-libc-dev_4.4.0-38.57_amd64.deb ...
Unpacking linux-libc-dev:amd64 (4.4.0-38.57) over (4.4.0-36.55) ...
Setting up linux-image-4.4.0-38-generic (4.4.0-38.57) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.4.0-38-generic /boot/vmlinuz-4.4.0-38-generic
run-parts: executing /etc/kernel/postinst.d/dkms 4.4.0-38-generic /boot/vmlinuz-4.4.0-38-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.4.0-38-generic /boot/vmlinuz-4.4.0-38-generic
update-initramfs: Generating /boot/initrd.img-4.4.0-38-generic

gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-4.4.0-38-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-4.4.0-38-generic.postinst line 1052.
dpkg: error processing package linux-image-4.4.0-38-generic (--configure):
 subprocess installed post-installation script returned error exit status 2
dpkg: dependency problems prevent configuration of linux-image-extra-4.4.0-38-generic:
 linux-image-extra-4.4.0-38-generic depends on linux-image-4.4.0-38-generic; however:
  Package linux-image-4.4.0-38-generic is not configured yet.

dpkg: error processing package linux-image-extra-4.4.0-38-generic (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-image-generic:
 linux-image-generic depends on linux-image-4.4.0-38-generic; however:
  Package linux-image-4.4.0-38-generic is not configured yet.
 linux-image-generic depends on linux-image-extra-4.4.0-38-generic; however:
  Package linux-image-extra-4.4.0-38-generic is not configured yet.

dpkg: error processing package linux-image-generic (--configure):
 dependency problems - leaving unconfigured
Setting up linux-headers-4.4.0-38 (No apport report written because the error message indicates it's a follow-up error from a previous failure.
                                                               No apport report written because the error message indicates it's a follow-up error from a previous failure.
           4.4.0-38.57) ...
Setting up linux-headers-4.4.0-38-generic (4.4.0-38.57) ...
Examining /etc/kernel/header_postinst.d.
run-parts: executing /etc/kernel/header_postinst.d/dkms 4.4.0-38-generic /boot/vmlinuz-4.4.0-38-generic
Setting up linux-headers-generic (4.4.0.38.40) ...
dpkg: dependency problems prevent configuration of linux-generic:
 linux-generic depends on linux-image-generic (= 4.4.0.38.40); however:
  Package linux-image-generic is not configured yet.

dpkg: error processing package linux-generic (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-signed-image-4.4.0-38-generic:
 linux-signed-image-4.4.0-38-generic depends on linux-image-4.4.0-38-generic (= 4.4.0-38.57); however:
  Package linux-image-4.4.0-38-generic is not configured yet.

No apport report written because MaxReports has already been reached
                                                                    No apport report written because MaxReports has already been reached
                                                        dpkg: error processing package linux-signed-image-4.4.0-38-generic (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-signed-image-generic:
 linux-signed-image-generic depends on linux-signed-image-4.4.0-38-generic; however:
  Package linux-signed-image-4.4.0-38-generic is not configured yet.
 linux-signed-image-generic depends on linux-image-extra-4.4.0-38-generic; however:
  Package linux-image-extra-4.4.0-38-generic is not configured yet.

dpkg: error processing package linux-signed-image-generic (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports has already been reached
                                                                    dpkg: dependency problems prevent configuration of linux-signed-generic:
 linux-signed-generic depends on linux-signed-image-generic (= 4.4.0.38.40); however:
  Package linux-signed-image-generic is not configured yet.

dpkg: error processing package linux-signed-generic (--configure):
 dependency problems - leaving unconfigured
Setting up linux-libc-dev:amd64 (4.4.0-38.57) ...
No apport report written because MaxReports has already been reached
                                                                    Errors were encountered while processing:
 linux-image-4.4.0-38-generic
 linux-image-extra-4.4.0-38-generic
 linux-image-generic
 linux-generic
 linux-signed-image-4.4.0-38-generic
 linux-signed-image-generic
 linux-signed-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

如您所见,我在使用 update-initramfs 时遇到很多错误。由于安装过程非常糟糕,我现在不敢重新启动。

这个问题让我此错误报告,但我仍然不太清楚该怎么办,因为以前从未发生过这种情况。为什么现在会发生这种情况,我该如何解决?它说某处空间不足,这是为什么?

我正在运行带有 GNOME 3.20 的 Ubuntu GNOME 16.04.1。

答案1

原因可能是您没有足够的可用磁盘空间(可能是因为您/boot在硬盘上创建的分区太小)并且安装了太多旧内核。

彻底清理旧内核的最正确方法是使用此命令删除它们:

sudo apt purge linux-headers-* linux-headers-*-generic linux-image-*-generic linux-image-extra-*-generic linux-signed-image-*-generic

要检查系统上当前安装了哪些内核版本...请执行以下命令:

sudo dpkg --get-selections | grep linux  

4.4.0-36从命令输出中将 * 替换为内核版本(例如:) 。

示例 - 这是从内核版本完全删除所有痕迹的命令4.4.0-36

sudo apt purge linux-headers-4.4.0-36 linux-headers-4.4.0-36-generic linux-image-4.4.0-36-generic linux-image-extra-4.4.0-36-generic linux-signed-image-4.4.0-36-generic  

或者,你可以使用byobuDustin Kirkland (Canonical) 来摆脱旧内核:

sudo apt install byobu  
sudo purge-old-kernels  

这将删除所有旧内核,但保留当前内核(当然)和之前安装的内核。

答案2

您的计算机磁盘空间不足。

释放一些/boot

然后重新运行该命令。

更新:聊天我们发现该/boot分区已满。此处应释放磁盘空间。

更新 2:执行此操作ls /boot应显示一些vmlinuz-X.XX.XX文件。apt-get purge linux-image-X.XX.XX-generic对每个文件执行此操作。只需保留最新的一个,以防您安装的那个不起作用。(感谢 edwinksl 请求有关如何执行此操作的信息)。

答案3

希望这能够帮助其他人。

几个月前,我曾尝试手动安装较新的内核版本,结果与 OP 类似。
尽管/boot只使用了 30%,但在运行时,我还是遇到了同样的磁盘空间不足错误apt-get autoremove,每次都会尝试为新内核构建 initramfs,但失败了。

基于这个 AskUbuntu 问题 我移走了有问题的内核文件/var/lib/initramfs-tools,并且能够再次运行 apt-get 并且没有任何错误。

答案4

至于为什么它会发生在 Ubuntu 16.04 中,我有一个理论:

在 16.04 中,不需要的内核应该通过unattended-upgradescron 任务等默认方式自动删除,这样 /boot 就永远不会被填满,但我怀疑错误 #1624644发生了。您能确认 Launchpad 中的错误吗?

相关内容