New ubuntu installation removed old grub configuration, cannot set up dual boot

Solution 1:

Ubuntu is installed in EFI mode, but Windows is installed in legacy BIOS mode

GRUB can't chainload a legacy BIOS bootloader when in EFI mode, and vice versa. This means that Windows is not being added to the GRUB boot menu.

To resolve this issue, either GRUB must be re-installed in legacy BIOS mode, or the Windows installation needs to be converted to boot using EFI.

To detect Windows Boot Manager in EFI boot mode, GRUB searches the EFI System Partitions (ESPs) for bootmgfw.efi. According to the output from Boot-Repair, this file is not present; the disk that Windows is installed to contains a legacy BIOS MBR, and no ESP.

Converting a Windows installation to EFI

Considering OP wishes to upgrade to Windows 11 in the future, the best solution would be to convert the Windows installation to EFI boot.

From a Windows installation (preferably the Recovery environment from that installation, otherwise you will need to supply the /allowFullOS switch to force conversion), or from a Windows PE environment such as the Windows installer, you can run mbr2gpt to convert the Windows disk in to a GPT partition table, and create the ESP.

From the recovery environment of the Windows installation which is to be converted, the system disk is the disk to be converted, so identifying the disk number, and supplying the /disk:<number> argument, is not necessary.

Otherwise, the disk number is identical to the one shown in diskpart. You can run list disk in diskpart from a Command Prompt to identify your disk number:

X:\Windows\System32>diskpart

Microsoft DiskPart version 10.0.19041.964

Copyright (C) Microsoft Corporation.
On computer: ...

DISKPART> list disk

You can then type exit to return to the Command Prompt.

Validate the conversion

Before you convert the disk, you must check to see if the disk can be converted, via the /validate switch.

From the Command Prompt:

X:\Windows\System32>mbr2gpt /validate /disk:<number>

If the disk is eligible for conversion, you will see:

MBR2GPT: Validation completed successfully

Perform the conversion

If all is good, and you are confident you have selected the right disk, you can then proceed with the conversion:

X:\Windows\System32>mbr2gpt /convert /disk:<number>

If all goes well, you will see these messages:

MBR2GPT: Conversion completed successfully
MBR2GPT: Before the new system can boot properly you need to switch the firmware to boot to UEFI mode!

If you reboot your system, your Windows installation may start booting over Ubuntu. Once Windows has booted up successfully, you can shut down Windows and select Ubuntu from the boot selection menu in your system firmware.

Updating the GRUB boot menu

Open up a Terminal, then run update-grub:

$ sudo update-grub

You should see Windows Boot Manager added to the GRUB boot menu. If so, you can now disable legacy BIOS boot in the system firmware.

Note also that there should be a Windows Boot Manager entry in your firmware's boot device selection menu. If there isn't, you need to run bootrec /FixMBR to add the option to NVRAM when Windows has booted in EFI mode. This may place the Windows Boot Manager entry higher in the boot order than Ubuntu. To reverse this, from a Terminal, list the NVRAM boot option entries:

$ sudo efibootmgr

Identify the number that corresponds to Ubuntu, then copy the BootOrder, moving Ubuntu to the beginning, and paste it in to the command, i.e., if the boot order is 0001,0002,0003, and Ubuntu is 0003, run:

$ sudo efibootmgr -o 0003,0001,0002

Ubuntu will now boot as the first operating system starting from the next reboot.