Can I safely remove grub after installing rEFInd?

9,259

The short answer is "yes, you can safely remove GRUB if rEFInd works for you." There are some caveats, though. Most notably, it's always possible that something in the future will break. For instance, there's bug #1649326, which is preventing kernels 3.13.0-101 through at least 3.13.0-106 from booting via rEFInd (or any other method that relies on the EFI stub loader). That said, given the way Ubuntu keeps the currently-booted kernel installed, even if you ran into a problem like this, it should be possible to boot the old kernel via rEFInd, either indefinitely or until a real solution is found.

As to how to remove GRUB, the following command should delete the packages:

dpkg -P grub-efi-amd64 grub-efi-amd64-signed grub-common grub-efi-amd64-bin \
        grub-common grub2-common shim-signed

There are three caveats:

  • Package changes might necessitate a change to the preceding package list. (That list is taken from this page of the rEFInd documentation, which I wrote a couple months ago.)
  • This command removes the packages, but not the GRUB binary on the ESP. To delete that, you'll need to type sudo rm -rf /boot/efi/EFI/ubuntu.
  • Ubuntu is likely to try to add GRUB back. To deal with this issue, I personally employ an empty "dummy" package that claims to be GRUB 3. You can download it from here, if you care to use it. Since it claims to be GRUB 3, Ubuntu won't try to replace it with GRUB 2.

Alternatively, you could delete the files on the ESP and then simply lock the installed GRUB version with a command like this:

apt-mark hold grub-efi-amd64 grub-efi-amd64-signed grub-common \
              grub-efi-amd64-bin grub-common grub2-common

This should keep GRUB off the ESP and prevent future GRUB updates, although your current GRUB package will technically remain installed.

A third possibility is to use dont_scan_file or dont_scan_dirs in refind.conf to keep Ubuntu's GRUB out of the rEFInd menu. This solution won't remove GRUB at all, which has the advantage that it should remain accessible via the computer's built-in boot manager should it ever be needed. OTOH, if Ubuntu should update GRUB, it will take over as the default boot manager. See this page for more ideas on how to handle such issues.

Share:
9,259

Related videos on Youtube

png2378
Author by

png2378

Updated on September 18, 2022

Comments

  • png2378
    png2378 over 1 year

    I use rEFInd for dual-boot with Windows 10 on my PC and I want to remove GRUB because I don't use it and OS boots from rEFInd directly, without GRUB (after rEFInd installation, I removed ubuntu directory from /boot/efi/EFI).

    Can I do this safely? If so, how?

    Сurrent contents of my /boot/efi/EFI:

    maxim@ProBook:~$ sudo ls /boot/efi/EFI
    Boot  Microsoft  refind  tools
    

    Installed GRUB packages:

    maxim@ProBook:~$ dpkg -l | grep grub
    ii  grub-common                                    2.02~beta2-36+elementary11+r2~ubuntu0.4.1               amd64        GRand Unified Bootloader (common files)
    ii  grub-efi-amd64                                 2.02~beta2-36+elementary11+r2~ubuntu0.4.1               amd64        GRand Unified Bootloader, version 2 (EFI-AMD64 version)
    ii  grub-efi-amd64-bin                             2.02~beta2-36+elementary11+r2~ubuntu0.4.1               amd64        GRand Unified Bootloader, version 2 (EFI-AMD64 binaries)
    ii  grub-efi-amd64-signed                          1.66.2+elementary11~ubuntu0.4.1+2.02~beta2-36ubuntu3    amd64        GRand Unified Bootloader, version 2 (EFI-AMD64 version, signed)
    ii  grub2-common                                   2.02~beta2-36+elementary11+r2~ubuntu0.4.1               amd64        GRand Unified Bootloader (common files for version 2)
    

    Thank you in advance!

  • png2378
    png2378 over 7 years
    Thank you! I removed GRUB packages via your command (after that apt autoremove also removed mokutil, os-prober, secureboot-db and shim packages), installed "GRUB 3" and removed /boot/grub folder and it works! I tried to install newest kernel manually and didn't get any problems.
  • Carlos Pinzón
    Carlos Pinzón over 3 years
    I also had to add some more to the list and it worked: sudo dpkg -P grub-efi-amd64 grub-efi-amd64-signed grub-common grub-efi-amd64-bin \ grub-common grub2-common shim-signed os-prober grub-pc-bin grub-pc
  • DKebler
    DKebler over 3 years
    For others considering the options. I opted for locking grub (after making sure it was latest) then added EFI/ubuntu to the dont_scan_dirs. The reason being that if refind gets pooched for any reason (noo!) I can still boot from cmos to grub, but I don't have to worry that updates to grub will overwrite the boot order I set to refind. This has always been the rub with grub (ha ha).
  • tekHedd
    tekHedd over 2 years
    I successfully used the "hold" method on a Devuan single-boot install, that kept reverting to a non-working grub2 boot on updates. I recursively deleted /boot/efi/EFI/devuan and the system still boots to rEFInd nicely. YMMV good luck!