# Introduction to grub 2
GRUB 2 Destination
BIOS-based
/boot/grub2/grub.cfg
UEFI
/boot/efi/EFI/redhat/grub.cfg
Menu Entries in grub.cfg
menuentry 'Red Hat Enterprise Linux Server' --class red --class gnu-linux --class gnu --class os | |
$menuentry_id_option 'gnulinux-simple-c60731dc-9046-4000-9182-64bdcce08616' { | |
load_video | |
set gfxpayload=keep | |
insmod gzio | |
insmod part_msdos | |
insmod xfs | |
set root='hd0,msdos1' | |
if [ x$feature_platform_search_hint = xy ]; then | |
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hintbaremetal=ahci0,msdos1 --hint='hd0,msdos1' 19d9e294-65f8-4e37-8e73-d41d6daa6e58 | |
else | |
search --no-floppy --fs-uuid --set=root 19d9e294-65f8-4e37-8e73-d41d6daa6e58 | |
fi | |
echo 'Loading Linux 3.8.0-0.40.el7.x86_64 ...' | |
linux16 /vmlinuz-3.8.0-0.40.el7.x86_64 root=/dev/mapper/rhel-root ro rd.md=0 rd.dm=0 rd.lvm.lv=rhel/swap crashkernel=auto rd.luks=0 vconsole.keymap=us rd.lvm.lv=rhel/root rhgb quiet | |
echo 'Loading initial ramdisk ...' | |
initrd /initramfs-3.8.0-0.40.el7.x86_64.img | |
} |
linux on 64-bit IBM POWER Series, linux16 on x86_64 BIOS-based systems, and linuxefi on UEFI-based systems.
The initrd directives followed by the path to the kernel and the initramfs image respectively.
# Configuring GRUB 2 to Require a Password only for Modifying Entries
Run the grub2-setpassword command as root:
~]# grub2-setpassword
Enter and confirm the password:
Enter password:
Confirm password:
Following this procedure creates a /boot/grub2/user.cfg file that contains the hash of the password. The user for this password, root, is defined in the /boot/grub2/grub.cfg file. With this change, modifying a boot entry during booting requires you to specify the root user name and your password.
# Changing the Default Boot Entry
GRUB 2 supports using a numeric value as the key for the saved entry directive to change the default order in which the operating systems are loaded. To specify which operating system should be loaded first, pass its number to the grub2-set-default command. For example:
~]# grub2-set-default 2 |
To force a system to always use a particular menu entry, use the menu entry name as the key to the GRUB_DEFAULT directive in the /etc/default/grub file. To list the available menu entries, run the following command as root:
~]# awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg |
# Rebuilding the grub.cfg file
Changes to /etc/default/grub require rebuilding the grub.cfg file as follows:
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 |