22

I'm dual booting Windows 10 (pre-Anniversary Update) and Fedora 24 on a Lenovo IdeaPad N580 (Intel Pentium B960 2.2GHz, 4GB RAM, UEFI with Secure Boot disabled). I originally had just Windows 10 and then installed Fedora 23 alongside it and everything worked fine - it worked as well when I upgraded to Fedora 24. A while back, I decided I wanted to try out Ubuntu, and installed it only overwriting the root, /boot and SWAP partitions and keeping my home partition. Windows 10 can still boot here. Then I decided I didn't like Ubuntu and reinstalled Fedora, with the 24 installer, trying to do exactly what I did with Ubuntu. The interface was a bit different, but I'm sure I did it correctly: after I did all the partition configuring, it gave me a popup saying "We will only touch these partitions," and the partitions it listed were root, /boot and SWAP. Nothing else.

Then, when it finished installing, I rebooted. The only options in the GRUB menu were Fedora and Fedora Recovery - nothing else. No Windows.

I tried installing rEFInd, which has worked for me in the past. But it didn't help, it gave me those same two options.

The Windows partition still exists and I can access it from Fedora - important files such as /bootmgr and /Boot/BCD seem intact. The Windows partition is at /dev/sda5.

As well, in the BIOS settings where Windows Boot Manager used to appear, it doesn't. It just has rEFInd and an entry with the model number of my hard drive - which I'm assuming just brings me to the GRUB menu. (I haven't actually tried bringing it to the top of the list and rebooting though - I'm a bit lazy :P)

Can someone help?

UPDATE: Manoj identified the issue: by formatting the /boot partition I was getting rid of the Windows EFI files. So I need to reconstruct the files at /boot/efi/EFI/Microsoft. I think I've reconstructed the directory /boot/efi/EFI/Microsoft/Boot, but I need the other files in Microsoft. Could someone tell me what files I need there?

TheInitializer
  • 309
  • 1
  • 2
  • 16

2 Answers2

29

Since you have copied all the required files to boot/efi/EFI/Microsoft/Boot, you need to rebuild Windows loader configuration. You will need a Windows bootable usb or dvd (64 bit will be preferable):

  1. Boot from your bootable medium. Make sure that you are booting in UEFI mode.

  2. At the first screen (where it asks you to choose language and keyboard), press Shift + F10. This will give you a command prompt.

  3. Type diskpartand then list disk (to list all available disks). Select appropriate hard drive by typing select disk #.

  4. Now type list partition and make sure that there is a partition of type system (the efi partition). Select this partition by typing select partition # and assign a temporary drive letter to it, say G by typing assign letter=G.

  5. Just to make sure that drive letter is correctly assigned, type list vol. You should see a volume with drive letter (Ltr) as G & file system (Fs) as FAT32

  6. Close diskpart by typing exit. Make sure that you are in X:\Sources.

  7. Type cd /d G:\EFI\Microsoft\Boot\. Now run these commands one by one.

    bootrec /scanos     
    bootrec /fixmbr    
    bootrec /fixboot
    bootrec /rebuildbcd    
    bcdboot C:\Windows /l en-us /s G: /f ALL
    
  8. Close the command prompt and restart the system. You should now be booting into Windows.

  9. Of course you may not or don't have the grub menu now. But installing grub is far more easy. Follow any one of these links for more info: link1, link2, link3

Sources : 1, 2, 3, 4.

EDIT - Make sure that you remove the drive letter G assigned to efi partition as soon as possible to keep it from showing up in My Computer.

genpfault
  • 532
  • 2
  • 6
  • 21
Manoj
  • 796
  • 1
  • 9
  • 18
  • Thank you, but I don't have a recovery USB (kinda stupid of me) and I can't create one without access to Windows. I'll try to find a way to make one – TheInitializer Aug 09 '16 at 17:12
  • 1
    `bootrec /rebuildbcd` failed for me but it worked anyway after I skipped it. – en4bz Nov 05 '16 at 02:34
  • 1
    What can you do if your partition isn't listed by `list disk`? – arshbot Jun 13 '19 at 05:32
  • As a remark to anyone who has issues with creating a bootable windows stick under linux: Download the official iso from the microsoft site and copy it onto your usb stick using the tool `woeusb`. I was trying dd and other things but only this approach has worked. Following the above steps afterwards helped to reconstruct the dual boot. – apparat Jan 29 '20 at 10:10
  • @arshbot follow the instructions here https://www.diskpart.com/windows-10/missing-efi-partition-windows-10.html to create EFI partition, then follow instructions above. – Ari Fordsham Oct 14 '20 at 15:10
  • I had a similar problem as I had used a 3rd party bootloader (Clover) in the EFI part which in turn the loaded the Windows EFI loader from another disk. When that disk died, I had no more loader for Win 10, but the Win10 system was still there. In the end, the `bcdboot` command recreated the missing files (no need to copy them from elsewhere) but `diskpart` listed the system as letter E: - I had to use the `select vol` and `assign letter=C` commands to force the Win10 to use C: before the `bcdboot` command worked (passing it `E:\Windows` did not work!) – SuperTempel Mar 30 '21 at 20:19
  • 1
    Perfect solutio ! :) Worked fine for me ... I just had a couple of problems, firstly the `cd /d G:\EFI\Microsoft\Boot\` didn't work because the folder didn't exist so I mkdir it :) Then the `bootrec /fixboot` didn't work because it told me Unauthorized permission ... But at the end everything's working fine now :) Thanks a lot – Simon Trichereau Jun 16 '21 at 21:08
0

Before starting back up your boot partition using mkdir $HOME/backup && sudo cp -R /boot $HOME/backup. Boot partition is usually limited to 100MB so it should be really small.

If you still have a Windows 10 bootable medium (like a USB stick or a DVD), you will be able to find the EFI files over there.

If you don't have a Windows bootable medium you can mount the ISO (download if necessary) using the command sudo mkdir /tmp/win10iso && sudo mount -o loop /location/of/win10.iso /tmp/win10iso.

When you successfully copied those EFI files to the Windows partition add an entry to the file /etc/grub.d/40_custom.

The entry would look like this:

menuentry 'Windows 10' {
set root='(hd0,msdos5)'
chainloader +1
}

In GRUB configuration the hdX stands for /dev/sdX and msdosY stands for /dev/sdXY. Note that hdX starts at 0 and /dev/sdX starts at A.

After that's done, update your GRUB with sudo update-grub2. Windows boot entry should now be there.

Condor
  • 65
  • 8