Issue
The kernel booted by default (using GRUB) is different from the one you would like to be automatically selected on startup. How do I change the default kernel in GRUB that is loaded at startup?

Resolution
Use the command
grubby –bootloader-probe to find out which bootloader you have installed.

For RHEL 4, 5, 6 Systems:

  • GRUB is the most common bootloader for RHEL 4, 5, 6 systems
    Below is an example GRUB configuration file:
default=0
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
title Red Hat Enterprise Linux ES (kernel number zero)
    root (hd0,0)
    kernel /vmlinuz-zero ro root=/dev/hard_drive
    initrd /initrd-zero.img
title Red Hat Enterprise Linux ES (kernel number one)
    root (hd0,0)
    kernel /vmlinuz-one ro root=/dev/hard_drive
    initrd /initrd-one.img
  • In this example file, notice the line at the top that reads default=0. The number 0(zero) indicates which stanza to select by default. A stanza is the indented portion afterthe line starting with title. GRUB will then use this default stanza to boot, after anumber of seconds has passed (specified in the line timeout=10)
    . The 0 (zero) in thiscase is referring to the first stanza that starts with “title Red Hat Enterprise Linux ES (kernel number zero)“. It includes all of the indented lines up to but not includingthe next “title” line.
  • For example, to instead set the second stanza, “title Red Hat Enterprise Linux ES (kernel number one)“, to be the default, change the default line to:
Default=1
  • The effect of changes will be seen on the next boot.

 

For RHEL 7 Systems:

  • GRUB2 is the supported bootloader for x86 RHEL 7 systems.
  • Note that ordering of menu entries means very little in GRUB2. By default, each newkernel package install changes the default kernel regardless of its location in theordering of kernel menu entries. To override this, use grub2-set-default ‘ID’, where ID is either a number or a name, e.g.:
# grub2-set-default 'Red Hat Enterprise Linux Server, with Linux 3.10.0-123.el7.x86_64'
  • By default, the key for the GRUB_DEFAULT directive in the /etc/default/grub  file is the word saved. This instructs GRUB 2 to load the kernel specified by the saved_entry directive in the GRUB 2 environment file, located at /boot/grub2/grubenv.
    One can set another GRUB record to be the default, using the grub2-set-default command,which will update the GRUB 2 environment file.
  • By default, the saved_entry value is set to the name of latest installed kernel ofpackage type kernel. This is defined in /etc/sysconfig/kernel  by the UPDATEDEFAULT and DEFAULTKERNEL directives. The file can be viewed by the root user as follows:
$ cat /etc/sysconfig/kernel
# UPDATEDEFAULT specifies if new-kernel-pkg should make
# new kernels the default
UPDATEDEFAULT=yes
# DEFAULTKERNEL specifies the default kernel package type
DEFAULTKERNEL=kernel
  • To force a system to always use a particular menu entry, use the menu entry name asthe key to the GRUB_DEFAULT directive in the
    /etc/default/grub file. To list theavailable menu entries, run the following command as root:
# awk -F\' /^menuentry/{print\$2} /etc/grub2.cfg
Red Hat Enterprise Linux Server, with Linux 3.10.0-123.el7.x86_64 <=== Entry 0
Red Hat Enterprise Linux Server, with Linux 3.10.0-123.9.2.el7.x86_64 <=== Entry 1
Red Hat Enterprise Linux Server, with Linux 3.10.0-123.6.3.el7.x86_64 <=== Entry 2
Red Hat Enterprise Linux Server, with Linux 0-rescue-b03fd2e1e769493994c88 b8da4257178 <=== Entry 3
  • GRUB 2 supports using a numeric value as the key for the saved_entry directive tochange the default order in which the kernel or operating systems are loaded. To specify which kernel or operating system should be loaded first, pass its number to the grub2-set-default command. For example:
# grub2-set-default 1
  • Check the below file to see the kernel which will be loaded at next boot, crosscheck thenumeric value with the menu entry in the
    /etc/default/grub file.
# cat /boot/grub2/grubenv |grep saved
saved_entry=1
  • Changes to /etc/default/grub require rebuilding the grub.cfg file as follows.
  • Rebuild the  /boot/grub2/grub.cfg  file by running the grub2-mkconfig -o command as follows:
On BIOS-based machines:~]# grub2-mkconfig -o /boot/grub2/grub.cfg
On UEFI-based machines:~]# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
Categories: Redhat

Leave a Reply

Your email address will not be published.

nine + eleven =

Related Posts

Redhat

How to change / set hostname Centos / RHEL 7

How to change / set hostname Centos / RHEL 7 Hostname types We can configure 3 hostname types is CentOS/RHEL 7 : Hostname Type Description Static Assigned by the system admin Dynamic Assigned by DHCP Read more…

Redhat

Set up yum repository for locally-mounted DVD on Red Hat Enterprise Linux 7

Set up yum repository for locally-mounted DVD on Red Hat Enterprise Linux 7  Mount the RHEL 7 installation ISO to a directory like /mnt, e.g.: # mount -o loop RHEL7.1.iso /mnt If you use DVD media Read more…

CentOs

Linux Test Disk I/O Performance

How can I use dd command on a Linux to test I/O performance of my hard disk drive? How do I check the performance of a hard drive including the read and write speed on Read more…