# Dual boot FreeBSD with Windows 10



## balanga (Aug 13, 2019)

I have Windows 10 installed on my ThinkPad X1 Carbon and thought I'd try dual booting it with FreeBSD, so I shrunk the main Windows partition and installed FreeBSD into the remaining free space, expecting the system to boot up with the FreeBSD boot manager prompt, which it seems to have always done in the past. Except... it didn't and booted up straight into FreeBSD.

Do I need to install the FreeBSD boot manager - boot0cfg() manually, or do I need to do something else?

This is the disk layout:-

```
root@X1:~ # gpart show
=>       63  468862065  ada0  MBR  (224G)
         63       1985        - free -  (993K)
       2048    1124352     1  ntfs  (549M)
    1126400  262932480     2  ntfs  (125G)
  264058880  204803248     3  freebsd  [active]  (98G)

=>        0  204803248  ada0s3  BSD  (98G)
          0  197132288       1  freebsd-ufs  (94G)
  197132288    7670960       2  freebsd-swap  (3.7G)
```


----------



## SirDice (Aug 13, 2019)

balanga said:


> Do I need to install the FreeBSD boot manager - boot0cfg() manually


Yes. It's the right choice too, boot0cfg(8) only works for MBR and UFS. It's fairly spartan though, so don't expect much. 

In the past I've also used Windows' own boot manager, but that was a long time ago, not sure if that would still work.


----------



## tedbell (Aug 13, 2019)

I just select the partition from my EFI menu. I use GPT.


----------



## SirDice (Aug 13, 2019)

Installing Windows 10 with GPT is a little tricky. You _must_ boot the Windows installer in EFI mode or else you can only install using the MBR scheme. This took me several installation attempts to figure out. I absolutely wanted GPT so I could easily dual boot to FreeBSD on ZFS. Never got around to dual booting though. Virtualbox worked much better and didn't require me to reboot the machine when I needed a FreeBSD desktop.


----------



## SirDice (Aug 13, 2019)

SirDice said:


> In the past I've also used Windows' own boot manager, but that was a long time ago, not sure if that would still work.


I suddenly remembered the tool I used for that, BCD edit: https://www.boyans.net/
Don't know how well it works now though, like I said, it was a long time ago.


----------



## obsigna (Aug 13, 2019)

I maintain on one of my boxes a Windows 10 partition which I need to boot-up on occasions when I want to test one of my software how it behaves in Windows.

The disk partition is similar to yours but not exactly the same.

```
# gpart show
=>       63  312581745  ada0  MBR  (149G)
         63  156364767     1  ntfs  (75G)
  156364830       2018        - free -  (1.0M)
  156366848     919552     2  !39  (449M)
  157286400         30        - free -  (15K)
  157286430  155295378     3  freebsd  [active]  (74G)

=>        0  155295378  ada0s3  BSD  (74G)
          0  146800640       1  freebsd-ufs  (70G)
  146800640    8494738       2  freebsd-swap  (4.0G)
```

However, the important point is that also in my case the Windows-NTFS partition is on /dev/ada0s1 and the FreeBSD partition is /dev/ada0s3 and the UFS slide is /dev/ada0s3a. So, I am pretty sure that the follwoing would work in your case without any changes.

That said, for dual booting I get away without any boot manager. On FreeBSD I wrote a shell script ~/bin/startwin

```
#!/bin/sh
gpart set -a active -i 1 ada0
shutdown -r now
```

Of course this shall be executed as root (sudo(8)), and it simply switches the active attribute to the Windows partition, and would reboot the machine immediately, which consequently boots into Windows - of course.

Now on Windows I put the following two files in my home directory:

1. dp_active_p3.txt

```
select disk 0
select partition 3
active
```

2. Start FreeBSD.bat

```
diskpart /s C:\Users\rolf\dp_active_p3.txt
shutdown /r /t 0
```

Now when I am finished with Windows, I simply execute the batch file as Administrator (right click on it and choose "admin start". This would switch the active attribute back to the FreeBSD partition and let the machine reboot immediately, and this of course into FreeBSD then.


----------



## balanga (Aug 13, 2019)

SirDice said:


> Yes. It's the right choice too, boot0cfg(8) only works for MBR and UFS. It's fairly spartan though, so don't expect much.



Thankfully that worked and was quite eventfully, and I have my FreeBSD Boot Manager available. I'm always afraid when Windows is involved that it might break something.


----------

