How To Change Default Kernel in CentOS 7
How to change the kernel that comes by default in CentOS 7 Linux systems.
The most vital component of any Linux distro is the kernel which interacts with the hardware allowing the operability of the applications and that each process has communication between them, this is called IPC.
Thanks to the kernel we can carry out tasks such as:
- Management of CPU usage times of both processes and applications.
- Management and control of the memory for each process.
- On a regular basis, the kernels are updated in Linux with the aim that each time the boot and configuration are much more reliable and secure.
That is why when we start CentOS 7 we can select which kernel to begin with:
We can visualize that a specific kernel is the one chosen when CentOS 7 starts. This can be adjusted for administrative or support reasons.
Modify Default Kernel Permanently
For this we will first list all available kernels using the following command:
sudo grep '^menuentry' /boot/grub2/grub.cfg
There we will see the different possible kernels like:
There we must verify which kernel we wish to establish as a permanent predefined one and it is essential to bear in mind that GRUB2 assigns each input a numeric value that starts at zero and increases.
Once this number is identified we will access the file /etc/default/grub using nano or vi, and there we will place the GRUB_DEFAULT line where we will enter the ID of our kernel, for example:
We save the changes using the key combination Ctrl + O, and we left the editor using Ctrl + X.
Finally, we regenerated the GRUB configuration by executing the following line:
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
Now when we start CentOS 7 again we can see the new kernel by default:
Modify Default Kernel Temporarily
As we have mentioned some occasions we want to start CentOS 7 with a different kernel for management reasons. If we want to do it temporarily it's simple, just execute the following syntax:
Finally, execute the reboot command to restart the system with the indicated kernel. It will be that simple to configure our kernel in CentOS 7.