Remove GRUB bootloader from EFI

5,430

Its not like the space ocupied in the EFI partition by grub is huge, in my case in /boot/efi/EFI/ubuntu/ occupies 4.4 MB....

Perhaps if the bootloader is just bothering you could use:

Recommended Alternatives

  1. Use efibootmgr to manage the boot options
:~$ efibootmgr

BootCurrent: 0003
Timeout: 0 seconds
BootOrder: 0000,0003,0004,0005
Boot0000* ubuntu
Boot0003* rEFInd bootmgr
Boot0004* Windows Boot Manager
Boot0005* ubuntu
  1. Change the Boot Order
:~$ sudo efibootmgr --bootorder 0003,0000,0004,0005

BootCurrent: 0003
Timeout: 0 seconds
BootOrder: 0003,0000,0004,0005
Boot0000* ubuntu
Boot0003* rEFInd bootmgr
Boot0004* Windows Boot Manager
Boot0005* ubuntu
  1. Deactivate a specific boot
:~$ sudo efibootmgr --bootnum 0000 --inactive

BootCurrent: 0003
Timeout: 0 seconds
BootOrder: 0003,0000,0004,0005
Boot0000  ubuntu
Boot0003* rEFInd bootmgr
Boot0004* Windows Boot Manager
Boot0005* ubuntu

To actually remove what is in the EFI

  1. First we need to know where the ESP is mounted. Lets investigate. Under Linux, the ESP is usually mounted at /boot/efi, although sometimes at /boot, or /efi. Under macOS or windows the ESP is not mounted by default, so you must mount it yourself to access it....more info here
:~$ sudo fdisk -l | grep -i efi
/dev/sda2    1024000   1638399    614400  300M EFI System
:~$ df | grep -i sda2
/dev/sda2         303104   113684    189420  38% /boot/efi
  1. To access the EFI boot section we need to access as superuser

    a. normally you would do this with su

    b. Ubuntu has the su account locked so you would enter as sudo -s

username@nodename:~$ sudo -s
[sudo] password for username: 
root@nodename:/home/username# cd /boot/efi/
root@nodename:/boot/efi#
  1. Search for where grub is:
:/boot/efi# find . -iname *grub*
./EFI/ubuntu/grubx64.efi
./EFI/ubuntu/grub.cfg
  1. I would suggest to make a backup copy.

    a. cp -r ./EFI/ubuntu /home/username/tmp/ubuntu

    b. the files copied will have root as owner, to be able to access them you will need to change their ownership with sudo chown username -R /home/username/tmp/ubuntu/

  2. Now that you have a backup copy and determined that it is in ./EFI/ubuntu/... its upto you to delete what you want... rm -r ./EFI/ubuntu/

Best of Luck :)

P.S. I know I answered like 5 months late, but this was one of the first search engine matches , so I decided to give it an answer after I figured my own one out

Share:
5,430

Related videos on Youtube

Cybran
Author by

Cybran

Updated on September 18, 2022

Comments

  • Cybran
    Cybran over 1 year

    On Ubuntu 20.04, I want to remove the EFI bootloader installed by the default GRUB. Basically, I'm searching for the inverse of grub-install, which does not leave any dysfunctional remains (files on EFI partition, NVRAM entry, etc.) behind.

    • I don't want to uninstall GRUB packages
    • I don't want to uninstall Linux
    • I don't have Windows
    • There are other operating systems installed on the same drive with their own EFI bootloaders which must remain unaffected

    I did not find a command like grub-uninstall, but there has to be some easy way, right?

    • Artem S. Tashkinov
      Artem S. Tashkinov over 3 years
      efibootmgr does that. Google how to use it in case you have troubles understanding its manual. You may want to delete Ubuntu files in /efi/EFI/...
    • oldfred
      oldfred over 3 years
      If you have another boot loader. Uninstall Ubuntu from menu, Really UEFI boot menu askubuntu.com/questions/63610/… & askubuntu.com/questions/429610/… You may want to remove the mount of the ESP in fstab, so a major grub update does not reinstall it.