GRUB2 is the latest version of GNU GRUB, the GRand Unified Bootloader. +A bootloader is the first software program that runs when a computer +starts. It is responsible for loading and transferring control to the +operating system kernel. In Fedora, the kernel is Linux. The kernel then initializes +the rest of the operating system.
+GRUB2 is the follower of the previous version GRUB (version 0.9x). The original version is available under the name GRUB Legacy.
+Since Fedora 16, GRUB2 has been the default bootloader on x86 BIOS +systems. For upgrades of BIOS systems, the default is also to install +GRUB2, but you can opt to skip bootloader configuration entirely.
+Installing GRUB2 on a BIOS system
+Normally, GRUB2 will be installed and set up by the installer, Anaconda, during the installation process. You will probably never have to deal with manual installation of GRUB2. However, in certain situations , you will want to install GRUB2 manually, especially if you need to repair the existing GRUB2 installation or you want to change its configuration.
+This procedure shows the steps to install GRUB2 on your Master Boot Record (MBR) of your primary hard disk.
+Before you start:
+-
+
-
+
Make sure you have the the GRUB2 packages and the
+os-prober
package installed in your system:++++$ dnf list installed | grep grub
+
+ -
+
To automatically collect information about your disks and operating systems installed on them, the
+os-prober
package needs to be installed on your system.
+
-
+
-
+
List block devices available on the system.
+++++$ lsblk
+
+ -
+
Identify the primary hard disk. Usually, it is the
+sda
device.
+ -
+
Install GRUB2 in the MBR of the primary hard disk.
+++++$ sudo grub2-install /dev/sda
+
+ -
+
Create a configuration file for GRUB2.
+++++$ sudo grub2-mkconfig -o /boot/grub2/grub.cfg
+
+ -
+
Reboot your computer to boot with the newly installed bootloader.
+
+
-
+
-
+
The
+grub2-mkconfig
command creates a new configuration based on the currently +running system. It collects information from the/boot
partition (or directory), from the/etc/default/grub
file, and the customizable scripts in/etc/grub.d/
.
+ -
+
The configuration format is changing with time, and a new configuration +file can become slightly incompatible with the older versions of the bootloader. Always run
+grub2-install
before you create the configuration file withgrub2-mkconfig
.
+ -
+
In Fedora, it is generally safe to edit
+/boot/grub2/grub.cfg
manually. Grubby in Fedora patches the configuration when a kernel update is performed and will try to not make any other changes than what is necessary. Manual changes can be overwritten withgrub2-mkconfig
when the system gets upgraded with +Anaconda. Customizations placed in/etc/grub.d/40_custom
or +/boot/grub2/custom.cfg
files will survive running thegrub2-mkconfig
command.
+
Installing GRUB2 on a UEFI system
+Normally, GRUB2 will be installed and set up by the installer, Anaconda, during the installation process. You will probably never have to deal with manual installation of GRUB2. However, in certain situations , you will want to install GRUB2 manually, especially if you need to repair the existing GRUB2 installation or you want to change its configuration.
+This procedure shows the steps to install GRUB2 on a UEFI system on Fedora 18 or newer. The procedure consists of three parts.
+Creating an EFI System Partition
+The UEFI firmware requires to boot from an EFI System Partition on +a disk with a GPT label. To create such a partition:
+-
+
-
+
List available block devices to find a place to create your ESP.
+++++$ lsblk
+
+ -
+
Create at least a 128 MiB disk partition using a GPT label on the primary hard disk.
+++++$ sudo gdisk /dev/sda
+++For the sake of this procedure, we assume that the created partition is recognized as
+/dev/sda1
.
+ -
+
Format the partition with the FAT32 file system.
+++++$ sudo mkfs.vfat /dev/sda1
+
+ -
+
Create the
+/boot/efi
directory as a mount point for the new partition.++++$ sudo mkdir /boot/efi
+
+ -
+
Mount the partition to the
+/boot/efi
mount point.++++$ sudo mount /dev/sda1 /boot/efi
+
+ -
+
Proceed to the next part.
+
+
Install the bootloader files
+In order to use GRUB2 with on the UEFI systems, you need to install or re-install appropriate packages:
+-
+
-
+
Re-install the necessary packages.
+++++dnf reinstall grub2-efi grub2-efi-modules shim
+
+ -
+
If the above command ends with an error, install the packages.
+++++dnf install grub2-efi grub2-efi-modules shim
+
+
-
+
-
+
This installs the signed shim and the GRUB2 binary.
+
+
Create a GRUB2 configuration
+If you already have a working GRUB2 EFI configuration file, you do not need to do anything else.
+Otherwise, create the configuration file using the grub2-mkconfig
command.
$ sudo grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg+
-
+
-
+
Under EFI, GRUB2 looks for its configuration in +
+/boot/efi/EFI/fedora/grub.cfg
.
+ -
+
For newly installed kernels to work, +
+grubby
expects/etc/grub2-efi.cfg
to be a symlink to the real +grub.cfg (for example/boot/efi/EFI/fedora/grub.cfg
).
+
Creating the boot menu entries with UEFI bootloader
+If not, shim
can help you bootstrap. The EFI program
+/boot/efi/EFI/BOOT/fallback.efi
will look for files called BOOT.CSV
+in your ESP and will add boot entries corresponding to them. The shim
command
+provides its own BOOT.CSV
file that will add an entry for grub2-efi
.
During the boot process, you can use the EFI Shell to invoke the fallback.efi
profile to boot the system:
-
+
-
+
Enter the boot partition.
+++++> fs0:
+
+ -
+
Navigate into the
+EFI\BOOT
directory.++++> cd EFI\BOOT
+
+ -
+
Invoke the
+fallback.efi
profile.++++> fallback.efi
+
+
-
+
-
+
If you have no boot entries at all, then just booting off your disk in +UEFI mode should automatically invoke
+/boot/efi/EFI/BOOT/BOOTX64.EFI
, +which will, in turn, invokefallback.efi
.
+ -
+
If you already have incorrect boot entries, you’ll either need to delete +them or to modify
+BOOT.CSV
to create new entries with different names.
+
Adding other operating systems to the GRUB2 menu
+Sometimes, however, you cannot use this approach and you will have to create the bootloader configuration file again to enable it to boot more operating systems.
+-
+
-
+
Make sure that the operating systems are on disks, connected to the system.
+
+ -
+
You have the
+os-prober
package installed.
+
-
+
-
+
Install GRUB2 into the MBR of your primary hard disk.
+++++$ sudo grub2-install /dev/sda
+
+ -
+
Recreate the GRUB2 configuration file.
+++++$ sudo grub2-mkconfig -o /boot/grub2/grub.cfg
+
+
-
+
-
+
The
+grub2-mkconfig
command will add entries for all operating systems it can find.
+ -
+
When problems appear, see the GRUB manual to solve issues with booting secondary operating systems.
+
+