So I have tried to install CentOS on a laptop with existing Windows 10, after freeing some space by shrinking Windows parttion inside Windows. But, while it did boot up, it moved the system no non-EFI and garbled the Windows boot.
I do have Windows 10 installation media now. So I tried:
bootrec /fixmbr - succeeded
bootrec /scanos - finds 0 windows instalations?? Despite the Windows partition being perfectly readable.
bootrec /fixboot - access is denied?! Even after reformatting the EFI system partition.
bcdboot C:\windows /s N: /f UEFI - success. But boot is not fixed. (N is where I mount the EFI system drive)
So I renamed N:\EFI\Microsoft\Boot\BCD to BCD.old and did
bootrec /rebuildbcd
This did find the Windows installation successfully. But the boot is still not working!
Startup Repair from the installation media also fails.
I found that the installer created a second EFI style partition (but never marked it System). I tried creating BCD on that too, then I deleted the partition. Now I only have the original EFI partition with newly created BCD for the Windows I have, marked as System in diskpart. It still will not boot!
Moreover, after deleting the partition I tried to switch to Legacy First boot. Parted shows the EFI system partition as "boot" so I tried to create boot files on it also for BIOS:
bcdboot C:\windows /s N: /f UEFI
Still no boot!
I am totally baffled at this now. What can I do to get Windows back? I don't care if Linux boots - i can do a new install (probably a different distro) after I fix Windows.