From c17a49fff6a4780a8636d693486523d29df935f0 Mon Sep 17 00:00:00 2001 From: Raman Gupta Date: May 13 2022 21:01:30 +0000 Subject: Improve EFI boot docs, fix some numbering --- diff --git a/modules/system-administrators-guide/pages/kernel-module-driver-configuration/Working_with_the_GRUB_2_Boot_Loader.adoc b/modules/system-administrators-guide/pages/kernel-module-driver-configuration/Working_with_the_GRUB_2_Boot_Loader.adoc index 68b8e22..3a7d0dd 100644 --- a/modules/system-administrators-guide/pages/kernel-module-driver-configuration/Working_with_the_GRUB_2_Boot_Loader.adoc +++ b/modules/system-administrators-guide/pages/kernel-module-driver-configuration/Working_with_the_GRUB_2_Boot_Loader.adoc @@ -12,6 +12,8 @@ indexterm:[GRUB 2,configuring GRUB 2]indexterm:[GRUB 2,reinstalling GRUB 2]index GRUB 2 reads its configuration from the `/boot/grub2/grub.cfg` file on traditional BIOS-based machines and from the `/boot/efi/EFI/fedora/grub.cfg` file on UEFI machines. This file contains menu information. +Note that the postinstall script of `grub2-common` installs a small shim which chains the UEFI-based config at `/boot/efi/EFI/fedora/grub.cfg` to the standard configuration at `/boot/grub2/grub.cfg`. To reset this shim to defaults, delete the existing `/boot/efi/EFI/fedora/grub.cfg` and then `dnf reinstall grub2-common`. + The GRUB 2 configuration file, `grub.cfg`, is generated during installation, or by invoking the [application]*/usr/sbin/grub2-mkconfig* utility, and is automatically updated by [command]#grubby# each time a new kernel is installed. When regenerated manually using [application]*grub2-mkconfig*, the file is generated according to the template files located in `/etc/grub.d/`, and custom settings in the `/etc/default/grub` file. Edits of `grub.cfg` will be lost any time [application]*grub2-mkconfig* is used to regenerate the file, so care must be taken to reflect any manual changes in `/etc/default/grub` as well. Normal operations on `grub.cfg`, such as the removal and addition of new kernels, should be done using the [command]#grubby# tool and, for scripts, using [command]#new-kernel-pkg# tool. If you use [command]#grubby# to modify the default kernel the changes will be inherited when new kernels are installed. For more information on [command]#grubby#, see xref:#sec-Making_Persistent_Changes_to_a_GRUB_2_Menu_Using_the_grubby_Tool[Making Persistent Changes to a GRUB 2 Menu Using the grubby Tool]. @@ -277,18 +279,19 @@ The file name `/etc/grub2.cfg` is a symlink to the `grub.cfg` file, whose locati Changes to `/etc/default/grub` require rebuilding the `grub.cfg` file as follows: -* On BIOS-based machines, issue the following command as `root`: +* Issue the following command as `root`: [subs="attributes"] ---- ~]#{nbsp}grub2-mkconfig -o /boot/grub2/grub.cfg ---- -* On UEFI-based machines, issue the following command as `root`: +* On UEFI-based machines the a chaining shim to `/boot/grub2/grub.cfg` should be installed in `/boot/efi/EFI/fedora/grub.cfg`. This shim can be recreated/reset as follows: [subs="attributes"] ---- -~]#{nbsp}grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg +~]#{nbsp}rm /boot/efi/EFI/fedora/grub.cfg +~]#{nbsp}dnf reinstall grub2-common ---- [[sec-Editing_a_Menu_Entry]] @@ -304,18 +307,19 @@ Where [option]`console=tty0` is the first virtual terminal and [option]`console= Changes to `/etc/default/grub` require rebuilding the `grub.cfg` file as follows: -* On BIOS-based machines, issue the following command as `root`: +* Issue the following command as `root`: [subs="attributes"] ---- ~]#{nbsp}grub2-mkconfig -o /boot/grub2/grub.cfg ---- -* On UEFI-based machines, issue the following command as `root`: +* On UEFI-based machines the a chaining shim to `/boot/grub2/grub.cfg` should be installed in `/boot/efi/EFI/fedora/grub.cfg`. This shim can be recreated/reset as follows: [subs="attributes"] ---- -~]#{nbsp}grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg +~]#{nbsp}rm /boot/efi/EFI/fedora/grub.cfg +~]#{nbsp}dnf reinstall grub2-common ---- [[sec-Adding_a_new_Entry]] @@ -361,9 +365,9 @@ Note that modifying the `/etc/default/grub` file does not have any effect on cre ==== -. On BIOS-based machines, copy the contents of `/boot/grub2/grub.cfg`, or, on UEFI machines, copy the contents of `/boot/efi/EFI/fedora/grub.cfg`. Put the content of the `grub.cfg` into the `/etc/grub.d/40_custom` file below the existing header lines. The executable part of the `40_custom` script has to be preserved. +. Copy the contents of `/boot/grub2/grub.cfg`. Put the content of the `grub.cfg` into the `/etc/grub.d/40_custom` file below the existing header lines. The executable part of the `40_custom` script has to be preserved. -. From the content put into the `/etc/grub.d/40_custom` file, only the `menuentry` blocks are needed to create the custom menu. The `/boot/grub2/grub.cfg` and `/boot/efi/EFI/fedora/grub.cfg` files might contain function specifications and other content above and below the `menuentry` blocks. If you put these unnecessary lines into the `40_custom` file in the previous step, erase them. +. From the content put into the `/etc/grub.d/40_custom` file, only the `menuentry` blocks are needed to create the custom menu. The `/boot/grub2/grub.cfg` file might contain function specifications and other content above and below the `menuentry` blocks. If you put these unnecessary lines into the `40_custom` file in the previous step, erase them. This is an example of a custom `40_custom` script: @@ -414,25 +418,26 @@ menuentry 'Second custom entry' --class red --class gnu-linux --class gnu --clas ** `01_users` (if it exists), ** and `README`. - ++ Alternatively, if you want to keep the files in the `/etc/grub2.d/` directory, make them unexecutable by running the [command]#chmod a-x # command. . Edit, add, or remove menu entries in the `40_custom` file as desired. . Rebuild the `grub.cfg` file by running the [command]#grub2-mkconfig -o# command as follows: - -** On BIOS-based machines, issue the following command as `root`: - ++ +** Issue the following command as `root`: ++ [subs="attributes"] ---- ~]#{nbsp}grub2-mkconfig -o /boot/grub2/grub.cfg ---- -** On UEFI-based machines, issue the following command as `root`: - +** On UEFI-based machines the a chaining shim to `/boot/grub2/grub.cfg` should be installed in `/boot/efi/EFI/fedora/grub.cfg`. This shim can be recreated/reset as follows: ++ [subs="attributes"] ---- -~]#{nbsp}grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg +~]#{nbsp}rm /boot/efi/EFI/fedora/grub.cfg +~]#{nbsp}dnf reinstall grub2-common ---- [[sec-GRUB_2_Password_Protection]] @@ -453,7 +458,7 @@ All menu entries can be password-protected against changes by setting superusers === Setting Up Users and Password Protection, Specifying Menu Entries . To specify a superuser, add the following lines in the `/etc/grub.d/01_users` file, where `john` is the name of the user designated as the superuser, and `johnspassword` is the superuser's password: - ++ [subs="quotes"] ---- cat <<EOF @@ -463,7 +468,7 @@ EOF ---- . To allow other users to access the menu entries, add additional lines per user at the end of the `/etc/grub.d/01_users` file. - ++ [subs="quotes"] ---- cat <<EOF @@ -474,7 +479,7 @@ EOF ---- . When the users and passwords are set up, specify the menu entries that should be password-protected in the `/etc/grub.d/40_custom` file in a similar fashion to the following: - ++ [subs="quotes, attributes"] ---- @@ -508,18 +513,19 @@ After you have made changes in the template file the GRUB 2 configuration file m Rebuild the `grub.cfg` file by running the [command]#grub2-mkconfig -o# command as follows: -* On BIOS-based machines, issue the following command as `root`: +* Issue the following command as `root`: [subs="attributes"] ---- ~]#{nbsp}grub2-mkconfig -o /boot/grub2/grub.cfg ---- -* On UEFI-based machines, issue the following command as `root`: +* On UEFI-based machines the a chaining shim to `/boot/grub2/grub.cfg` should be installed in `/boot/efi/EFI/fedora/grub.cfg`. This shim can be recreated/reset as follows: [subs="attributes"] ---- -~]#{nbsp}grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg +~]#{nbsp}rm /boot/efi/EFI/fedora/grub.cfg +~]#{nbsp}dnf reinstall grub2-common ---- [[sec-Password_Encryption]] @@ -594,26 +600,27 @@ This method completely removes all GRUB 2 configuration files and system setting . Run the [command]#rm /etc/sysconfig/grub# command; . For EFI systems *only*, run the following command: - ++ [subs="attributes"] ---- ~]#{nbsp}dnf reinstall grub2-efi shim grub2-tools ---- . Rebuild the `grub.cfg` file by running the [command]#grub2-mkconfig -o# command as follows: - -** On BIOS-based machines, issue the following command as `root`: - ++ +** Issue the following command as `root`: ++ [subs="attributes"] ---- ~]#{nbsp}grub2-mkconfig -o /boot/grub2/grub.cfg ---- - -** On UEFI-based machines, issue the following command as `root`: - ++ +** On UEFI-based machines the a chaining shim to `/boot/grub2/grub.cfg` should be installed in `/boot/efi/EFI/fedora/grub.cfg`. This shim can be recreated/reset as follows: ++ [subs="attributes"] ---- -~]#{nbsp}grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg +~]#{nbsp}rm /boot/efi/EFI/fedora/grub.cfg +~]#{nbsp}dnf reinstall grub2-common ---- . Now follow the procedure in xref:#sec-Reinstalling_GRUB_2[Reinstalling GRUB 2] to restore GRUB2 on the `/boot/` partition. @@ -656,18 +663,19 @@ The first line disables the graphical terminal. Note that specifying the `GRUB_T Rebuild the `grub.cfg` file by running the [command]#grub2-mkconfig -o# command as follows: -* On BIOS-based machines, issue the following command as `root`: +* Issue the following command as `root`: [subs="attributes"] ---- ~]#{nbsp}grub2-mkconfig -o /boot/grub2/grub.cfg ---- -* On UEFI-based machines, issue the following command as `root`: +* On UEFI-based machines the a chaining shim to `/boot/grub2/grub.cfg` should be installed in `/boot/efi/EFI/fedora/grub.cfg`. This shim can be recreated/reset as follows: [subs="attributes"] ---- -~]#{nbsp}grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg +~]#{nbsp}rm /boot/efi/EFI/fedora/grub.cfg +~]#{nbsp}dnf reinstall grub2-common ---- [NOTE]