What GRUB is and why you might install a custom version

GRUB (Grand Unified Bootloader) is the program that runs when you turn on a Linux computer. It sits between your hardware and your operating system, letting you choose which system to boot if you have multiple ones installed, and passing control to the kernel once you pick one. Most Linux distributions install GRUB automatically during setup, but you might install a custom version if you want to change how it looks, add boot options that weren't there before, or fix a broken bootloader that won't let your system start.

A custom GRUB installation means replacing the version your distribution set up with one you configure yourself. This is different from just editing GRUB's menu — you're actually reinstalling the bootloader code to your disk. The process is straightforward if you follow the steps in order, but it does require working from a terminal and understanding which disk your system uses.

Key Takeaways

  • GRUB is the bootloader that starts your Linux system, and you can reinstall it with custom settings if the default version doesn't do what you need.
  • You need to know your disk name (usually /dev/sda or /dev/nvme0n1) and have root access or sudo permission before you start.
  • The installation process involves mounting your system, installing GRUB to the disk, and generating a new configuration file in the correct order.
  • If something goes wrong, you can boot from a Linux live USB and reinstall GRUB without losing your files.

Preparing your system and gathering the information you need

Before you install anything, you need to know which disk holds your Linux system. Open a terminal and type lsblk — this shows all your disks and partitions. Look for the one marked as your root partition (usually labeled with a forward slash /). If you have an older SATA drive, it will show as /dev/sda or /dev/sdb. If you have a newer NVMe drive, it will show as /dev/nvme0n1 or /dev/nvme1n1. Write down the disk name — not the partition number, just the disk itself.

You also need to know whether your system uses UEFI or BIOS. Type ls /sys/firmware/efi into the terminal. If a directory appears, you have UEFI. If you get "No such file or directory", you have BIOS. This matters because UEFI and BIOS installations use different commands and different disk locations.

Make sure you have root access. If you are not logged in as root, you will need to use sudo before each command. Test this by typing sudo -l — if it shows a list of allowed commands, you can proceed.

Installing GRUB on a BIOS system

If your system uses BIOS, the installation is simpler because GRUB goes directly to the disk's master boot record. Open a terminal and type sudo grub-install /dev/sda, replacing sda with your actual disk name if it is different. The command will take a few seconds and should end with "Installation finished. No error reported." If you see an error, double-check that you used the disk name (not a partition name like sda1) and that you have root permission.

After GRUB installs, you need to generate a new configuration file that tells GRUB which systems are available to boot. Type sudo grub-mkconfig -o /boot/grub/grub.cfg. This scans your disk for Linux installations and Windows installations if you have them, then writes a menu file. You should see lines that say "Found linux image" or "Found Windows Boot Manager" — these mean GRUB found your systems and added them to the menu.

Restart your computer. When it boots, you should see the GRUB menu with your system listed. If you do not see a menu, hold Shift while the computer starts — this forces GRUB to show the menu instead of booting directly to your default system.

Installing GRUB on a UEFI system

UEFI systems require an extra step because GRUB needs to know where your EFI partition is. First, find your EFI partition by typing lsblk again and looking for a partition marked as "EFI System" — it is usually small, around 100 to 500 megabytes. Write down its name, like /dev/sda1 or /dev/nvme0n1p1.

Type sudo grub-install --target=x86_64-efi --efi-directory=/boot/efi /dev/sda, replacing /dev/sda with your disk name and /boot/efi with the actual path to your EFI partition if it is mounted somewhere else. If your EFI partition is mounted at /boot/efi, the command above will work as written. The installation should finish with "Installation finished. No error reported."

Now generate the configuration file the same way as BIOS: type sudo grub-mkconfig -o /boot/grub/grub.cfg. Wait for it to finish, then restart your computer. You should see the GRUB menu when it boots.

What to do if GRUB does not appear or your system will not boot

If your computer boots straight to your operating system without showing a GRUB menu, GRUB is installed but set to hide the menu by default. This is not a problem — your system is working. If you need to see the menu to choose a different system, hold Shift while the computer starts.

If your computer does not boot at all and shows an error like "No bootable device found", GRUB may not have installed correctly. The safest way to fix this is to boot from a Linux live USB (the same kind you used to install Linux originally), then reinstall GRUB from there. Insert the USB, restart, and boot from it. Once you are in the live environment, open a terminal and repeat the installation steps above — the live system can reinstall GRUB to your main disk even though it is not running from it.

If you are not sure whether the installation worked, you can check by typing sudo grub-install --version to see which version is installed, and sudo grub-probe / to see whether GRUB can find your system. Both commands should return information without errors.

Customizing GRUB after installation

Once GRUB is installed and working, you can customize how it looks and behaves by editing its configuration file. Type sudo nano /etc/default/grub to open the settings file in a text editor. Common changes include setting GRUB_DEFAULT to choose which system boots by default (0 for the first one, 1 for the second, and so on), and setting GRUB_TIMEOUT to change how many seconds GRUB waits before booting the default system.

After you make changes, you must regenerate the configuration file for them to take effect. Type sudo grub-mkconfig -o /boot/grub/grub.cfg again. This reads your settings from /etc/default/grub and writes them into the actual menu file that GRUB uses when it boots.

You can also add custom boot entries by creating files in /etc/grub.d/, but this is more advanced. For most users, editing /etc/default/grub and regenerating the config file is enough.

When to reinstall GRUB and when to just edit the config

You only need to reinstall GRUB itself (using grub-install) if something is wrong with the bootloader code on your disk — for example, if your system will not boot at all, or if you switched from BIOS to UEFI. If GRUB boots fine but you just want to change the menu, edit /etc/default/grub and run grub-mkconfig instead. This is much faster and safer because you are not touching the bootloader code itself.

If you are just adding a new Linux system to your menu, you usually do not need to do anything — running grub-mkconfig will find it automatically. If you are adding a Windows system or another operating system, you may need to add a custom entry to /etc/default/grub or create a file in /etc/grub.d/, depending on whether GRUB found it on its own.

Frequently Asked Questions

What is the difference between grub-install and grub-mkconfig?

grub-install writes the bootloader code to your disk so your computer can start GRUB when it powers on. grub-mkconfig reads your settings and creates the menu file that GRUB displays. You need grub-install only once (or when something breaks), but you run grub-mkconfig every time you change your settings or add a new system to boot.

Can I break my system by installing GRUB wrong?

You can make your system unbootable if you install GRUB to the wrong disk or use the wrong commands for your BIOS/UEFI type, but you cannot lose your files. You can always boot from a live USB and reinstall GRUB correctly. As long as you double-check your disk name before running grub-install, you should be fine.

Do I need to reinstall GRUB if I add a new Linux system?

No. Just run grub-mkconfig after you install the new system, and GRUB will find it and add it to the menu automatically. You only reinstall GRUB itself if the bootloader code is damaged or if you need to change BIOS/UEFI settings.

Why does my GRUB menu not show up when I boot?

GRUB is probably set to hide the menu and boot directly to your default system. Hold Shift while your computer starts to force the menu to appear. If you want the menu to show every time, edit /etc/default/grub, set GRUB_TIMEOUT to a number greater than 0, and run grub-mkconfig again.

What if I have multiple disks and I am not sure which one to install GRUB to?

Run lsblk and look for the disk that contains your root partition (marked with /). That is the disk you install GRUB to. If you have a separate EFI partition on a different disk, GRUB still goes on the disk with your root partition — the EFI partition just needs to be accessible from there.