# Ubuntu – How to restore Windows boot loader after removing Ubuntu

dual-bootgrub2windows

I am just about to install Ubuntu alongside Windows, just need to make sure I know how to remove it later.

I know from past the major problem was when I removed Ubuntu, I either still got into the GRUB booting menu, or I couldn't boot at all, and had to format HDD and start over. Now I found an article practically saying the Windows loader should be back upon deleting Linux partition, so I want to make sure:

If I have Windows and Ubuntu dualboot, and I want to get back to Windows booting quickly itself without choosing from any booting menu, is it enough to just delete the Ubuntu partition? Will the Windows loader override GRUB?

Thanks!

This depends on whether your operating systems are installed in UEFI mode or Legacy mode.
(If your PC is manufactured in the last 5-6 years, and came pre-installed with an operating system, it will most likely be UEFI.)
There is a similar question that you can follow to check whether you are using Legacy or UEFI.

Note: Irrespective of which mode you install in, if you simply delete the Ubuntu partition, it won't make the Windows bootloader default automatically. You have to do it once, manually.

## If you install in Legacy mode and then delete the Ubuntu partition

You'll most likely end up in a grub rescue prompt on the next boot. You'll need a bootable recovery disk (either Windows or Linux) to help you restore your Windows boot sector.
Here is a similar question that can help in this case.

## If you install in UEFI mode and then delete the Ubuntu partition

You'll most likely end up in a GRUB command line prompt on the next boot, from where you'll have to boot to Windows and delete the GRUB EFI Firmware entry or change the order to put the Windows bootloader in the first place.
Here is a similar question that can help in this case.

## So, what's the better way?

### For Legacy

Boot to Windows first and use the bootsect tool to replace the GRUB boot sector with the Windows boot sector, and then delete the Ubuntu partition. Run these from an elevated Command Prompt :-

bootsect /nt60 SYS /mbr
bootsect /nt60 SYS


### For UEFI

Manually delete the GRUB EFI boot entry and/or set the Windows bootloader to the first position before you get rid of Ubuntu.
This answer to a similar question explains the process for deleting it in Windows.

To perform this from Ubuntu, the efibootmgr tool can be useful. Run :-

sudo efibootmgr -v


sudo efibootmgr -b XXX -B


to delete entry XXX.