This guide explains how UEFI (Unified Extensible Firmware Interface) and GRUB (GRand Unified Bootloader) cooperate to start your Linux system. You’ll learn what each component does, how they hand off control, and how to configure and troubleshoot the boot process. No prior deep knowledge is required, but basic familiarity with Linux and terminal commands helps.
What You’ll Need
- A computer with UEFI firmware (most systems from 2012 onward).
- A Linux distribution installed in UEFI mode (e.g., Ubuntu, Fedora, Arch).
- Root or sudo access to inspect and edit boot configuration.
- Optional: a live USB for recovery if something goes wrong.
Step-by-Step
- Understand the boot flow. When you power on, UEFI firmware initializes hardware, then reads a list of boot entries stored in NVRAM. Each entry points to an EFI executable file on the EFI system partition (ESP). The first valid entry is executed; in a typical Linux setup, that’s the GRUB bootloader (e.g.,
\EFI\ubuntu\shimx64.efior\EFI\GRUB\grubx64.efi). - Identify your firmware mode. Check if you’re booting in UEFI mode by running
[ -d /sys/firmware/efi ] && echo "UEFI" || echo "BIOS"in a terminal. If it prints UEFI, you’re on the right track. - Locate the EFI System Partition. Run
lsblk -forblkidto find the partition with typevfat(FAT32) and usually a mount point of/boot/efi. This is where GRUB’s EFI files live. - Examine GRUB’s configuration. The main config is
/boot/grub/grub.cfg(or/boot/grub2/grub.cfgon some distros). It’s generated by scripts and should not be edited directly. Instead, edit/etc/default/gruband files in/etc/grub.d/. - Understand GRUB’s role. GRUB reads its config, displays a menu (if configured), and then loads the Linux kernel and initramfs from the root or boot partition. It passes control to the kernel, which then mounts the real root filesystem.
- Check the boot entries. Run
efibootmgr -vto list UEFI boot entries. You should see an entry for your distro, e.g., “ubuntu” pointing to\EFI\ubuntu\shimx64.efi. If it’s missing, you can add it withefibootmgr -c -d /dev/sda -p 1 -L "Linux" -l \\EFI\\ubuntu\\shimx64.efi(adjust device and partition). - Reinstall or update GRUB if needed. On Debian/Ubuntu:
sudo grub-install(it will detect EFI and install to the ESP). Then runsudo update-grubto regenerate the config. On Fedora:sudo grub2-mkconfig -o /boot/grub2/grub.cfg. - Test with a reboot. After any change, reboot and see if the menu appears and the system boots. If you have multiple OSes, GRUB should list them.
Common Mistakes
- Editing grub.cfg directly: Changes are overwritten on the next update. Always edit
/etc/default/gruband run the update command. - Missing ESP mount: If
/boot/efiisn’t mounted, GRUB installation fails. Mount it first:mount /dev/sda1 /boot/efi(use your ESP device). - BIOS vs UEFI mismatch: Installing GRUB for BIOS firmware on a UEFI system (or vice versa) causes boot issues. Ensure you’re in the correct mode when installing.
- Secure Boot not handled: On many systems, you need shim (a signed bootloader) or disable Secure Boot. If you get “Invalid signature” errors, either enable shim or disable Secure Boot in firmware settings.
- Wrong partition for EFI: The ESP must be FAT32 and have the EFI system partition type (ef00 in gdisk). Using NTFS or ext4 will fail.
Tips
- Use
efibootmgrto manage boot order. For example,sudo efibootmgr -o 0000,0001sets the order. - If you want a hidden GRUB menu, set
GRUB_TIMEOUT=0in/etc/default/gruband run update-grub. Hold Shift (BIOS) or press Esc (UEFI) during boot to force it. - For dual-boot, install GRUB last so it detects Windows and adds an entry automatically.
- Backup your
grub.cfgbefore major changes:sudo cp /boot/grub/grub.cfg /boot/grub/grub.cfg.bak. - If you use LVM or LUKS, make sure the initramfs includes the necessary modules; GRUB itself doesn’t need them.
Troubleshooting
- System boots straight to Windows: Use
efibootmgrto change boot order, or press the boot menu key (F12, F2, etc.) during startup and select your Linux entry. - GRUB menu doesn’t appear: Try holding Shift or pressing Esc repeatedly at boot. If that fails, check
GRUB_TIMEOUTin the config; it might be set to 0. - Error: “no such partition” or “unknown filesystem”: This often means GRUB can’t find its files. Boot from a live USB, chroot into your system, and reinstall GRUB with
grub-installand update the config. - Secure Boot violation: Either disable Secure Boot in firmware or ensure you’re using shim. On some systems, you may need to enroll a key (MOK) for custom kernels.
- After a Windows update, Linux disappears: Windows may reset the boot order. Use
efibootmgrto reorder, or boot from a live USB and reinstall GRUB. - GRUB shows “Minimal BASH-like line editing”: This means the config is missing or unreadable. Use the
lscommand to find partitions, then manually set root and configfile, e.g.,set root=(hd0,gpt2)andconfigfile /boot/grub/grub.cfg.
Frequently Asked Questions
What is the difference between UEFI and BIOS?
UEFI is a modern firmware interface that supports larger disks, faster boot, secure boot, and a more flexible boot process. BIOS is the older legacy system with 16-bit code and limited features.
Can I use GRUB without UEFI?
Yes, GRUB supports both BIOS and UEFI. In BIOS mode, GRUB installs its core image to the Master Boot Record (MBR) of the disk.
Why does GRUB need an EFI System Partition?
UEFI firmware can only execute files from a FAT32 partition with a specific type. The ESP stores the GRUB EFI executable and other bootloaders.
How do I change the default GRUB boot entry?
Edit /etc/default/grub and set GRUB_DEFAULT to the menu entry number (starting from 0) or a saved entry. Then run update-grub.
What is shim and do I need it?
Shim is a small signed bootloader that allows GRUB to work with Secure Boot. If Secure Boot is enabled, you need shim or a signed GRUB binary.
Why does GRUB show a black screen after boot?
This can be due to graphics drivers or a missing framebuffer. Try adding GRUB_GFXMODE=text in /etc/default/grub and update, or use the nomodeset kernel parameter.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Valheim Server Not Showing in Community List Fixes
- DisplayPort vs HDMI: Which Cable Should You Use?
- Soundbar vs 2.1 Speaker System: Which Is Better?
- Mouse Moving on Its Own? Causes & Fixes
- Slack Channels for Construction Projects: Setup Guide
- Surface Won’t Turn On: Quick Fixes1.8 h