0% found this document useful (0 votes)
154 views

Grub2 Commands: Making Persistent Changes To A Grub 2 Menu

This document provides information on making persistent changes and customizing settings in GRUB 2, the GNU GRand Unified Bootloader. It describes how to change the default boot entry, view and modify kernel menu entries, add or remove arguments, update all kernels, customize configuration files, set passwords, reinstall GRUB 2, and reset and rebuild the grub.cfg file. The steps shown include using grubby, grub2, and grub2-mkconfig commands to manage these tasks from the command line.

Uploaded by

BG Supp
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
154 views

Grub2 Commands: Making Persistent Changes To A Grub 2 Menu

This document provides information on making persistent changes and customizing settings in GRUB 2, the GNU GRand Unified Bootloader. It describes how to change the default boot entry, view and modify kernel menu entries, add or remove arguments, update all kernels, customize configuration files, set passwords, reinstall GRUB 2, and reset and rebuild the grub.cfg file. The steps shown include using grubby, grub2, and grub2-mkconfig commands to manage these tasks from the command line.

Uploaded by

BG Supp
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Grub2 commands

MAKING PERSISTENT CHANGES TO A GRUB 2 MENU

# ~]# grubby --default-kernel >> get the default kernel

# grubby --default-index >> find index no of the default kernel

Changing the Default Boot Entry

~]# grubby --set-default /boot/vmlinuz-3.10.0-229.4.2.el7.x86_64 >> change default kernel

Viewing the GRUB 2 Menu Entry for a Kernel

# grubby --info=ALL >> To list all the kernel menu entries,

# grubby --info /boot/vmlinuz-3.10.0-229.4.2.el7.x86_64 >> to view the specific kernel

Adding and Removing Arguments from a GRUB 2 Menu Entry

#grubby --remove-args="argX argY" --args="argA argB" --update-kernel /boot/kernel

Eg:

# grubby --remove-args="rhgb quiet" --args=console=ttyS0,115200 --update-kernel


/boot/vmlinuz-3.10.0-229.4.2.el7.x86_64

#grubby --info /boot/vmlinuz-3.10.0-229.4.2.el7.x86_64 >> to view the changes

Updating All Kernel Menus with the Same Arguments

#grubby --update-kernel=ALL --args=console=ttyS0,115200

CUSTOMIZING THE GRUB 2 CONFIGURATION FILE

GRUB_TIMEOUT_STYLE=hidden >> the /etc/default/grub file

Changing the Default Boot Entry


#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 specify which operating system should be loaded


first, pass its number to the grub2-set-default command. For example:

~]# grub2-set-default 2

~]# awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg >> to list the available menu entries on
grub2.cfg

On BIOS-based machines, issue the following command as root

~]# grub2-mkconfig -o /boot/grub2/grub.cfg

On UEFI-based machines, issue the following command as root:

~]# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg

Editing a Menu Entry


#GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,9600n8"

Where console=tty0 is the first virtual terminal and console=ttyS0 is the serial terminal to be used

On BIOS-based machines
~]# grub2-mkconfig -o /boot/grub2/grub.cfg

On UEFI-based machines,
grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg

PROTECTING GRUB 2 WITH A PASSWORD


~]# grub2-setpassword

2. Enter and confirm the password:

Enter password:
Confirm password

Reinstalling GRUB 2 on BIOS-Based Machines

~]# grub2-install /dev/sda


Reinstalling GRUB 2 on UEFI-Based Machines

~]# yum reinstall grub2-efi shim

Resetting and Reinstalling GRUB 2

Important steps:

1. Run the rm /etc/grub.d/* command;


2. Run the rm /etc/sysconfig/grub command
3. For EFI systems only, run the following command

~]# yum reinstall grub2-efi shim grub2-tools

4. For BIOS and EFI systems, run this command:

#yum reinstall grub2-tools

Rebuild the 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

GRUB 2 OVER A SERIAL CONSOLE


#console=ttyS0,9600n8

You might also like