How to remove unnecessary EFI entries from GRUB?

Solution 1:

Finally i am able to resolve this issue...went thru each and every file under /etc/grub.d/ directory and got rid of the entries not needed and then ran 'sudo update-grub'. I went into 25_custom and wiped all the entries into which were not needed(to boot into at the time of startup - like all the unnecessary EFI entries).

sudo gedit  /etc/grub.d/25_custom
sudo update-grub

Please make sure to make a backup of the files you are editing. Make sure that you are not storing any of the backup files starting with 25_custom...if you store it with 25_custom_today'sdate etc....EFI boot loader will still read the entries from that....For folks who have HP Laptop - this will definitely work for you.Thanks for all your help.

Update Faced this issue again with my Dell XPS Desktop. This time I need to do the same for custom_40 and custom_41. Please refer to anything under /etc/grub.d to find out the issues specific to your machine.

Another alternative to do this: Use grub-customizer - graphical user interface

sudo add-apt-repository ppa:danielrichter2007/grub-customizer
sudo apt-get update
sudo apt-get install grub-customizer
grub-customizer

egrub-customizer on my machine Now highlight the entry and remove it Save the changes once done.

With next reboot - you can check those unwanted entries are gone. enter image description here and good part about grub-customizer is that in the right side - it has the removed items - one can revert back some or all of them if you have deleted something by mistake. Also don't forget to purge the old kernels so that you can save on disk space also.

Solution 2:

To clean your Grub entry you have to decide which menuentry to remove, First let's edit the custom file script in the /etc/grub.d dir contain same content of your grub.cfg.

gedit /boot/grub/grub.cfg

Copy all contents and go to the file /etc/grub.d/40_custom

sudo gedit  /etc/grub.d/40_custom

Append the copied content to the lines founded in the 40_custom.

Now In this custom file just remove all menuentries that you don't want to appear in your Grub menu. Take sure to remove the node of the menuentry which is enclosed by { }

Now when you finish Save the 40_custom file and exit from gedit

Then run the command:

sudo update-grub

This command will create a new boot menu in the file /boot/grub/grub.cfg that contains the custom menu items that we have specified.

You can check, ahead of rebooting, just to be sure, by using the command: gedit /boot/grub/grub.cfg. This will open the file in read-only mode.

If the file is as you expect then go ahead and reboot else check where you have an error.

you can read some articles for more info such as this and this.