linux_wiki:grub2

This is an old revision of the document!


Grub2

General Information

Grub2 is used by RHEL/CentOS 7. It is quite different from Grub1.

Checklist

  • Distro(s): Any
  • Other: Grub2

Grub2 Files

Grub2 files:

  • /etc/default/grub ⇒ grub2 variables (can be edited, then menus re-generated)
    • Typically, this is the only file you should be hand editing.
  • /boot/grub2/grub.cfg ⇒ grub2 generated menu (do not edit directly; changes will be over-written)
  • /etc/grub.d/ ⇒ individual files used internally by grub2

Grub2 symlinks

  • /etc/grub2.cfg ⇒ symlink to /boot/grub2/grub.cfg
  • /etc/sysconfig/grub ⇒ symlink to /etc/default/grub

Grub2 Commands

View the active kernel that is the default the system will boot to

grub2-editenv list
 
saved_entry=CentOS Linux (3.10.0-327.3.1.el7.x86_64) 7 (Core)


View list of available kernels displayed on grub menu

grep ^menuentry /boot/grub2/grub.cfg 
 
menuentry 'CentOS Linux (3.10.0-327.3.1.el7.x86_64) 7 (Core)' ...
menuentry 'CentOS Linux (3.10.0-327.el7.x86_64) 7 (Core)' ...
menuentry 'CentOS Linux (0-rescue-15bdd5425c924660bb6c9979dc071d56) 7 (Core)' ...


Set default kernel for grub system boot (permanent)

grub2-set-default 'CentOS Linux (3.10.0-327.3.1.el7.x86_64) 7 (Core)'
  • Note: Copy/paste including the single quotes from the “grep ^menuentry” output


Changing grub2 kernel arguments

  1. Edit grub2 variables
    vim /etc/default/grub
  2. After making changes to grub2 variables, re-generate the grub2 menu
    grub2-mkconfig -o /boot/grub2/grub.cfg

  • linux_wiki/grub2.1558842657.txt.gz
  • Last modified: 2019/05/25 23:50
  • by 127.0.0.1