Question: I have several kernel images installed on my CentOS box, and I want to change the default boot kernel either permanently or temporarily ('just once'). How can I change the default kernel version used by GRUB/GRUB2 on CentOS?When there are multiple kernels installed on CentOS, GRUB/GRUB2 boot loader chooses and loads one of them as the default kernel during boot time. The default kernel can be chosen differently. For example, CentOS can be configured to boot into a newly installed kernel (e.g., CentOS 6), or it can boot a last saved entry regardless of the kernel is newer or older (e.g., CentOS 7).If you want to change the default kernel to a particular kernel version permanently, you can modify GRUB configuration as follows. Change the Default Kernel Version Permanently on CentOS 7First, list all available kernel images added to GRUB2 by running the following command.
Now you can reboot and GRUB should prompt at boot. Using GRUB rescue mode commands on CentOS. The following image shows Grub’s main screen on CentOS Linux, before going to the command prompt you can check the current configuration by pressing e.If you are going through booting problems and you see a command prompt go to the next step.
$ grep '^menuentry' /boot/grub2/grub.cfgIdentify the GRUB menu entry for the kernel that you want to set as default. Each menu entry is assigned by GRUB2 a numeric value starting from 0 in an increasing order. That is, the first menu entry assigned 0, the second entry assigned 1, etc. For example, the menu entry value for the kernel 3.10.0-327 is '2' in the above screenshot.Open /etc/default/grub with a text editor, and set GRUBDEFAULT to the numeric entry value for the kernel you chose as the default.
In this example, I choose the kernel 3.10.0-327 as the default kernel.GRUBDEFAULT=2Finally, re-generate GRUB configuration. $ sudo grep '^:space:.kernel' /boot/grub/grub.confFrom the list, identify the kernel that you want to set as default.
Each kernel in the list is assigned by GRUB a numeric entry value starting from 0 in an increasing order. That is, the first entry assigned 0, the second entry assigned 1, etc. For example, the kernel 2.6.32-431 is assigned GRUB entry value '1' in the above screenshot.Open /boot/grub/grub.conf with a text editor, look for 'default=N', and change N to the GRUB entry value for the default kernel to use. For example, to set the kernel 2.6.32-431 as the default kernel:default=1Reboot and confirm that the chosen kernel has been booted by default. Change the Default Boot Kernel Temporarily on CentOSOften times you may want to switch to a different kernel just temporarily, not permanently. Even if you do want to change the default kernel permanently, it is a good idea to try a temporary boot to a new kernel before making a permanent transition from the old kernel to a new one.
That way, in case there is any kernel crash with the new kernel, you can easily fall back to the old kernel simply by rebooting.Of course you can choose a kernel to boot interactively via GRUB menu. However, such interactive control is not always available, for example, when you are booting over SSH remotely.Here is how to change the default boot kernel 'temporarily' from the command line. I assume that '2' is the numeric GRUB menu entry value of a kernel that you want to boot into during the next boot session. Replace the number with your own.On CentOS 7.
Grub is the bootloader in most of the Linux distros that manage the operating systems installed in a computer. If you have installed multiple operating systems like for instance you have a dual-boot PC running Microsoft Windows and Ubuntu, you should see both the entries during the boot process.In the recent days, the use of M.2 and PCI Express NVMe Solid State Drives have increased and so it makes the situation a little complicated when you are dealing with multiple operating systems on the same PC, especially involving all the different types of media.One such problem occurred on my test PC.
I have Windows 10 and Ubuntu installed on the M.2 NVMe SSD so that I can benefit from the lightning-fast transfer speeds within the operating system. I also have a normal SSD installed which is only for storing the data. I had successfully installed Windows, Ubuntu, and the Grub on the NVMe drive.Ubuntu GrubAfter a kernel update in Ubuntu, I noticed a new duplicate entry in the Grub pointing to Windows on the SSD.
That didn’t make any sense. I don’t have Windows installed on the SSD! Anyway, I tried to select it and see what happens during the boot.
Obviously, the screen was blank.I need to get rid of this duplicate entry. The usual “sudo update-grub” will not fix the issue. Boot Repair can’t fix it either. Some reason it also thinks Windows is installed on the sda1 drive. Here is what I did to clean up the Grub. Editing Grub to delete the entries in UbuntuStep 1) Launch the “Terminal”.
You can use the Ctrl+Alt+T keyboard shortcut. Step 2) Enter the following command to add the PPA to install “Grub Customizer”. Sudo add-apt-repository ppa:danielrichter2007/grub-customizerStep 3) Update the system sudo apt-get updateStep 4) Install the Grub Customizer package. Sudo apt-get install grub-customizerStep 5) Launch Grub Customizer from the Apps menu.Step 6) Right-click on the option that you wish to delete and select “Remove”. In my case, I want to delete “Windows 10 (on /dev/sda1)”Grub-Customizer User InterfaceStep 7) Click “Save”. The application has the revert functionality and puts the deleted entries in the right pane. You can anytime revert the changes – even after reboot!Step 8) Restart the PC for new settings to take effect.
My Grub got cleaned up from the messier looking duplicate Windows entry. I’m happy!Updated Grub. I'm Kiran Kumar, founder of FOSSLinux.com. I'm an avid Linux lover and enjoy hands-on with new promising distros. Currently, I'm using Ubuntu as a daily driver and run several other distros such as Fedora, Solus, Manjaro, Debian, and some new ones on my test PC and virtual machines. I have a day job as an Engineer, and this website is one of my favorite past time activities especially during Winter;). When I'm not writing for FOSSLinux, I'm seen biking and hiking on scenic trails.
Hope you enjoy using this website as much as I do writing for it. Feedback from readers is something that inspires me to do more, and spread Linux love! If you find a time, drop me an email or feedback from the 'Contact' page. Or simply leave a comment below if you found this article useful.
Have a good day!