尝试删除内核

尝试删除内核

我正在尝试删除加密系统中的旧内核。我得到了标记为清除的内核,但在我努力之后安装成功。

我首先删除以前内核更新留下的临时文件

$ sudo rm -rv ${TMPDIR:-/var/tmp}/mkinitramfs-*

我当前的版本号是 4.4.0-127-generic

经过多次尝试,这是我目前的列表。我试图保留 127(我的当前版本和 124)

$ dpkg -l | tail -n +6 | grep -E 'linux-image-[0-9]+'
pi  linux-image-4.4.0-112-generic              4.4.0-112.135                                amd64        Linux kernel image for version 4.4.0 on 64 bit x86 SMP
pi  linux-image-4.4.0-116-generic              4.4.0-116.140                                amd64        Linux kernel image for version 4.4.0 on 64 bit x86 SMP
pi  linux-image-4.4.0-119-generic              4.4.0-119.143                                amd64        Linux kernel image for version 4.4.0 on 64 bit x86 SMP
pi  linux-image-4.4.0-121-generic              4.4.0-121.145                                amd64        Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii  linux-image-4.4.0-122-generic              4.4.0-122.146                                amd64        Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii  linux-image-4.4.0-124-generic              4.4.0-124.148                                amd64        Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii  linux-image-4.4.0-127-generic              4.4.0-127.153                                amd64        Linux kernel image for version 4.4.0 on 64 bit x86 SMP

假设我尝试删除 4.4.0-119

我通过删除 initrd.img 文件释放启动空间

$ sudo update-initramfs -d -k 4.4.0-119-generic
update-initramfs: Deleting /boot/initrd.img-4.4.0-119-generic

我尝试清除内核

$ sudo dpkg --purge linux-image-4.4.0-119-generic linux-image-extra-4.4.0-119-generic

dpkg: dependency problems prevent removal of linux-image-4.4.0-119-generic:
 linux-signed-image-4.4.0-119-generic depends on linux-image-4.4.0-119-generic (= 4.4.0-119.143).

dpkg: error processing package linux-image-4.4.0-119-generic (--purge):
 dependency problems - not removing
(Reading database ... 513541 files and directories currently installed.)
Removing linux-image-extra-4.4.0-119-generic (4.4.0-119.143) ...
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.4.0-119-generic /boot/vmlinuz-4.4.0-119-generic
run-parts: executing /etc/kernel/postinst.d/dkms 4.4.0-119-generic /boot/vmlinuz-4.4.0-119-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.4.0-119-generic /boot/vmlinuz-4.4.0-119-generic
update-initramfs: Generating /boot/initrd.img-4.4.0-119-generic
run-parts: executing /etc/kernel/postinst.d/pm-utils 4.4.0-119-generic /boot/vmlinuz-4.4.0-119-generic
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.4.0-119-generic /boot/vmlinuz-4.4.0-119-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 4.4.0-119-generic /boot/vmlinuz-4.4.0-119-generic
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.4.0-119-generic /boot/vmlinuz-4.4.0-119-generic
Generating grub configuration file ...
Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.
Found linux image: /boot/vmlinuz-4.4.0-127-generic
Found initrd image: /boot/initrd.img-4.4.0-127-generic
Found linux image: /boot/vmlinuz-4.4.0-124-generic
Found initrd image: /boot/initrd.img-4.4.0-124-generic
Found linux image: /boot/vmlinuz-4.4.0-122-generic
Found initrd image: /boot/initrd.img-4.4.0-122-generic
Found linux image: /boot/vmlinuz-4.4.0-121-generic
Found initrd image: /boot/initrd.img-4.4.0-121-generic
Found linux image: /boot/vmlinuz-4.4.0-119-generic
Found initrd image: /boot/initrd.img-4.4.0-119-generic
Found linux image: /boot/vmlinuz-4.4.0-116-generic
Found initrd image: /boot/initrd.img-4.4.0-116-generic
Found linux image: /boot/vmlinuz-4.4.0-112-generic
done
Purging configuration files for linux-image-extra-4.4.0-119-generic (4.4.0-119.143) ...
Errors were encountered while processing:
 linux-image-4.4.0-119-generic

这样做会将内核的状态更改为 pi。这是我以前用来删除旧内核的方法。我不确定这里发生了什么变化。

答案1

查看您收到的错误消息:

dpkg: dependency problems prevent removal of linux-image-4.4.0-119-generic:
 linux-signed-image-4.4.0-119-generic depends on linux-image-4.4.0-119-generic (= 4.4.0-119.143).

它告诉您,删除这些包后,该包linux-signed-image-4.4.0-119-generic将具有未满足的依赖关系。因此,解决问题的方法应该是也删除这个包,因为它属于您尝试删除的内核。

尝试这个命令:

$ sudo dpkg --purge linux-image-4.4.0-119-generic linux-image-extra-4.4.0-119-generic linux-signed-image-4.4.0-119-generic

答案2

尝试从 apt 中删除:

sudo apt remove --purge linux-image-4.4.0-119-generic linux-image-extra-4.4.0-119-generic

相关内容