Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to change default kernel
07-13-2018, 11:04 AM (This post was last modified: 07-13-2018 05:52 PM by cchen.)
Post: #1
How to change default kernel
Sometimes we need to change the default kernel to an old kernel, for example the xen kernel. Use the following steps to accomplish it: (in the following steps, I will use xen kernel as an example)

P1). Run "awk -F\' /^menuentry/{print\$2} /etc/grub2.cfg". It will print out a list of available kernels. For example:
Code:
CentOS Linux (4.14.0-1.el7.elrepo.x86_64) 7 (Core)
CentOS Linux (4.9.86-30.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-327.el7.x86_64) 7 (Core)
CentOS Linux (0-rescue-9e73f9f4e92942b092f659cdd89b15c2) 7 (Core)
CentOS Linux, with Xen hypervisor

P2). Figure out the index of the target kernel (for example 4 for xen in this case), run:
Code:
grub2-set-default <index>

P3). run "cat /boot/grub2/grubenv |grep saved" to verify the default kernel. example output in this case:
Code:
saved_entry=4

P4). run "grub2-mkconfig -o /boot/grub2/grub.cfg" to rebuild the grub.cfg file

P5). Reboot to make changed happen

RR rayluk
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: