无法删除旧的 initrd.img

无法删除旧的 initrd.img

我可以摆脱 initrd.img-3.13.0-100-generic 以下是我的故障排除步骤

user@server:~$ sudo apt purge linux-image-3.13.0-100-generic
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  linux-image-3.13.0-100-generic*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 213161 files and directories currently installed.)
Purging configuration files for linux-image-3.13.0-100-generic (3.13.0-100.147) ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 3.13.0-100-generic /boot/vmlinuz-3.13.0-100-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.13.0-100-generic /boot/vmlinuz-3.13.0-100-generic

user@server:/etc/kernel/postrm.d$ sudo rm /boot/initrd.img*
user@server:/etc/kernel/postrm.d$ sudo update-initramfs -c -k all
update-initramfs: Generating /boot/initrd.img-4.15.0-135-generic
update-initramfs: Generating /boot/initrd.img-4.15.0-130-generic
update-initramfs: Generating /boot/initrd.img-3.13.0-100-generic
WARNING: missing /lib/modules/3.13.0-100-generic
Ensure all necessary drivers are built into the linux image!
depmod: ERROR: could not open directory /lib/modules/3.13.0-100-generic: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
E: amd64-microcode: unsupported kernel version!
depmod: WARNING: could not open /var/tmp/mkinitramfs_t6H6En/lib/modules/3.13.0-100-generic/modules.order: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_t6H6En/lib/modules/3.13.0-100-generic/modules.builtin: No such file or directory
mrjake@pandora:/etc/kernel/postrm.d$ ls -o /boot
total 120975
-rw-r--r-- 1 root   217458 Jan  5 12:18 config-4.15.0-130-generic
-rw-r--r-- 1 root   217458 Jan 18 12:20 config-4.15.0-135-generic
drwxr-xr-x 5 root     1024 Feb  2 16:12 grub
-rw-r--r-- 1 root 13017205 Feb  2 16:28 initrd.img-3.13.0-100-generic
-rw-r--r-- 1 root 42212519 Feb  2 16:28 initrd.img-4.15.0-130-generic
-rw-r--r-- 1 root 42213324 Feb  2 16:27 initrd.img-4.15.0-135-generic
drwx------ 2 root    12288 Oct 22  2013 lost+found
-rw-r--r-- 1 root   182704 Jan 28  2016 memtest86+.bin
-rw-r--r-- 1 root   184380 Jan 28  2016 memtest86+.elf
-rw-r--r-- 1 root   184840 Jan 28  2016 memtest86+_multiboot.bin
-rw------- 1 root  4078450 Jan  5 12:18 System.map-4.15.0-130-generic
-rw------- 1 root  4078490 Jan 18 12:20 System.map-4.15.0-135-generic
-rw------- 1 root  8388256 Jan  6 06:22 vmlinuz-4.15.0-130-generic
-rw------- 1 root  8392352 Jan 18 12:24 vmlinuz-4.15.0-135-generic

然后 initrd.img-3.13.0-100-generic 又回来了,并从我的启动分区中白白占用了 10mb。我该如何摆脱它?

答案1

检查您是否有文件/boot/vmlinu[zx]-3.13.0-100-generic。我原本以为该文件会被删除apt purge,但也许出了什么问题。

检查 20.04 安装,update-initramfs只是一个调用来linux-version list获取已安装内核版本列表的 BASH 脚本。

linux-version只是一个使用DebianLinux.pm模块获取的PERL 脚本image_list

PERL模块DebianLinux.pm查找匹配的文件/boot/vmlinuz-(或/boot/vmlinux-在某些架构上)并使用它们的名称来生成image_list.

在线可浏览的源与我在系统上看到的略有不同,因此行为可能因版本和架构的不同而有所不同。

编辑

这些是 Debian 源代码参考。它们并不都与我安装的 Ubuntu 版本完全匹配,但 Ubuntu 源代码链接似乎不正确

https://salsa.debian.org/kernel-team/initramfs-tools/-/blob/master/update-initramfs#L187

https://salsa.debian.org/kernel-team/linux-base/-/blob/master/bin/linux-version#L84

https://salsa.debian.org/kernel-team/linux-base/-/blob/master/lib/DebianLinux.pm#L87

编辑2

还要检查/var/lib/initramfs-tools/目录中的3.13.0-100-generic。在shell18.04脚本中update-initramfs,使用该目录作为版本列表(其中20.04使用linux-version)。

相关内容