You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu系统内核升级因空间不足失败且无法删除旧内核的问题求助

Ubuntu系统内核升级因空间不足失败且无法删除旧内核的问题求助

大家好,我遇到了一个Ubuntu系统升级的棘手问题,希望能得到各位的帮助:

我的系统环境

当前正在运行的内核版本:

uname -r
# 输出结果:5.15.0-60-generic

问题:apt upgrade执行失败

我执行apt upgrade时,流程卡在了linux-firmware的配置环节,具体报错如下:

Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
Get more security updates through Ubuntu Pro with 'esm-apps' enabled:
mc libmagickcore-6.q16-6-extra node-hosted-git-info imagemagick libzmq5
python2.7-minimal libmagickwand-6.q16-6 python2.7 python3-rsa mc-data
node-tar imagemagick-6.q16 libeditorconfig0 libjs-jquery-ui libopenexr24
libsdl2-2.0-0 libmysofa1 libmagickcore-6.q16-6 glances libpython2.7-minimal
libpython2.7-stdlib imagemagick-6-common
Learn more about Ubuntu Pro at https://ubuntu.com/pro
0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up linux-firmware (1.187.36) ...
update-initramfs: Generating /boot/initrd.img-5.15.0-60-generic
I: The initramfs will attempt to resume from /dev/dm-2
I: (/dev/mapper/vgubuntu-swap_1)
I: Set the RESUME variable to override this.
Error 24 : Write error : cannot write compressed block
E: mkinitramfs failure cpio 141 lz4 -9 -l 24
update-initramfs: failed for /boot/initrd.img-5.15.0-60-generic with 1.
dpkg: error processing package linux-firmware (--configure):
installed linux-firmware package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
linux-firmware
E: Sub-process /usr/bin/dpkg returned an error code (1)

这里我有个疑问:我明明已经在运行5.15.0-60-generic这个内核了,为什么系统还要尝试生成该版本的initrd镜像文件呢?

排查发现/boot分区空间不足

我猜测问题根源是磁盘空间不够,于是执行df -H查看分区使用情况:

df -H
# 输出结果:
Filesystem                 Size  Used Avail Use% Mounted on
udev                       135G     0  135G   0% /dev
tmpfs                       28G  3.0M   28G   1% /run
/dev/mapper/vgubuntu-root  982G  838G   94G  90% /
tmpfs                      136G  296M  135G   1% /dev/shm
tmpfs                      5.3M  4.1k  5.3M   1% /run/lock
tmpfs                      136G     0  136G   0% /sys/fs/cgroup
/dev/nvme0n1p2             738M  588M   97M  86% /boot
/dev/nvme0n1p1             536M  6.4M  530M   2% /boot/efi
/dev/sda2                  7.0T  1.5T  5.2T  23% /mnt/usb-8tb
tmpfs                       28G   25k   28G   1% /run/user/125
tmpfs                       28G   70k   28G   1% /run/user/1000

可以看到/boot分区使用率已经达到86%,剩余空间仅97M,应该是空间不足导致initramfs生成时写入失败。

尝试删除旧内核但无法释放空间

为了腾出/boot的空间,我打算删除旧内核,先查看了已安装的内核镜像列表:

dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n  | grep linux-image
# 输出结果:
20      linux-image-generic-hwe-20.04
9520    linux-image-5.8.0-43-generic
9927    linux-image-5.11.0-36-generic
9928    linux-image-5.11.0-37-generic
9933    linux-image-5.11.0-38-generic
9956    linux-image-5.13.0-25-generic
9956    linux-image-5.13.0-27-generic
9965    linux-image-5.13.0-28-generic
9965    linux-image-5.13.0-30-generic
9965    linux-image-5.13.0-35-generic
9968    linux-image-5.13.0-37-generic
9968    linux-image-5.13.0-39-generic
9971    linux-image-5.13.0-40-generic
9971    linux-image-5.13.0-41-generic
9971    linux-image-5.13.0-44-generic
9972    linux-image-5.13.0-48-generic
9973    linux-image-5.13.0-51-generic
9973    linux-image-5.13.0-52-generic
10775   linux-image-5.15.0-41-generic
10778   linux-image-5.15.0-43-generic
11196   linux-image-5.15.0-46-generic
11207   linux-image-5.15.0-52-generic
11208   linux-image-5.15.0-50-generic
11209   linux-image-5.15.0-48-generic
11210   linux-image-5.15.0-53-generic
11212   linux-image-5.15.0-56-generic
11214   linux-image-5.15.0-57-generic
11215   linux-image-5.15.0-58-generic
11223   linux-image-5.15.0-60-generic
11499   linux-image-5.11.0-40-generic
11502   linux-image-5.11.0-41-generic
11502   linux-image-5.11.0-43-generic
11504   linux-image-5.11.0-44-generic
11504   linux-image-5.11.0-46-generic

但奇怪的是,当我尝试删除任意一个旧内核时,系统提示只会释放0字节的空间,这让我完全摸不着头脑。

希望大家能帮我解答两个核心问题:

  1. 为什么我已经在运行5.15.0-60-generic内核,系统还要更新它的initrd文件?
  2. 为什么删除旧内核无法释放/boot空间?有没有正确的清理方法?

非常感谢各位的指导!

备注:内容来源于stack exchange,提问作者Nik

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.23 11:39:12