I have a Windows machine which could dual boot between Windows 10 and ubuntu 18.04. After some Windows upgrade in Feb 2022, the machine could only boot directly into Windows 10. Thanks to the answers above and collected elsewhere, here below were the steps that I fixed the dual boot failure.
Step 1: Use bcdedit to set the correct booloader path for grubx64.efi
First, let’s check current BCD (Boot Configuration Data) settings. In windows, open command prompt as administrator, and type
bcdedit
In my case, it looks like
Windows Boot Manager
—-----------------------------
identifier {bootmgr}
path \EFI\ubuntu\shimx64.efi
...
Since my computer disables the secure boot, I should not use shimx64.efi. Hence, I changed the path to grubx64.efi using the command recommended by many people as
bcdedit /set {bootmgr} path \EFI\ubuntu\grubx64.efi
You can type bcdedit again to double check the path was now changed to
Windows Boot Manager
—-----------------------------
identifier {bootmgr}
path \EFI\ubuntu\grubx64.efi
...
Step 2: Copy a grubx64.efi bootloader to EFI System Partition (ESP)
In my Windows machine, the grubx64.efi bootloader was somehow lost after a previous Windows upgrade. Here below are the steps to check whether the bootloader exists in the EFI System Partition (ESP) or not.
In windows, open command prompt as administrator, and type the following commands to mount the boot partition on the drive P:. If P: is an existing drive, you should choose another drive, e.g., Z:. After mounting the system partition, change directory to the drive to check what files are in the \EFI\ubuntu directory.
mountvol P: /S
cd /d P:
cd EFI
cd ubuntu
dir
In my case, the directory contained shimx64.efi, mmx64.efi, grub.cfg, and BOOX64.CSV. It was good that grub.cfg was still there. However, there was no grubx64.efi.
Hence, what I did was to copy a grubx64.efi file into this directory. In my case, I had a USB drive with ubuntu 18.04 (my ubuntu image version). I inserted the USB drive into the Windows machine. The new drive appeared to be in F:. Since I was already in P:\EFI\ubuntu, I copied the bootloader without specifying the destination path.
copy "F:\efi\boot\grubx64.efi"
So far, I had done two things.
Used bcdedit to Set the correct booloader path for grubx64.efi.
Copied a grubx64.efi bootloader file to the EFI System Partition (ESP).
I rebooted the Windows machine, and the dual boot was working again. I can now boot into either Windows or ubuntu in turn smoothly without issues.