From: Gordon Messmer gordon.messmer@gmail.com
The rescue kernel can only be used to boot a system normally if the corresponding kernel and modules are still available. Once they are removed, functionality is significantly reduced.
When a kernel is removed, check the rescue kernel and remove it if it matches the kernel to be removed.
The currently running kernel is assumed good, so build a rescue kernel based on this version as long as it is still installed.
diff --git a/redhat/kernel.spec.template b/redhat/kernel.spec.template index blahblah..blahblah 100644 --- a/redhat/kernel.spec.template +++ b/redhat/kernel.spec.template @@ -3846,6 +3846,9 @@ touch %{_localstatedir}/lib/rpm-state/%{name}/installing_core_%{KVERREL}%{?-v:+% %define kernel_variant_preun(v:u:) \ %{expand:%%preun %{?-v:%{-v*}-}%{!?-u*:core}%{?-u*:uki-%{-u*}}}\ /bin/kernel-install remove %{KVERREL}%{?-v:+%{-v*}} || exit $?\ +read -r MACHINE_ID < /etc/machine-id && /bin/cmp /boot/vmlinuz-0-rescue-${MACHINE_ID} boot/vmlinuz-%{KVERREL}%{?-v:+%{-v*}} &&\ + /bin/rm /boot/vmlinuz-0-rescue-${MACHINE_ID} /boot/initramfs-0-rescue-${MACHINE_ID}.img &&\ + [ -e /boot/vmlinuz-$(uname -r) ] && kernel-install add $(uname -r) /lib/modules/$(uname -r)/vmlinuz\ %if !%{with_automotive}\ if [ -x %{_sbindir}/weak-modules ]\ then\
-- https://gitlab.com/cki-project/kernel-ark/-/merge_requests/3960
From: Gordon Messmer on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/3960#note_2569565...
This change has not (yet) been tested, and is presented for discussion.
The need to maintain the rescue kernel has been discussed numerous times, including:
https://bugzilla.redhat.com/show_bug.cgi?id=1768132
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/... read/HP5V5THLK4W5S66UZZ4CBCTO5E4SST35/#HP5V5THLK4W5S66UZZ4CBCTO5E4SST35
It would be nicely symmetrical if this could be handled in kernel- install/dracut, but dracut doesn't seem to have any concept of removing a kernel. Handling this in the kernel scriptlet seems like the best place for now, even if it lacks symmetry.
kernel@lists.fedoraproject.org