grub2-install: command not found

The grub2-install command is used to install the GRUB 2 boot loader on a storage device. It copies GRUB 2 files into the /boot/grub2 directory and, on some platforms, installs GRUB 2 into the boot sector. However, grub2-install applies to BIOS systems, not UEFI. To install GRUB 2 on a UEFI system, use a package manager to install the grub2-efi package. Installing this package will copy GRUB 2 files onto the EFI system partition (ESP) in the /boot/efi directory.

Syntax

The syntax of the grub2-install command is:

# grub2-install [options] [device name]

The following are some options you can use with the grub2-install command:

Option Description
–modules {module names} Preload the specified kernel modules with the GRUB 2 boot loader.
—install-modules {module names} Install only the specified modules and their dependencies, rather than the default of installing all available modules.
—directory {directory name} Install files from the specified directory, rather than the default.
–target {target platform} Specify the target platform to install GRUB 2 for, rather than the platform that is currently running.
—boot-directory {directory name} Specify the boot directory to install GRUB 2 files to, rather than the default /boot/ directory.
–force Install GRUB 2 regardless of detected issues.

If you encounter below error while running the the grub2-install command:

grub2-install: command not found

you may try installing the below package:

# dnf install grub2-tools-1

Conclusion

Typically the bootloader is installed during the boot process, but it is possible that the bootloader could become corrupt and need to be reinstalled. To install the bootloader, execute the grub-install command and provide the device where you want to install GRUB.

Related Post