At times, it can happen that the server does not boot up correctly, because of issues such as file-system issues or OS loading issues. In such a scenario, a solution that can be tried for troubleshooting such issues is by changing the default boot kernel for the server via the Console of LayerPanel.
A general boot menu of an Ubuntu server with more than one kernel will be as below, with the first kernel at position 0
, the second kernel at position 1
and so on.
In order to change the default boot kernel, the grub configuration file /etc/default/grub
needs to be edited. The parameter value that needs to be updated is for GRUB_DEFAULT.
In the below example, if the kernel that needs to be set as the default one is the third one
from the boot menu (position 2), then the value for GRUB_DEFAULT needs to be updated as 1>2.
Here, 1 denotes the second entry of the Main menu and 2 denotes the third entry in the sub-menu.
Execute the below command for rebuilding the grub configuration file.
# update-grub
Once the grub configuration file has been rebuilt, the server can be rebooted. Once the server is back online, the kernel with which the server has been booted up can be verified.
AlmaLinux is basically a community-driven project that is built from the source code of RedHat Enterprise Linux. It is also a fork of RHEL 8. For AlmaLinux servers having multiple kernel versions available, use grubby, the command-line tool used to configure bootloader menu entries.
To identify and check the different versions of Kernel available, execute the following command.
# rpm -qa | grep kernel | sort
The output of the above command will list all the versions of Kernel available. Now, the system has its way to number each of them. The first option will be given the number 0
, the second option will be given as 1
and so on.
Suppose if you would wish to have the 3rd kernel version
in the list to be made default one, the following steps are done.
# grub2-set-default 2
Once done, you can verify if the variable has gained the value, by the following command.
# cat /boot/grub2/grubenv |grep saved
The saved_entry variable will get the value.
After making the above changes, the Grub configuration file is to be rebuilt, and it can be achieved by following steps.
# ls -ld /boot/grub2/grub.cfg
This will show the grub configuration file details as output:
Final step is to rebuild the grub configuration done, and this is done using the following command.
# grub2-mkconfig -o /boot/grub2/grub.cfg
Once the grub configuration file has been rebuilt, the server can be rebooted. Once the server is back online, the kernel with which the server has been booted up can be verified.
To identify and check the different versions of Kernel available, execute the following command.
# awk -F\' /^menuentry/{print\$2} /etc/grub2.cfg
The output of the above command will list all the versions of Kernel available. Now, the system has its way to number each of them. The first option will be given the number 0
, the second option will be given as 1
and so on.
Suppose if you would wish to have the 3rd kernel version
in the list to be made default one, the following steps are done.
# grub2-set-default 2
Once done, you can verify if the variable has gained the value, by the following command.
# cat /boot/grub2/grubenv |grep saved
The saved_entry variable will get the value:
After making the above changes, the Grub configuration file is to be rebuilt, and it can be achieved by following steps.
# ls -ld /boot/grub2/grub.cfg
This will show the grub configuration file details as output:
Final step is to rebuild the grub configuration done, and this is done using the following command.
# grub2-mkconfig -o /boot/grub2/grub.cfg
Once the grub configuration file has been rebuilt, the server can be rebooted. Once the server is back online, the kernel with which the server has been booted up can be verified.