GRUB2 (GRand Unified Bootloader version 2) is the primary bootloader for Fedora 42. It is the first software program that runs when your computer starts, responsible for loading the operating system kernel and transferring control to it. This guide provides a detailed overview of installing, reinstalling, updating, and customizing GRUB2 on Fedora 42 systems.
/boot/grub2/grub.cfg
file, which is automatically generated and updated.GRUB2 is the cornerstone of the boot process in Fedora 42. It acts as the first program loaded when your computer starts, taking responsibility for loading the operating system kernel, which in Fedora's case is Linux. GRUB2 replaced the older GRUB (version 0.9x), also known as GRUB Legacy, and has been the default bootloader on x86 BIOS systems since Fedora 16.
In most cases, GRUB2 is automatically installed and configured during the Fedora 42 installation process using Anaconda, the Fedora system installer. However, there are scenarios where you might need to manually install or reinstall GRUB2, such as after a system upgrade or when setting up a dual-boot configuration.
During a fresh installation of Fedora 42, Anaconda typically handles the GRUB2 setup. The installer configures GRUB2 to boot the newly installed Fedora system. If you are setting up a dual-boot system, Anaconda usually detects other operating systems and adds them to the GRUB2 boot menu.
There might be situations where you need to manually install or reinstall GRUB2. This could be due to a corrupted bootloader, issues arising from dual-boot configurations, or after performing certain system updates.
Here are the general steps to reinstall GRUB2 from a live Fedora environment:
Download the Fedora Live ISO from the Fedora Project website and create a bootable USB drive. Boot your computer from this live USB.
Creating a bootable USB drive with Fedora Media Writer.
Open a terminal and use the lsblk
command to identify your system's partitions. Take note of the root partition (where Fedora is installed) and the EFI system partition (if using UEFI).
Mount the root partition to /mnt/root
. Replace /dev/sdXY
with your actual root partition.
sudo mount /dev/sdXY /mnt/root
If you have separate /boot
or EFI partitions, mount them as well.
sudo mount /dev/sdXZ /mnt/root/boot # Mount /boot partition
sudo mount /dev/sdXA /mnt/root/boot/efi # Mount EFI partition
Bind mount /dev
, /sys
, and /proc
from the live environment to the mounted root partition.
sudo mount --bind /dev /mnt/root/dev
sudo mount --bind /sys /mnt/root/sys
sudo mount --bind /proc /mnt/root/proc
sudo mount --bind /dev/pts /mnt/root/dev/pts
Use the chroot
command to enter your installed Fedora system.
sudo chroot /mnt/root
Reinstall the necessary GRUB2 packages. The specific packages may vary based on your system configuration (BIOS or UEFI).
For UEFI systems:
dnf reinstall grub2-efi grub2-efi-modules shim
For BIOS systems:
dnf reinstall grub2
Install GRUB2 to the appropriate location. For UEFI systems, this is typically the EFI partition. For BIOS systems, it's the MBR (Master Boot Record) of the disk.
For UEFI systems:
grub2-install /dev/sdX
For BIOS systems:
grub2-install /dev/sda
Create a new GRUB2 configuration file.
grub2-mkconfig -o /boot/grub2/grub.cfg
Exit the chroot environment and unmount the partitions.
exit
sudo umount /mnt/root/dev/pts
sudo umount /mnt/root/dev
sudo umount /mnt/root/sys
sudo umount /mnt/root/proc
sudo umount /mnt/root/boot/efi # If you mounted it
sudo umount /mnt/root/boot # If you mounted it
sudo umount /mnt/root
Reboot your system. GRUB2 should now be properly installed and configured.
Keeping GRUB2 up-to-date is essential for system stability and security. Fedora's package management system, DNF, usually handles GRUB2 updates automatically during regular system updates. However, it's good practice to manually update GRUB2 after a major system upgrade or kernel update.
DNF automatically updates GRUB2 packages when you run system updates:
sudo dnf update
After a Fedora release upgrade or kernel update, it's recommended to reinstall GRUB2 and regenerate the configuration file. This ensures that GRUB2 recognizes the new kernel and any other changes to your system.
Run the grub2-install
command to update the bootloader on your drive.
sudo grub2-install /dev/sda
Use grub2-mkconfig
to create a new GRUB2 configuration file.
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
GRUB2's behavior is primarily controlled by the /boot/grub2/grub.cfg
file. While it's possible to directly edit this file, it's generally not recommended, as manual changes can be overwritten during system updates. Instead, you should use the /etc/default/grub
file and the scripts in the /etc/grub.d/
directory to customize GRUB2.
This file contains global GRUB2 settings, such as the default timeout, default kernel options, and the GRUB theme.
This directory contains scripts that generate GRUB2 menu entries. You can add custom scripts here to create custom boot options.
/etc/default/grub
Here are some common options you can set in /etc/default/grub
:
Option | Description |
---|---|
GRUB_TIMEOUT |
Sets the timeout (in seconds) before the default menu entry is automatically booted. |
GRUB_DEFAULT |
Specifies the default menu entry to boot. Can be a number (starting from 0) or the title of the menu entry. |
GRUB_CMDLINE_LINUX |
Adds kernel parameters to the Linux kernel command line. |
GRUB_GFXMODE |
Sets the GRUB graphics mode (resolution). |
GRUB_BACKGROUND |
Specifies a background image for the GRUB menu. |
After making changes to /etc/default/grub
or the scripts in /etc/grub.d/
, you need to regenerate the /boot/grub2/grub.cfg
file for the changes to take effect:
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
/etc/default/grub
:
sudo nano /etc/default/grub
GRUB_TIMEOUT
:
Change the value of GRUB_TIMEOUT
to your desired timeout in seconds. For example, to set it to 10 seconds:
GRUB_TIMEOUT=10
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
You can customize the visual appearance of the GRUB2 menu by installing themes or manually configuring the background image and text colors.
GRUB2 themes provide a quick way to change the look and feel of the boot menu. You can find many GRUB2 themes online.
Download a theme from a trusted source.
Extract the theme files to /boot/grub2/themes/
:
sudo mkdir /boot/grub2/themes
sudo tar -xf downloaded-theme.tar.gz -C /boot/grub2/themes/
/etc/default/grub
:
Set the GRUB_THEME
variable to the theme's theme.txt
file:
GRUB_THEME="/boot/grub2/themes/theme-name/theme.txt"
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
GRUB Customizer is a GUI tool that simplifies GRUB2 configuration and customization. It allows you to easily change the boot order, edit menu entries, and customize the appearance of the GRUB menu.
sudo dnf config-manager --add-repo=copr: grub-customizer/grub-customizer
sudo copr enable grub-customizer/grub-customizer
sudo dnf install grub-customizer
Using Grub Customizer, Fedora users can streamline their boot process and tailor their system’s startup to meet their needs better.
GRUB Customizer on Fedora Linux.
GRUB2 makes it easy to set up a dual-boot configuration with other operating systems, such as Windows. During the Fedora installation, Anaconda usually detects other operating systems and automatically adds them to the GRUB2 menu.
To ensure that other operating systems are detected during the Fedora installation:
If you are dual-booting with Windows, it's generally recommended to install Windows first.
Make sure that your UEFI/BIOS settings are configured correctly for the operating systems you want to boot.
If GRUB2 doesn't automatically detect other operating systems, you can manually add them to the GRUB2 menu.
os-prober
:
This utility scans your system for other operating systems.
sudo dnf install os-prober
os-prober
:
sudo os-prober
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
GRUB2 should now detect and add the other operating systems to the boot menu.
GRUB2 issues can sometimes arise, especially after system updates or configuration changes. Here are some common problems and their solutions:
If you encounter a grub rescue>
prompt, it means that GRUB2 is unable to find its configuration files. This can happen if the GRUB2 files are corrupted or if the boot partition is not mounted correctly.
Use the ls
command to identify the partition containing the /boot/grub2
directory.
ls
Set the prefix
and root
variables to the correct partition. Replace (hdX,Y)
with the appropriate device and partition numbers.
set root=(hdX,Y)
set prefix=(hdX,Y)/boot/grub2
insmod normal
normal
If this works, GRUB2 should load normally. You can then boot into your Fedora system and regenerate the GRUB2 configuration file to fix the issue permanently.
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
Stuck in GNU Grub 2.0 Screen.
If an operating system is missing from the GRUB2 menu, it might not have been detected properly.
os-prober
:
sudo os-prober
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
GRUB2 is the GRand Unified Bootloader, version 2. It is the primary bootloader used in Fedora 42 and is responsible for loading the operating system kernel when the computer starts.
You can reinstall GRUB2 by booting from a Fedora live image, mounting your root partition, chrooting into your installed system, reinstalling the GRUB2 packages, and generating a new GRUB2 configuration file. Detailed steps are provided in the Manual Installation or Reinstallation section.
GRUB2 is typically updated automatically with system updates. However, you can manually update it by running sudo dnf update
, followed by sudo grub2-install /dev/sda
and sudo grub2-mkconfig -o /boot/grub2/grub.cfg
.
You can customize the GRUB2 menu by editing the /etc/default/grub
file and the scripts in the /etc/grub.d/
directory. After making changes, regenerate the GRUB2 configuration file using sudo grub2-mkconfig -o /boot/grub2/grub.cfg
.
It is generally recommended to install Windows first, then install Fedora. The Fedora installer usually detects the existing Windows installation and adds it to the GRUB2 menu. If it is not detected, you can manually add it by running sudo os-prober
and regenerating the GRUB2 configuration file.