卸载 linux-image-xxx 但更新 initramfs:生成 /boot/initrd.img-4.4.250-0404250-generic

卸载 linux-image-xxx 但更新 initramfs:生成 /boot/initrd.img-4.4.250-0404250-generic

/boots 只有 200M,所以我尝试删除未使用的 linux-image,例如

sudo apt-get purge linux-image-4.4.250*

并检查

$ dpkg --list|grep linux-image
ii  linux-image-4.4.0-210-generic          4.4.0-210.242                                       amd64        Signed kernel image generic
ii  linux-image-generic                    4.4.0.210.216                                       amd64        Generic Linux kernel image
$ dpkg --list|grep linux-headers
ii  linux-headers-4.4.0-210                4.4.0-210.242                                       all          Header files related to Linux kernel version 4.4.0
ii  linux-headers-4.4.0-210-generic        4.4.0-210.242                                       amd64        Linux kernel headers for version 4.4.0 on 64 bit x86 SMP
ii  linux-headers-generic                  4.4.0.210.216                                       amd64        Generic Linux kernel headers

但是我尝试 sudo apt-get 之后,它显示仍然更新 4.4.250 版本的 initramfs,/boot 再次满了:

$ sudo apt-get autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 248 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up linux-firmware (1.173.21) ...
update-initramfs: Generating /boot/initrd.img-4.4.250-0404250-generic
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/x86_64-linux-gnu_EGL.conf: No such file or directory

gzip: stdout: No space left on device
E: mkinitramfs failure find 141 cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-4.4.250-0404250-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)

我不确定我还能做什么?如何释放 /boot 的空间?寻找任何解决方案,我将不胜感激

答案1

200 MiB 相当小。最多保留两个内核/boot已经是您应该清理的最大值。增加 /boot 分区的大小是最好的解决方案,但还有其他方法可以解决此问题:

  • 使用比 gzip 更强的压缩(参见 initramfs.conf 手册页):
COMPRESS=xz
COMPRESSLEVEL=9
  • 使用MODULES=dep而不是默认的MODULES=most。注意:这将使安装的可移植性降低。因此,在更换硬件或将磁盘移入新系统时要小心。

相关内容