Removing GRUB 2 is covered in the rEFInd documentation:
https://www.rodsbooks.com/refind/bootcoup.html#disabling_grub
In brief, you use apt
to remove the various GRUB packages, as you're trying; however, dependencies keep changing over time, so you may need to track them all down and remove them individually (or all in one command line). Unfortunately, an increasing web of dependencies is making this harder to do, since various packages you might want or need now depend on GRUB, even though they don't really need GRUB -- just any boot program. Thus, as @user10489 suggests, keeping GRUB around but ensuring that rEFInd is the default boot program may be easier and safer.
OTOH, if GRUB is kept installed, Ubuntu's package management will probably try to update it, sooner or later, and this may result in a boot coup, in which GRUB takes over as the default boot program. You can either deal with this manually or in a semi-automated way (by using refind-mkdefault
when it happens, or putting that in a shutdown script); or you can try to prevent GRUB updates by using apt-mark hold
, as in:
sudo apt-mark hold grub-efi-amd64 grub-efi-amd64-signed grub-common grub-efi-amd64-bin grub-common grub2-common
(That example is from the preceding documentation page. I haven't checked it today, so the package list might need to be changed.)
I can definitively say that it is possible to completely remove the GRUB packages and all their dependencies and the computer will continue to boot, so long as it's booting through rEFInd. I run several systems this way. (I'm rEFInd's maintainer.) It can be a nuisance, though, and it means that you might not get updates to some important packages, like shim
, since they're (unnecessarily) dependent upon GRUB. (rEFInd will, when Secure Boot is active, copy over whatever Shim binary it thinks is newest to rEFInd's directory, so rEFInd will continue to boot through that Shim binary even after the shim
package is removed. If Secure Boot is inactive, or if you set it up to boot with Secure Boot active without Shim, then this is irrelevant.)
As to GRUB's files on the ESP and the GRUB entry in the NVRAM, they're basically just harmless clutter, once you set up a rEFInd-only installation. If you want to remove those files and the NVRAM entry, you can do so, but you'll have to do so manually. AFAIK, there's no script to do this -- certainly not that ships with rEFInd, and AFAIK not with GRUB, either. It's not hard to do -- just one rm
command to delete the files and two efibootmgr
commands (one to find the relevant entry and another to delete it), but you need to know what you're doing. It's probably best to just leave it alone.