3

In Red Hat EL versions 5 and 6 we can easily to update the /etc/grub.conf in case we want to change the kernel by default variable

 For example , grub.conf on redhat 5
 default=0
 timeout=5
 #splashimage=(hd0,0)/grub/splash.xpm.gz
 #hiddenmenu
  title Red Hat Enterprise Linux Server (2.6.18-410.el5)
   root (hd0,0)
   kernel /vmlinuz-2.6.18-410.el5 ro root=/dev/rootvg/slash
   initrd /initrd-2.6.18-410.el5.img
  title Red Hat Enterprise Linux Server (2.6.18-409.el5)
    root (hd0,0)
   kernel /vmlinuz-2.6.18-409.el5 ro root=/dev/rootvg/slash
   initrd /initrd-2.6.18-409.el5.img

From this /etc/grub.conf if we want to boot from kernel 2.6.18-409 version then we just change the default=1. So on the next boot, the OS will start with the old kernel

RHEL7 is very different. I find in the RHEL7 the /boot/grub2/grub.cfg But I don't understand how to change the file in order to boot from other kernel as I do it on RHEL5.

2 Answers 2

3

change GRUB_DEFAULT=0 in /etc/default/grub to the number that you want, now you need to regenarate the grub2 config using grub2-mkconfig -o /boot/grub2/grub.cfg

6
  • just one remark - I not find the GRUB_DEFAULT in the file grub.cfg , cat /boot/grub2/grub.cfg|grep GRUB_DEFAULT , this variable exist in other file?
    – dandan
    Jul 15, 2016 at 9:20
  • @dandan was my foul, I edited my answer with the filename that you need to edit
    – c4f4t0r
    Jul 15, 2016 at 10:10
  • I think the seting of the default shuld be by the command - grub2-set-default N , while N is the entrie from awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg
    – dandan
    Jul 15, 2016 at 10:32
  • @dandan don't edit that file by hand.
    – c4f4t0r
    Jul 15, 2016 at 10:41
  • please see my post , what you think about ?
    – dandan
    Jul 15, 2016 at 10:42
2

How the change GRUB kernel on redhat 7 version

To list all the menu entries that will be displayed at system boot, issue the following command:

 # awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg
 0 : Red Hat Enterprise Linux Server (3.10.0-327.18.2.el7.x86_64) 7.2 (Maipo)
 1 : Red Hat Enterprise Linux Server (3.10.0-327.10.1.el7.x86_64) 7.2 (Maipo)
 2 : Red Hat Enterprise Linux Server, with Linux 0-rescue- b2c5e6a1c5ea4cb5be82100bd7dc3469

How to verify what is the current entry (the current kernel from /etc/default/grub )

# grub2-editenv list
  saved_entry=1

This mean the current kernel version from grub configuration is: 3.10.0-327.10.1.el7.x86_64

let’s check what is the current kernel version on the machine:

# uname -r
  3.10.0-327.10.1.el7.x86_64

Now let’s changes the kernel version from GRUB configuration so Linux will boot with the higher kernel - 3.10.0-327.18.2.el7.x86_64 ,

remember from the awk command we get entrie number 0

So the setting should be as the following

 # grub2-set-default 0

Now we check the new GRUB configuration by

 # grub2-editenv list
   saved_entry=0

so now the new GRUB configuration is set to kernel version: 3.10.0-327.18.2.el7.x86_64

Now we reboot the machine

 # Reboot

After reboot Linux was up with the new kernel

 # uname -r
   3.10.0-327.18.2.el7.x86_64
2
  • May be you need to enter one more command after grub2-set-default 0 where 0 is the no. of the desired kernel. And then grub2-mkconfig -o /boot/grub2/grub.cfg Aug 17, 2017 at 10:21
  • I wanted to change default boot loader to be windows which is the third one. I issued grub2-set-default 2. This worked! Nov 30, 2017 at 5:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .