We want to re-generate initramfs and vmlinuz for the Rescue Kernel in our CentOS/RHEL 7 system. How can this be done using the current kernel from which the system is booted up?
During the boot process, when the kernel image and initramfs image get loaded, initramfs starts the first process on the system, which is systemd with the process ID 1. This systemd process further takes over control in the final stages of system booting and performs the following operations:
- Reads the configuration files from the /etc/systemd/ directory
- Reads the files linked by /etc/systemd/system/default.target
- Executes the /etc/rc.local file
Follow the steps below to re-generate the initramfs and vmlinuz for the Rescue Kernel from the current kernel.
1. Review the existing files for the rescue kernel:
# cd /boot # ll | grep rescue -rw-------. 1 root root 72166662 Apr 6 21:37 initramfs-0-rescue-a0eaa652c599455aa125077a4167f435.img <<----Apr 6 -rwxr-xr-x. 1 root root 5925632 Apr 6 21:37 vmlinuz-0-rescue-a0eaa652c599455aa125077a4167f435 <<----Apr 6
2. Move the existing files to a different directory (for example ‘/tmp’):
# mv initramfs-0-rescue-a0eaa652c599455aa125077a4167f435.img /tmp/initramfs-0-rescue-a0eaa652c599455aa125077a4167f435.img.bk # mv vmlinuz-0-rescue-a0eaa652c599455aa125077a4167f435 /tmp/vmlinuz-0-rescue-a0eaa652c599455aa125077a4167f435.bk
Verify that there are no files present for the rescue kernel in the /boot directory:
# ll | grep rescue #
3. Regenerate the new initramfs & vmlinuz for the rescue kernel with current kernel.
# /etc/kernel/postinst.d/51-dracut-rescue-postinst.sh $(uname -r) /boot/vmlinuz-$(uname -r)
Verify
After the above command finishes, the two new files for the rescue kernel should be shown as below:
# ll | grep rescue -rw-------. 1 root root 72164785 May 4 00:18 initramfs-0-rescue-a0eaa652c599455aa125077a4167f435.img <<----May 4 -rwxr-xr-x. 1 root root 5925632 May 4 00:18 vmlinuz-0-rescue-a0eaa652c599455aa125077a4167f435 <<----May 4