Views: 283
0 0
Read Time:2 Minute, 9 Second

Introduction: In Linux systems, the kernel serves as the core component responsible for managing system resources and providing essential functionality. CentOS and Red Hat Enterprise Linux (RHEL) are widely used distributions that offer various kernels to choose from. However, it’s often necessary to set a default boot kernel to ensure stability and compatibility with your specific system requirements. In this tutorial, we will explore the steps to set the default boot kernel on CentOS/RHEL 7.

Prerequisites: Before proceeding with the steps outlined in this tutorial, ensure that you have the following:

  1. Access to a CentOS/RHEL 7 system.
  2. Administrative privileges (root access).

Step 1: Checking the Current Default Kernel: To begin, let’s first verify the currently set default boot kernel on your system. Open a terminal or connect to your CentOS/RHEL 7 server using SSH and run the following command:

grubby --default-kernel

Step 2: Listing Available Kernels: Next, we need to list the available kernels on your system. Execute the following command:

awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg

This command will display a list of kernels installed on your system.

Step 3: Choosing the Desired Kernel: Review the list of available kernels and determine which one you want to set as the default. Make a note of its name.

Step 4: Setting the Default Kernel: To set the desired kernel as the default boot option, run the following command, replacing “KERNEL_NAME” with the name of the kernel you want to use:

grubby --set-default=/boot/vmlinuz-KERNEL_NAME

Note: Replace “/boot/vmlinuz-KERNEL_NAME” with the appropriate path to the kernel you selected.

Step 5: Verifying the Changes: To ensure that the default boot kernel has been successfully set, use the following command:

grubby --default-kernel

The output should now display the name of the kernel you chose in the previous step.

Step 6: Testing the Default Kernel: To confirm that the changes take effect upon reboot, restart your system:

sudo reboot

After the system restarts, verify that the desired kernel is booted by executing the following command:

uname -r

The output should match the kernel name you set as the default.

Conclusion: Setting the default boot kernel on CentOS/RHEL 7 ensures that your system uses the desired kernel version, optimizing stability and compatibility. By following the steps outlined in this tutorial, you can easily configure the default boot kernel according to your specific needs.

Remember, it’s crucial to exercise caution when modifying kernel settings, as an incorrect configuration can potentially lead to system instability or failure.