Solved Can't boot Windows anymore after installing FreeBSD

Hello, newbie here!

After I installed FreeBSD one of the uefi entries "Windows Boot Manager" (Windows 8 from a different hard disk) doesn't boot anymore, it just boot directly to FreeBSD.

I tried deactivating the FreeBSD boot entry with "efibootmgr -b 0002 -A" to force to boot to Windows and now it just goes to the uefi setup menu.

I tried activating the Windows entry too, but it's already active.

I tried creating a new efi boot entry for Windows 8, but I can't make it, and I don't know if I did it right.

I really don't know what to do now and I can't just reinstall Windows, because I need the files there.

INFO:
Code:
 # efibootmgr -v
Boot to FW : false
BootCurrent: 0002
Timeout    : 2 seconds
BootOrder  : 0001, 0002
 Boot0001* Windows Boot Manager VenHw(99e275e7-75a0-4b37-a2e6-c5385e6c00cb)
                               HD(1,GPT,4997d151-1f5f-1e44-8529-5b869421dd6d,0x800,0x80000)/File(\EFI\Microsoft\Boot\bootmgfw.efi)
+Boot0002* FreeBSD HD(1,GPT,374e724e-787d-11ec-90fc-eca86bb12c6b,0x28,0x82000)/File(\efi\freebsd\loader.efi)
                      ada1p1:/efi/freebsd/loader.efi /boot/efi//efi/freebsd/loader.efi

Code:
 # gpart show
=>       34  488397101  ada0  GPT  (233G)
         34       2014        - free -  (1.0M)
       2048     262144     1  ms-reserved  (128M)
     264192  488132608     2  ms-basic-data  (233G)
  488396800        335        - free -  (168K)

=>       40  976773088  ada1  GPT  (466G)
         40     532480     1  efi  (260M)
     532520       1024     2  freebsd-boot  (512K)
     533544        984        - free -  (492K)
     534528    4194304     3  freebsd-swap  (2.0G)
    4728832  972044288     4  freebsd-zfs  (464G)
  976773120          8        - free -  (4.0K)

Code:
 # cat /etc/fstab
# Device                Mountpoint      FStype  Options         Dump    Pass#
/dev/ada1p1             /boot/efi       msdosfs rw              2       2
/dev/ada1p3             none    swap    sw              0       0
proc                    /proc           procfs  rw      0       0

linprocfs   /compat/linux/proc  linprocfs       rw      0       0
linsysfs    /compat/linux/sys   linsysfs        rw      0       0
tmpfs    /compat/linux/dev/shm  tmpfs   rw,mode=1777    0       0

fdesc   /dev/fd         fdescfs         rw      0       0
 
it just boot directly to FreeBSD.
Most BIOS/UEFI have a key for selecting the boot device, often it's F8 or F11 but depends on the implementation.

Code:
+Boot0002* FreeBSD HD(1,GPT,374e724e-787d-11ec-90fc-eca86bb12c6b,0x28,0x82000)/File(\efi\freebsd\loader.efi)
                      ada1p1:/efi/freebsd/loader.efi /boot/efi//efi/freebsd/loader.efi
The + here indicates it's going to boot FreeBSD on the next boot. efibootmgr -n 0001 should set BootNext to your Windows installation.

I can recommend installing rEFInd in your EFI partition. That will give you a nice boot selector, and it should automatically recognize both your Windows and the FreeBSD installs.
 
Oh, thanks for replying! \o/
Most BIOS/UEFI have a key for selecting the boot device, often it's F8 or F11 but depends on the implementation.
do you mean the boot entry menu of the efi(F7 on my machine)? I already tried that and it just boots to FreeBSD

The + here indicates it's going to boot FreeBSD on the next boot. efibootmgr -n 0001 should set BootNext to your Windows installation.
So I used "efibootmgr -n 0001" and I get "efibootmgr [-n | -N] -b bootnum" as output, then I use "efibootmgr -n -b 0001" and I get:
Code:
# efibootmgr -n -b 0001
Boot to FW : false
BootNext : 0001
BootCurrent: 0002
Timeout    : 2 seconds
BootOrder  : 0001, 0002
 Boot0001* Windows Boot Manager
+Boot0002* FreeBSD

So the 0002 still has the '+' indicator, I will reboot and go to the EFI boot entry menu to see if it worked and post the results soon...

I can recommend installing rEFInd in your EFI partition. That will give you a nice boot selector, and it should automatically recognize both your Windows and the FreeBSD installs.
Ok, I'll check it out. Do I need to install it from the rep?
 
Well, changing what bootnext didn't work, it just still boot to FreeBSD even though I selected the Windows Boot Manager entry.
 
Ok, I'll check it out. Do I need to install it from the rep?
There is no 'installer', you just copy a couple of files to the efi partition and configure your boot order (UEFI/BIOS) to boot rEFInd first.
 
There is no 'installer', you just copy a couple of files to the efi partition and configure your boot order (UEFI/BIOS) to boot rEFInd first.
Oh ok, so I need to put in both the FreeBSD and Windows efi partition? if not, which one?
 
Your Windows install appears to boot via CSM (aka BIOS boot), not through EFI. Assuming ada0 is the disk with Windows and you used ada1 to install FreeBSD on.
 
Installed rEFInd, it just detected freeBsd, and when I boot FreeBSD i get this.
20220124_164900-1.jpg
 
Your Windows install appears to boot via CSM (aka BIOS boot), not through EFI. Assuming ada0 is the disk with Windows and you used ada1 to install FreeBSD on.
One more thing, why my Boot0001 has "/File(\EFI\Microsoft\Boot\bootmgfw.efi)" and it has "EFI" in the name? Now I'm a bit confused.

one more thing, I'm trying hard to mount the ada0p1 partition
Code:
1. Name: ada0p1
   Mediasize: 134217728 (128M)
   Sectorsize: 512
   Stripesize: 0
   Stripeoffset: 1048576
   Mode: r0w0e0
   efimedia: HD(1,GPT,f28069c9-cd7a-409a-80b2-5c9f04d15df3,0x800,0x40000)
   rawuuid: f28069c9-cd7a-409a-80b2-5c9f04d15df3
   rawtype: e3c9e316-0b5c-4db8-817d-f92df00215ae
   label: Microsoft reserved partition
   length: 134217728
   offset: 1048576
   type: ms-reserved
   index: 1
   end: 264191
   start: 2048

but I just get a "invalid argument" error:
Code:
 # mount -t msdosfs /dev/ada0p1 /mnt
mount_msdosfs: /dev/ada0p1: Invalid argument
 # mount -t ext2fs /dev/ada0p1 /mnt
mount: /dev/ada0p1: Invalid argument
 # mount /dev/ada0p1 /mnt
mount: /dev/ada0p1: No such file or directory


More INFO:
Code:
 # fstyp /dev/ada0p1
ext2fs
Code:
 # /etc/autofs/special_media
ada0p2
ada0p1

edit1: one more information, I installed rEFInd in ada1p1:/efi/refind (/boot/efi/efi/refind)
Code:
# ls /boot/efi/efi/
boot/    freebsd/ refind/
 
One more thing, why my Boot0001 has "/File(\EFI\Microsoft\Boot\bootmgfw.efi)" and it has "EFI" in the name? Now I'm a bit confused.
There is an EFI directory on that filesystem. It's FAT32 so case doesn't matter. In that EFI directory you should have a windows directory (with the Windows EFI boot loader), a FreeBSD directory with a copy of loader.efi and a rEFInd directory with the files required for rEFInd.

one more thing, I'm trying hard to mount the ada0p1 partition
That looks to be a Windows MSR partition. It doesn't have a filesystem, and it's not used for booting the system.
 
So if I can't mount MSR partition that means I shouldn't put rEFInd files in it, just on FreeBSD. But I already did it, and the rEFInd menu just shows the FreeBSD boot entry.

In that EFI directory you should have a windows directory (with the Windows EFI boot loader)
Do you put the windows EFI boot loader in ada1p1:/boot/efi/efi? How do I do that? How do I get that Windows Bootloader (bootmgfw.efi I guess)? I'm kinda noob managing boot related issues.

That looks to be a Windows MSR partition. It doesn't have a filesystem, and it's not used for booting the system.
So which one is used as booting partition on windows? I'm a bit confused of what to now... :c
 
So which one is used as booting partition on windows?
Your Windows install on ada0 never EFI booted. It used the 'traditional' BIOS boot (called CSM nowadays). The 'traditional' BIOS boot worked by reading block 0 of the disk and executing the code that's contained in it.
 
One more thing, why my Boot0001 has "/File(\EFI\Microsoft\Boot\bootmgfw.efi)" and it has "EFI" in the name? Now I'm a bit confused.
...

edit1: one more information, I installed rEFInd in ada1p1:/efi/refind (/boot/efi/efi/refind)
Code:
# ls /boot/efi/efi/
boot/    freebsd/ refind/

I think your issue is that there is no /boot/efi/efi/Microsoft/boot/bootmgfw.efi
Maybe you can copy it from an usb installer of windows (by mounting the efi partition), but I am not sure that it will just works, especially if it was installed without uefi support in the first place.
 
but I am not sure that it will just works, especially if it was installed without uefi support in the first place.
Yeah, I'm not entirely sure that works either. With FreeBSD it's easy to switch between CSM and EFI boots. But Windows devs may have had other ideas about that. I'm also not sure you can EFI boot Windows from an EFI partition on a different disk.

Later on tonight I will be able to reboot my desktop, it's set up to dual boot (with rEFInd) Windows and FreeBSD, so I can have a quick look at the directory structure I've used. I've installed this system myself, did Windows 10 first, made sure it used GPT and EFI boot. Then installed FreeBSD on a bit of disk I left free. Added rEFInd to the ESP and it picked up Windows and FreeBSD automatically. No configuration of rEFInd was required.
 
I finally managed to solve it. The problem was like Monwarez said, there was no EFI partition in ada0 to execute, somehow it got deleted, and I didn't noticed it. So I recreated the EFI partition with the windows flash USB. Created a Efi entry with efibootmgr and it worked!

And thank you all for replying and helping me giving tips. You all were of great help!

And here is the article if someone need it: http://woshub.com/how-to-repair-deleted-efi-partition-in-windows-7/
 
Back
Top