Installing GRUB means writing the GRUB bootloader to a disk so that your computer can find and start an operating system. You usually do this after installing a Linux distribution that did not install a bootloader, after adding a second disk, or when repairing a system that no longer boots. The exact commands depend on whether you are installing GRUB from a running Linux system (BIOS or UEFI) or from a live rescue environment. This guide covers the common case: installing GRUB on a Linux system that is already running, with notes for UEFI and BIOS firmware.
What You'll Need
- A working Linux system with root or sudo access, or a live Linux USB if the system does not boot.
- The GRUB packages for your distribution (for example,
grub2orgrub-efi). - Knowledge of your disk layout: which disk is the boot disk (for example,
/dev/sdaor/dev/nvme0n1) and whether the system uses UEFI or BIOS. - A backup of important data. Writing a bootloader is low-risk but mistakes with disk names can destroy partitions.
- An EFI system partition (ESP) formatted as FAT32 if you are installing for UEFI. It is usually mounted at
/boot/efi.
Step-by-Step
- Confirm your firmware mode. Run
[ -d /sys/firmware/efi ] && echo UEFI || echo BIOS. If it prints UEFI, you need the EFI version of GRUB. If it prints BIOS, you need the BIOS version. Installing the wrong one is the most common reason GRUB does not appear at boot. - Install the GRUB packages. On Debian and Ubuntu, run
sudo apt update && sudo apt install grub-pcfor BIOS orsudo apt install grub-efi-amd64for UEFI on 64-bit x86. On Fedora and similar systems, usesudo dnf install grub2-pcorsudo dnf install grub2-efi-x64. On Arch, installgrubandefibootmgrfor UEFI. The package names vary, but the concept is the same: install the GRUB core for your firmware type. - Identify the disk, not the partition. GRUB is written to a disk (for example,
/dev/sda), not to a partition like/dev/sda1. Uselsblkto list disks and partitions. On NVMe drives the disk is named like/dev/nvme0n1and partitions are/dev/nvme0n1p1. Double-check before continuing. - Install GRUB to the disk (BIOS). On BIOS systems, run
sudo grub-install /dev/sda, replacing/dev/sdawith your boot disk. This writes the boot image to the disk's boot area and installs GRUB modules under/boot/grub. If you use a separate/bootpartition, GRUB handles it automatically as long as it is mounted. - Install GRUB for UEFI. On UEFI systems, make sure the EFI system partition is mounted at
/boot/efi. Then runsudo grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB. This copies the GRUB EFI binary to the ESP and creates a boot entry in the firmware. On some distributions the command isgrub2-installinstead. - Generate the GRUB configuration file. Run
sudo grub-mkconfig -o /boot/grub/grub.cfgon Debian/Ubuntu, orsudo grub2-mkconfig -o /boot/grub2/grub.cfgon Fedora/RHEL. On Arch and many others the output path is/boot/grub/grub.cfg. This step scans for installed operating systems and kernels and writes the menu entries. Without it, GRUB may show an empty or outdated menu. - Verify the boot entry and reboot. On UEFI, run
sudo efibootmgrto confirm a GRUB entry exists and is first in the boot order. Then reboot. If the system starts and shows the GRUB menu, the installation succeeded. If it boots straight to an OS or shows a firmware menu, see Troubleshooting below.
Common Mistakes
- Installing to a partition instead of a disk. Commands like
grub-install /dev/sda1are wrong for BIOS installs and can leave the system unbootable. Use the whole disk. - Mixing BIOS and UEFI. Installing BIOS GRUB on a UEFI system, or the reverse, produces a bootloader the firmware will not run. Check the firmware mode first.
- Forgetting to regenerate the config.
grub-installwrites the bootloader, but the menu comes fromgrub.cfg. Skippinggrub-mkconfigleaves old or missing entries. - Wrong EFI directory. If the ESP is mounted somewhere other than
/boot/efi, pass the correct path with--efi-directory. Otherwise the EFI files land in the wrong place. - Not mounting
/bootin a chroot. When repairing from a live USB, you must mount the root partition and any separate/bootand/boot/efipartitions before runninggrub-install.
Tips
- Run
lsblk -fto see filesystem types and confirm which partition is the EFI system partition (FAT32, usually mounted at/boot/efi). - Keep a live USB of your distribution handy. It lets you chroot into the installed system and reinstall GRUB if something goes wrong.
- On UEFI systems,
efibootmgrcan list, create, and reorder boot entries. If GRUB is installed but not first in the boot order, useefibootmgr -oto change it. - If you dual-boot, run
os-proberbeforegrub-mkconfigso other operating systems are detected. Some distributions disable it by default; check/etc/default/grub. - After a kernel update, the configuration is usually regenerated automatically. If you edit
/etc/default/grub, re-rungrub-mkconfigto apply changes.
Troubleshooting
GRUB does not appear at boot. Check the firmware boot order. On UEFI, run efibootmgr from a live environment and make sure the GRUB entry is first. If no entry exists, reinstall GRUB with the correct --efi-directory. On BIOS, confirm the disk's boot flag is set and that GRUB was installed to the correct disk.
GRUB shows a menu but no operating systems. The configuration file is missing entries. Boot a live USB, mount the root partition, chroot into it, and run grub-mkconfig again. Ensure /boot is mounted if it is a separate partition.
Error: grub-install: error: cannot find EFI directory. The EFI system partition is not mounted. Mount it at /boot/efi (or pass the correct path) and retry.
System drops to a grub> prompt. GRUB started but could not find its configuration. At the prompt, try ls to list devices, then set root=(hd0,1) and configfile /boot/grub/grub.cfg using the correct partition. If that works, reinstall GRUB and regenerate the config from a working system.
Secure Boot blocks GRUB. Some distributions sign GRUB for Secure Boot; others require you to disable Secure Boot or enroll keys. Check your distribution's documentation. Disabling Secure Boot is a common workaround but reduces boot-time protection.
Frequently Asked Questions
Do I need to reinstall GRUB after a kernel update?
No. Kernel updates usually trigger a configuration regeneration automatically. You only need to reinstall the bootloader if the GRUB core files are damaged or you change disks or firmware mode.
Can I install GRUB on a USB drive?
Yes. Install GRUB to the USB disk (for example, /dev/sdb) and make sure the firmware boots from it. This is useful for rescue drives, but performance and reliability depend on the USB device.
What is the difference between grub-install and grub-mkconfig?
grub-install writes the bootloader code to the disk or EFI partition. grub-mkconfig generates the menu configuration file that lists operating systems and kernels. You generally need both.
Does GRUB work with Windows dual-boot?
Yes. GRUB can chain-load Windows. Run os-prober before generating the configuration so the Windows entry is detected. Some distributions require enabling os-prober in /etc/default/grub.
How do I know if my system uses UEFI or BIOS?
Check for the directory /sys/firmware/efi. If it exists, the system booted in UEFI mode. If not, it is BIOS (legacy) mode. This determines which GRUB package and install command you need.
Can I reinstall GRUB without a live USB?
Yes, if the system still boots. Run the install and configuration commands from the running system. If the system does not boot, a live USB is the usual way to chroot in and repair GRUB.