Install Grub for UEFI Systems

 Published on 18 Dec 2023 .  Filed in Notes .  185 words
Table of Contents

Install Grub Bootloader

The command installs the GRUB bootloader for UEFI systems :

sudo grub-install \
  --target=x86_64-efi \
  --efi-directory=/boot/efi \
  --bootloader-id=grub_uefi
  • sudo grub-install Runs the GRUB installer with administrator privileges.
  • –target=x86_64-efi Installs the 64-bit UEFI version of GRUB.
  • –efi-directory=/boot/efi Specifies the mount point of the EFI System Partition (ESP). GRUB places its EFI binary (e.g., grubx64.efi) here.
  • –bootloader-id=grub_uefi Sets the name of the directory under EFI/ and the name of the UEFI boot entry. Example path created: boot/efi/EFI/grub_uefi

Delete a GRUB entry from UEFI firmware

First list current UEFI boot entries:

sudo efibootmgr

Find the entry named grub_uefi (example: Boot0001). Delete it using:

sudo efibootmgr -b 0001 -B

Replace 0001 with the actual entry number from your system.

Remove the GRUB directory created in the EFI System Partition:

sudo rm -r /boot/efi/EFI/grub_uefi

Restore another bootloader (Optional)

If you rely on another bootloader (e.g., Windows Boot Manager, systemd-boot, or another Linux distribution), ensure it is set as the default boot entry:

List entries:

sudo efibootmgr

Set the desired one as default:

sudo efibootmgr -o <order>

Where <order> is a comma-separated list of boot numbers (e.g., 0000,0002).