What is the first step before you can edit the grub 2 boot loader during the boot process?

This chapter is from the book

Working with GRUB 2

The GRUB 2 boot loader is one of the first things that needs to be working well to boot a Linux server. As an administrator, you will sometimes need to apply modifications to the GRUB 2 boot loader configuration. This section explains how to do so. The RHEL 8 boot procedure is discussed in more detail in Chapter 18, where troubleshooting topics are covered as well.

Understanding GRUB 2

The GRUB 2 boot loader makes sure that you can boot Linux. GRUB 2 is installed in the boot sector of your server’s hard drive and is configured to load a Linux kernel and the initramfs:

What is the first step before you can edit the grub 2 boot loader during the boot process?

  • The kernel is the heart of the operating system, allowing users to interact with the hardware that is installed in the server.

  • The initramfs contains drivers that are needed to start your server. It contains a mini file system that is mounted during boot. In it are kernel modules that are needed during the rest of the boot process (for example, the LVM modules and SCSI modules for accessing disks that are not supported by default).

Normally, GRUB 2 works just fine and does not need much maintenance. In some cases, though, you might have to change its configuration. To apply changes to the GRUB 2 configuration, the starting point is the /etc/default/grub file, which has options that tell GRUB what to do and how to do it. Example 17-3 shows the contents of this file after an installation with default settings of RHEL 8.

What is the first step before you can edit the grub 2 boot loader during the boot process?

Example 17-3 Contents of the /etc/default/grub File

[root@localhost ~]# cat /etc/default/grub GRUB_TIMEOUT=5 GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)" GRUB_DEFAULT=saved GRUB_DISABLE_SUBMENU=true GRUB_TERMINAL_OUTPUT="console" GRUB_CMDLINE_LINUX="crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet" GRUB_DISABLE_RECOVERY="true" GRUB_ENABLE_BLSCFG=true

As you can see, the /etc/default/grub file does not contain much information. The most important part that it configures is the GRUB_CMDLINE_LINUX option. This line contains boot arguments for the kernel on your server.

Apart from the configuration in /etc/default/grub, there are a few configuration files in /etc/grub.d. In these files, you’ll find rather complicated shell code that tells GRUB what to load and how to load it. You typically do not have to modify these files. You also do not need to modify anything if you want the capability to select from different kernels while booting. GRUB 2 picks up new kernels automatically and adds them to the boot menu automatically, so nothing has to be added manually.

Understanding GRUB 2 Configuration Files

Based on the configuration files mentioned previously, the main configuration file is created. If your system is a BIOS system, the name of the file is /boot/grub2/grub.cfg. On a UEFI system the file is written to /boot/efi/EFI/redhat on RHEL and /boot/efi/EFI/centos on CentOS. After making modifications to the GRUB 2 configuration, you’ll need to regenerate the relevant configuration file, which is why you should know the name of the file that applies to your system architecture. Do not edit it, as this file is automatically generated.

Modifying Default GRUB 2 Boot Options

To apply modifications to the GRUB 2 boot loader, the file /etc/default/grub is your entry point. The most important line in this file is GRUB_CMDLINE_LINUX, which defines how the Linux kernel should be started. In this line, you can apply permanent fixes to the GRUB 2 configuration. Some likely candidates for removal are the options rhgb and quiet. These options tell the kernel to hide all output while booting. That is nice to hide confusing messages for end users, but if you are a server administrator, you probably just want to remove these options.

Another interesting parameter is GRUB_TIMEOUT. This defines the amount of time your server waits for you to access the GRUB 2 boot menu before it continues booting automatically. If your server runs on physical hardware that takes a long time to get through the BIOS checks, it may be interesting to increase this time a bit.

While working with GRUB 2, you need to know a bit about kernel boot arguments. There are many of them, and most of them you’ll never use, but it is good to know where you can find them. Type man 7 bootparam for a man page that contains an excellent description of all boot parameters that you may use while starting the kernel.

To write the modified configuration to the appropriate files, you use the grub2-mkconfig command and redirect its output to the appropriate configuration file. On a BIOS system, the command would be grub2-mkconfig -o /boot/grub2/grub.cfg, and on a UEFI system the command would be grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg.

In Exercise 17-2, you learn how to apply modifications to the GRUB 2 configuration and write them to the /boot/grub2/grub.cfg configuration file.

What is the first step before you can edit the grub 2 boot loader during the boot process?

Which procedure is used to edit a grub boot entry?

When the boot sequence begins, the GRUB main menu is displayed. Use the arrow keys to select the boot entry to edit, then type e to access the GRUB edit menu. Use the arrow keys to select the kernel or kernel$ line in this menu.

Which of the following is the grub 2 boot loader configuration file?

cfg file is the GRUB configuration file. It is generated by the grub2-mkconfig program using a set of primary configuration files and the grub default file as a source for user configuration specifications.

How do I edit a grub file?

To edit grub, make your changes to /etc/default/grub . Then run sudo update-grub . The update-grub will make the permanent changes to your grub.

How do I edit a grub command line?

Making Temporary Changes to a GRUB 2 Menu.
Start the system and, on the GRUB 2 boot screen, move the cursor to the menu entry you want to edit, and press the e key for edit..
Move the cursor down to find the kernel command line. ... .
Move the cursor to the end of the line..