Regenerating the vmlinuz and initramfs for the rescue kernel of currently installed kernel under CentOS Stream 9 is really simple. There is a package dracut-config-rescue, which delivers a bash script (/usr/lib/kernel/install.d/51-dracut-rescue.install) to help generate a rescue kernel.
STEP 1) Move the old rescue kernel in a backup directory.
Remove the current rescue kernel from the /boot.
[root@srv ~]# ls -altr /boot/|grep rescue -rwxr-xr-x. 1 root root 10030216 Apr 12 2021 vmlinuz-0-rescue-b2a198ecbfdd451cb905f76f825af01e -rw-------. 1 root root 77700560 Apr 12 2021 initramfs-0-rescue-b2a198ecbfdd451cb905f76f825af01e.img [root@srv ~]# mkdir /tmp/old-rescue [root@srv ~]# mv /boot/*-rescue-* /tmp/old-rescue/ [root@srv ~]# ls -altr /tmp/old-rescue/ total 85684 -rwxr-xr-x. 1 root root 10030216 Apr 12 2021 vmlinuz-0-rescue-b2a198ecbfdd451cb905f76f825af01e -rw-------. 1 root root 77700560 Apr 12 2021 initramfs-0-rescue-b2a198ecbfdd451cb905f76f825af01e.img drwxrwxrwt. 9 root root 4096 Oct 5 10:00 .. drwxr-xr-x. 2 root root 4096 Oct 5 10:01 . [root@srv ~]# mv /boot/loader/entries/b2a198ecbfdd451cb905f76f825af01e-0-rescue.conf /tmp/old-rescue/
STEP 2) Regenerate the rescue kernel and the Grub boot entry.
Regenerate the with the /usr/lib/kernel/install.d/51-dracut-rescue.install the rescue kernel and the Grub entry by executing the following command:
[root@srv ~]# /usr/lib/kernel/install.d/51-dracut-rescue.install add $(uname -r) /boot /boot/vmlinuz-$(uname -r)
The command does not output anything on successful generation, but there are 3 new files with rescue in the name:
[root@srv ~]# find /boot/ -name '*rescue*' /boot/loader/entries/b2a198ecbfdd451cb905f76f825af01e-0-rescue.conf /boot/vmlinuz-0-rescue-b2a198ecbfdd451cb905f76f825af01e /boot/initramfs-0-rescue-b2a198ecbfdd451cb905f76f825af01e.img
Here are the valid arguments to generate the rescue kernel:
- add – the command what to do the script.
- kernel version – the kernel version, for which the script to generate the rescue kernel.
- boot directory – the boot directory, where the rescue kernel will be saved.
- kernel image – the kernel image against the script will produce the rescue kernel.
Bonus) Additional information.
It is interesting to mention, now, the script /usr/lib/kernel/install.d/51-dracut-rescue.install seems unfinished, because it does not include “USAGE” output and “remove” command is not implemented! The usage part is even stranger, because when the script is executed with wrong or without arguments it throws error for missing “usage command” (in fact, “usage” bash function):
[root@srv ~]# /usr/lib/kernel/install.d/51-dracut-rescue.install /usr/lib/kernel/install.d/51-dracut-rescue.install: line 129: usage: command not found
The remove command is just not implemented and it exits the script with 0, which WILL NOT remove a kernel rescue entry.
[root@srv ~]# grep remove -A 4 /usr/lib/kernel/install.d/51-dracut-rescue.install remove) exit 0 ;; *)
This is the situation for the latest version at present:
[root@srv ~]# dnf info dracut-config-rescue Last metadata expiration check: 1:35:30 ago on Wed 05 Oct 2022 09:06:59 AM UTC. Installed Packages Name : dracut-config-rescue Version : 057 Release : 13.git20220816.el9 Architecture : x86_64 Size : 3.5 k Source : dracut-057-13.git20220816.el9.src.rpm Repository : @System From repo : baseos Summary : dracut configuration to turn on rescue image generation URL : https://dracut.wiki.kernel.org/ License : GPLv2+ and LGPLv2+ and GPLv2 Description : This package provides the configuration to turn on the rescue initramfs : generation with dracut.
More topics on CentOS Stream 9 here.
Very good description, works fine!