A comprehensive guide for performing a Server reboot on RHEL or CentOS-based systems , which includes updating the kernel and ensuring the server boots properly after the update.
1. Initial Login & Access Verification
Log in to Data Center (DC) and check the server’s access via **KVM/IPMI** (to ensure you can access it remotely).
2. Check Current Kernel Version
To check the current kernel version use the below command
uname -r
3. Update the Kernel
To update the kernel while ensuring the current one is not deleted:
yum update kernel
4. Verify /boot Directory
Ensure the `/boot` directory contains both the new and old kernels:
ll /boot/
5. Verify Boot Mode (UEFI vs Legacy BIOS)
To determine if the system is booting in UEFI or Legacy BIOS mode, run:
[ -d /sys/firmware/efi ] && echo "UEFI Boot Detected" || echo "Legacy BIOS Boot Detected"
5.A. UEFI Boot Mode
If UEFI boot is detected:
Ensure the `grub.cfg` file exists in `/boot/efi/EFI/centos`
ll /boot/efi/EFI/centos
If the `grub.cfg` file is missing, copy it from `/boot/grub2/grub.cfg`:
cp /boot/grub2/grub.cfg /boot/efi/EFI/centos
5.B. Legacy BIOS Boot Mode
If Legacy BIOS boot is detected:
Ensure the `grub.cfg` file exists in `/boot/grub2`
ll /boot/grub2
To view the kernel menu entries, use the command:
awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg
or
awk -F\' '$1=="menuentry " {print i++ " : " $2}' /boot/grub2/grub.cfg
Expected output:
0 : CentOS Linux (3.10.0-1160.81.1.el7.x86_64) 7 (Core) ## newly installed kernel
1 : CentOS Linux (3.10.0-1160.36.2.el7.x86_64) 7 (Core) ## currently running kernel
2 : CentOS Linux (3.10.0-1062.1.2.el7.x86_64) 7 (Core)
The 0th kernel will be used on the next reboot.
5B.1. Check Installed Kernels (for AlmaLinux or CloudLinux)
For AlmaLinux or CloudLinux, there will be no `menuentry`. Instead, use:
grubby --info=ALL | grep -E 'index=|kernel="' or grubby --info=ALL | grep -E 'index=|kernel="
Expected output:
index=0 kernel=”/boot/vmlinuz-4.18.0-553.34.1.lve.el8.x86_64″ ## newly installed kernel
index=1 kernel=”/boot/vmlinuz-4.18.0-553.32.1.lve.el8.x86_64″ ## currently running kernel
index=2 kernel=”/boot/vmlinuz-4.18.0-553.30.1.lve.el8.x86_64″
You can also check the current default kernel:
grub2-editenv list grubby --default-kernel
6. Set Default Kernel
After verifying the kernel, set it as the default kernel
grub2-set-default 1
7. Verify Default Kernel is Set
Ensure that the default kernel is set correctly:
grub2-editenv list
Expected output:
saved_entry=1
8. Set Next Reboot Kernel
For testing the new kernel on the next reboot, use:
grub2-reboot 0
Then verify:
grub2-editenv list
Expected output:
saved_entry=1
next_entry=0
9. Reboot the Server
reboot
10. Set New Kernel as Default After Reboot
Once the server has rebooted successfully, set the newly installed kernel as the default:
grub2-set-default 0
11. Verify the Kernel Again
Ensure the new kernel is now the default:
grub2-editenv list
Expected output:
saved_entry=0
12. Check the New Kernel Version
Check the newly installed kernel:
uname -r
13. Check Server Uptime
uptime
By following these steps, you should be able to update and reboot the kernel successfully on RHEL or CentOS-based systems while ensuring the correct boot mode and kernel version are set.