Compiling Kernel   «Prev  Next»

Lesson 10Verify a New Kernel, Initramfs, and First Boot
ObjectiveVerify the target kernel's installed files and initramfs, then check the system after a controlled reboot.

Verify a New Kernel, Initramfs, and First Boot

Before the first boot, verify the kernel you installed rather than the one currently running. Confusing these versions can regenerate the wrong initramfs or inspect the wrong module directory while leaving the new kernel incomplete.

Keep running and target releases separate

Use the exact target release recorded in Lesson 9. Replace the placeholder before running these examples.

running_release=$(uname -r)
target_release='REPLACE_WITH_EXACT_BUILT_KERNEL_RELEASE'
printf 'Running: %s\nTarget:  %s\n' "$running_release" "$target_release"
ls -l "/boot/vmlinuz-$target_release"
ls -ld "/lib/modules/$target_release"

Confirm that the installed filenames match your distribution's installation convention. Do not substitute $(uname -r) for the target while you are still running the previous kernel.

Check dependencies and the early-boot image

Installation normally generates module dependency metadata. If it needs regeneration for the lab target, specify that target explicitly:

sudo depmod -a "$target_release"
ls -l "/lib/modules/$target_release/modules.dep"

An initramfs supplies an early userspace environment that can load drivers, unlock encrypted storage, assemble required storage layers, and mount the real root filesystem. Required code, firmware, tools, and configuration must be available at that stage.

On a RHEL-style system using dracut, inspect the target image first:

ls -l "/boot/initramfs-$target_release.img"
sudo lsinitrd "/boot/initramfs-$target_release.img"

If installation did not create it, generate it for the explicit target. If replacing an existing image, preserve that image first and rebuild it deliberately:

# Generate when the target image is missing:
sudo dracut "/boot/initramfs-$target_release.img" "$target_release"

# Alternative: rebuild an existing target image after preserving its backup.
# sudo dracut --force "/boot/initramfs-$target_release.img" "$target_release"

Run the appropriate command for the image's state, not both automatically. Inspect the output with lsinitrd and check that the VM's storage and root-filesystem requirements are represented. A host-specific initramfs may not be portable to another machine.

Check before rebooting

Lesson 11 explains inspection and selection of RHEL boot entries. A successful build or a loaded kexec image is not a test of the normal firmware and bootloader path; use a controlled reboot for the lab's first-boot check.

Red Hat Enterprise Linux 9 Administration

Verify after selecting the new kernel

uname -r
lsmod
findmnt /
ip -brief address
sudo journalctl -k -b --no-pager

Compare the running release with the recorded target, inspect errors, and exercise the functionality that motivated the build. Check networking, storage, and the relevant application workload. If the target does not boot or behaves incorrectly, select the retained working kernel and investigate before making the new one the default.

References


SEMrush Software 10 SEMrush Banner 10