27

I installed Ubuntu 18.04 using the "Something else..." option on a laptop with a single HDD that came with Windows 10. During installation I deleted all the partitions except the EFI partition. Then I created a / root file-system partition and a /home partition. All went well.

Except now I have an extra Windows entry in the UEFI boot menu that gets picked up by Grub. I can manually edit /etc/default/grub to hide the now defunct Windows boot option, but I want to get rid of the entry in the EFI system as well. How do I get rid of this final vestigial remnants of Windows?

user68186
  • 33,360

2 Answers2

55

Find UEFI boot entries

To remove the now useless Windows boot entry in the UEFI, first you need to find it. This can be done directly from the main Ubuntu OS. There is no need to boot from a live USB/DVD. The installed Ubuntu already has the required commandline utility.

Open a terminal by pressing Ctrl+Alt+T and then enter:

sudo efibootmgr

Enter the password when prompted and hit Enter. The cursor won't move and you won't see any asterisks(*****). This is normal in Ubuntu terminal. You will see some output like:

BootCurrent: 0002
Timeout: 2 seconds
BootOrder: 0002,0001,000
Boot0000* Dell
Boot0001* Windows Boot Manager
Boot0002* ubuntu

Note, I got two entries other than windows, 0 for "Dell" and 1 for "Windows Boot Manager". Since I deleted all the original partitions except EFI, I can no longer boot "Dell" or "Windows Boot Manager." I could delete both 0 and 1. But for this answer I will show how to delete only the Windows Boot Manager entry.

Note: the entries you want to delete may be different than this example. Use the output you get from your own computer, not the above example, to decide which entries you want to delete.

Delete the obsolete boot entries

Now that you know you want to delete the entry 1 (in this example), In the terminal enter:

sudo efibootmgr -b 1 -B

Note, the 1 in the command above. This command will delete the entry:

Boot0001* Windows Boot Manager

Delete the corresponding folder from the EFI partition

We are almost done. This last step makes sure the UEFI does not regenerate the entries we just deleted. To do this you have delete a folder corresponding the entry you deleted in the previous steps.

If EFI partition is not mounted:

In some computers the EFI partition may not be mounted by default. If this is the case, find out which one is the EFI partition with this command:

sudo os-prober

and look for the Windows Boot Manager. It may be /dev/sda1 for example. Yours may be different.

Then mount the EFI partition with:

sudo mount /dev/sda1 /boot/efi  

End of "If"

Now you find the name and location of the folder to delete. Use the following command to list all the folders in the EFI subfolder in the partition:

sudo ls /boot/efi/EFI

You will see some output like:

Dell Windows ubuntu

To delete the Windows (it may be called Microsoft) folder use the following command:

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

To verify that the folder was deleted, use the sudo ls /boot/efi/EFI command again.

Finally update GRUB to hide the GRUB menu

At this stage when you boot the laptop, GRUB will still show the menu to choose various OSs, even though you have only Ubuntu installed. Edit the file /etc/default/grub with the following command. You may use any other editor if you want.

sudo nano /etc/default/grub

Make the two lines look like this:

GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0

If the line GRUB_TIMEOUT_STYLE=hidden does not exist, add the line as above.

When done, save and exit the editor by Ctrl+X, followed by Y and Enter.

The final step is to update GRUB with the following command:

sudo update-grub

Now the laptop should directly boot Ubuntu without showing the GRUB menu. If you need to get to the recovery mode in the future, then hit Esc while the laptop boots to reveal the GRUB menu.

Reference: This answer is based on How do I remove "Ubuntu" in the bios boot menu? (UEFI)

user68186
  • 33,360
  • 2
    ESP should be already mounted on /boot/efi, I don't see a reason to mount ESP somewhere else. sudo ls /boot/efi/EFI and sudo rm -r /boot/efi/EFI/Windows should do it. – mook765 May 30 '18 at 16:52
  • @mook765 Thanks. I have edited the answer. – user68186 May 30 '18 at 17:04
  • efibootmgr can be buggy with some implementations. On those systems you might have to use bcfg from within a UEFI v2 shell. – Bob May 31 '18 at 00:52
  • @Bob Thanks! Feel free to add another answer using bcfg. I am not familiar with the UEFI shell. – user68186 May 31 '18 at 13:08
  • @user68186 I considered adding an answer but the Arch wiki really explains it better than I ever could, and I no longer have access to a machine I can easily try this on so at best it'd be a summary of the wiki. – Bob May 31 '18 at 13:30
  • @Bob Consider doing a summary of the wiki with any mods specific to Ubuntu as opposed to Arch and include a link to the wiki. Answer with just a link is not considered a good quality answer, as links can change over time. Any insights from your own experience may also be useful to future users. – user68186 May 31 '18 at 13:36
  • What if one gets EFI variables are not supported on this system after running sudo efibootmgr? I am using Ubuntu 20.04 – MadPhysicist Feb 20 '21 at 16:43
  • I am pretty sure it is UEFI. It is a pretty modern system. About 5 years old. – MadPhysicist Feb 20 '21 at 18:40
  • @MadPhysicist if it is UEFI system and EFI variables are not supported, then may be Ubuntu is installed in Legacy CSM mode. If this is the case, Windows (installed in UEFI mode) won't boot. – user68186 Feb 20 '21 at 19:15
  • ESP wasn't mounted for me on Ubuntu 21.04. I did sudo os-prober which showed Windows Boot Manager on /dev/sdb1, so I did sudo mount /dev/sdb1 /boot/efi. Also, my folder was called "Microsoft" rather than "Windows". – Alexia Luna Aug 02 '21 at 09:54
  • @nyuszika7h Thanks for this update. I am glad that you were able to figure it out and solve the problem. – user68186 Aug 02 '21 at 13:30
  • 1
    I wish I could upvote 1000 times. You really made my day. Thanks @user68186 – Sambhav Khandelwal Nov 14 '22 at 12:22
  • 1
    Man, you're a life saver!! – Muhammad Osama Jul 09 '23 at 19:13
-2

Open Terminal. cd /boot/efi/EFI. Remove Microsoft folder - sudo rm -R Microsoft. You can also remove the Boot folder - sudo rm -R Boot.

To remove Windows entry from grub2, sudo gedit /boot/grub/grub.cfg. Look for menu entry, Windows Boot Manager (or similar name description) and delete lines up to and including closing curly bracket, then save.

Job done. Restart.

Paul Benson
  • 1,022
  • 4
    A few problems with this answer: First, only deleting the folder may not be sufficient. See the comment by @Silversonic to the answer. Second, one should not use sudo directly with graphical programs like gedit as it can mess up user preferences. It is better to use sudo -i first to open a root shell if you want to use gedit with sudo. Third, directly editing grub.cfg is not recommended. It is recommended to edit /etc/default/grub and then sudo update-grub. – user68186 May 30 '18 at 19:19
  • 1
    See https://askubuntu.com/questions/1009574/which-best-practice-for-using-gedit-as-root for not using sudo gedit and see https://askubuntu.com/questions/437323/is-it-possible-to-edit-grub-cfg for more on editing grub.cfg. – user68186 May 30 '18 at 19:29
  • 1
    It is sufficient. There are no problems with it. It works 100%. I've done this a number of times and it's always worked each time. It makes no difference whether you use sudo -i then gedit, or sudo gedit. The latter does not muck up your user preferences. Where are you getting that from? You can edit grub.cfg with ease if you know what you're doing, and you can back up grub.cfg first if you're not confident. You are being pedantic. If you already know all the answers then why ask the question in the first place??? – Paul Benson May 30 '18 at 20:13
  • @PaulBenson I can't comment on the rest, but asking a question you know the answer to and then self answering is not only allowed but is actively encouraged. – Reinstate Monica May 31 '18 at 08:11