FreeBSD Alongside Windows

As much as I like FreeBSD UNIX I can not change the fact that the most common computer combination on a planet is a PC with Windows system on it.

The most secure way to try another operating system is to run it inside some virtual machine – like VirtualBox for example – but as you get used to new os – its best to run it natively … and this is where the problems begin – you REALLY do not want to brick your laptop while trying to make some dual boot configuration. Its a lot better if your computer allows to use two different physical disks – does not matter if laptop or regular PC – this way you would be able to choose desired disk from BIOS – but with laptops its not always that easy.

This guide will show you how to install FreeBSD alongside existing Windows installation – without breaking Windows – and without touching the Windows bootloader – we will use Windows bootloader to boot FreeBSD here.

Its kinda based on earlier Install FreeBSD with One Command article.

By doing all these things – we will either use FreeBSD tools or Windows native tools – no third party software involved.

Shrink Windows Disk

The first thing we will do is shrinking the Windows partition – its officially supported.

To start – right-click with mouse on the This PC on your Windows system and select Manage.

Next – right-click the C: disk and select Shrink Volume… option.

Put at least 10240 MB for a desired size – I used 15 GB as I had some more free space.

Then click Shrink button.

After a while you will see Unallocated free space as shown below.

Create Temporary FAT32 Partition

You may create new FAT32 partition in the Disk Management addon – here are the steps.

Mouse right-click the empty space and select New Simple Volume… option.

Hit Next button.

Hit Next without changing the size.

Hit Next on the letter assign part.

For the File system: select FAT32 type and hit Next button.

Click Finish button.

You New Volume is ready.

Alternatively you can use cmd.exe instead to achieve that.

Hit [Windows] key – then type cmd – and as Command Prompt will be displayed – select Run as Administrator on the right side.

After clicking it you will see something like that – I already typed some diskpart.exe commands – and I will repeat them below in text form.

Now – the instructions to create FAT32 filesystem in that free space – here they are.

C:\Windows\system32> diskpart

Microsoft DiskPart version 10.0.19041.3636

Copyright (C) Microsoft Corporation.
On computer: DESKTOP-RP45912

DISKPART> list disk

  Disk ###  Status         Size     Free     Dyn  Gpt
  --------  -------------  -------  -------  ---  ---
  Disk 0    Online           40 GB    15 GB        *

DISKPART> select disk 0

Disk 0 is now the selected disk.

DISKPART> list partition

  Partition ###  Type              Size     Offset
  -------------  ----------------  -------  -------
  Partition 1    System             100 MB  1024 KB
  Partition 2    Reserved            16 MB   101 MB
  Partition 3    Primary             24 GB   117 MB
  Partition 4    Recovery           509 MB    39 GB

DISKPART> create partition primary size=10240

DiskPart succeeded in creating the specified partition.

DISKPART> format fs=fat32

  100 percent completed

DiskPart successfully formatted the volume.

DISKPART> assign

DiskPart successfully assigned the drive letter or mount point.

DISKPART> list partition

  Partition ###  Type              Size     Offset
  -------------  ----------------  -------  -------
  Partition 1    System             100 MB  1024 KB
  Partition 2    Reserved            16 MB   101 MB
  Partition 3    Primary             24 GB   117 MB
  Partition 5    Primary             10 GB    24 GB
  Partition 4    Recovery           509 MB    39 GB

After these instructions my Windows system assigned E: letter for this temporary FAT32 place.

Next we will download FreeBSD-14.2-RELEASE-amd64-zfs.raw.xz and put it into that E: drive.

Copying of the image shown below.

We are ready to reboot and boot from FreeBSD system live media.

We can use FreeBSD-14.2-RELEASE-amd64-disc1.iso and put it into some USB pendrive … or burn on a CD-ROM disc. Does not matter which method you would use – boot from this media on your Windows computer … I hope you know how to do it – but if you are not – let me know in the comments – I will try to help because its different for each vendor and computer. Sometimes its [F11] key and sometimes its [F9] key … you got the idea.

FreeBSD Live System Operations

After you boot the FreeBSD-14.2-RELEASE-amd64-disc1.iso media – choose Live System and type root on the login: prompt and hit [ENTER] key.

It will look more or less like that image below.

Now – we have live FreeBSD UNIX at our hands – we will now dump a FreeBSD partition into that ‘free’ 15 GB spot.

It will require to use ramdisk (as AMIGA systems always used) – then create a ZFS pool with compression enabled there – extract the FreeBSD-14.2-RELEASE-amd64-zfs.raw.xz image there – then map that image as virtual disk – and then dump needed partition into that free 15 GB spot … for a start πŸ™‚

FreeBSD # mdconfig -a -t malloc -s 4g
md0

FreeBSD # zpool create -m /tmp/ramdisk ramdisk md0
ZFS filesystem version: 5
ZFS storage pool version: features support (5000)

FreeBSD # zfs get compress
NAME     PROPERTY     VALUE  SOURCE
ramdisk  compression  on     default

FreeBSD # cd /tmp/ramdisk

FreeBSD # df -g .
Filesystem 1G-blocks Used Avail Capacity  Mounted on
ramdisk            3    0     3     0%    /tmp/ramdisk

Now we have our temp space ready.

We will now mount our FAT32 space at /mnt dir to get access to the FreeBSD-14.2-RELEASE-amd64-zfs.raw.xz disk image. Then we will extract that image into our ZFS compression enabled ramdisk pool.

In my computer my one and only physical disk is represented as ada0 device – as shown below.

You can press [CTRL]+[T] key combination to get the status of the xz(1) command.

FreeBSD # gpart show -p ada0
=>      34  83886013    ada0  GPT  (40G)
        34      2014          - free -  (1.0M)
      2048    204800  ada0p1  efi  (100M)
    206848     32768  ada0p2  ms-reserved  (16M)
    239616  51141261  ada0p3  ms-basic-data  (24G)
  51380877      1395          - free -  (698K)
  51382272  20971520  ada0p4  ms-basic-data  (10G)
  72353792  10485760          - free -  (5.0G)
  82839552   1042432  ada0p5  ms-recovery  (509M)
  83881984      4063          - free -  (2.0M)

FreeBSD # mount_msdosfs /dev/ada0p4 /mnt

FreeBSD # xz -c -d /mnt/FreeBSD-14.2-RELEASE-amd64-zfs.raw.xz > /tmp/ramdisk/14.2.raw

load: 0.65  cmd: xz 925 [running] 16.37r 13.91u 1.49s 78% 10584k
/mnt/FreeBSD-14.2-RELEASE-amd64-zfs.raw.xz (1/1)
  6.8 %       54.4 MiB / 1444.2 MiB = 0.038    89 MiB/s       0:16   3 min 50 s
load: 0.68  cmd: xz 925 [runnable] 24.76r 20.64u 2.07s 79% 10584k
 11.9 %       95.8 MiB / 1649.7 MiB = 0.058    67 MiB/s       0:24   3 min 10 s
load: 0.73  cmd: xz 925 [running] 33.01r 27.43u 2.71s 90% 10584k
 16.8 %      134.8 MiB / 1907.3 MiB = 0.071    58 MiB/s       0:32   2 min 50 s
load: 0.86  cmd: xz 925 [running] 50.50r 40.48u 4.34s 88% 10584k
 27.5 %      220.8 MiB / 2378.5 MiB = 0.093    47 MiB/s       0:50   2 min 20 s
load: 1.32  cmd: xz 925 [tx->tx_sync_done_cv] 123.00r 97.71u 10.53s 85% 10584k
 78.2 %      627.5 MiB / 4295.0 MiB = 0.146    35 MiB/s       2:03         35 s

FreeBSD # echo ${?}
0

FreeBSD # du -sm /tmp/ramdisk/14.2.raw
1632  /tmp/ramdisk/14.2.raw

FreeBSD # df -g .
Filesystem 1G-blocks Used Avail Capacity  Mounted on
ramdisk            3    1     2    44%    /tmp/ramdisk

Now we will map the FreeBSD-14.2-RELEASE-amd64-zfs.raw.xz image to a virtual disk – from which we would copy FreeBSD partition.

The process will involve deleting the temporary FAT32 partition.

FreeBSD # mdconfig -a -t vnode -f 14.2.raw
md1

FreeBSD # gpart show -p md1
=>      34  12649841    md1  GPT  (6.0G)
        34       345  md1p1  freebsd-boot  (173K)
       379     66584  md1p2  efi  (33M)
     66963   2097152  md1p3  freebsd-swap  (1.0G)
   2164115  10485760  md1p4  freebsd-zfs  (5.0G)

FreeBSD # gpart show ada0
=>      34  83886013    ada0  GPT  (40G)
        34      2014          - free -  (1.0M)
      2048    204800  ada0p1  efi  (100M)
    206848     32768  ada0p2  ms-reserved  (16M)
    239616  51141261  ada0p3  ms-basic-data  (24G)
  51380877      1395          - free -  (698K)
  51382272  20971520  ada0p4  ms-basic-data  (10G)
  72353792  10485760          - free -  (5.0G)
  82839552   1042432  ada0p5  ms-recovery  (509M)
  83881984      4063          - free -  (2.0M)

FreeBSD # umount /mnt

FreeBSD # gpart delete -i 4 ada0
ada0p4 deleted

FreeBSD # gpart add -t freebsd-zfs ada0
ada0p4 added

FreeBSD # gpart show -p ada0
=>      34  83886013    ada0  GPT  (40G)
        34      2014          - free -  (1.0M)
      2048    204800  ada0p1  efi  (100M)
    206848     32768  ada0p2  ms-reserved  (16M)
    239616  51141261  ada0p3  ms-basic-data  (24G)
  51380877       115          - free -  (58K)
  51380992  31458560  ada0p4  freebsd-zfs  (15G)
  82839552   1042432  ada0p5  ms-recovery  (509M)
  83881984      4063          - free -  (2.0M)

FreeBSD # gpart show -p md1
=>      34  12649841    md1  GPT  (6.0G)
        34       345  md1p1  freebsd-boot  (173K)
       379     66584  md1p2  efi  (33M)
     66963   2097152  md1p3  freebsd-swap  (1.0G)
   2164115  10485760  md1p4  freebsd-zfs  (5.0G)

FreeBSD # dd bs=1m status=progress if=/dev/md1p4 of=/dev/ada0p4
  5302648832 bytes (5303 MB, 5057 MiB) transferred 73.007s, 73 MB/s
5120+0 records in
5120+0 records out
5368709120 bytes transferred in 73.332077 secs (73210924 bytes/sec)

Now – as we have FreeBSD system copied into the right place – we need to take care about the bootloader part – and stick with me here – we do not change Windows bootloader to anything else – we just mount the UEFI partition and add one FreeBSD loader file there.

FreeBSD # mkdir /tmp/efi-bsd

FreeBSD # mount_msdosfs /dev/md1p2 /tmp/efi-bsd

FreeBSD # find /tmp/efi-bsd
/tmp/efi-bsd
/tmp/efi-bsd/EFI
/tmp/efi-bsd/EFI/BOOT
/tmp/efi-bsd/EFI/BOOT/bootx64.efi

FreeBSD # mkdir /tmp/efi-win

FreeBSD # mount_msdosfs /dev/ada0p1 /tmp/efi-win

FreeBSD # cp /tmp/efi-bsd/EFI/BOOT/bootx64.efi /tmp/efi-win/EFI/Boot/fbsdx64.efi

FreeBSD # umount /tmp/efi-bsd

FreeBSD # umount /tmp/efi-win

We need to clear the /etc/fstab file because it includes entries to partitions that does not exist on our disk.

FreeBSD # zpool import -R /mnt zroot

FreeBSD # zfs list
NAME                 USED  AVAIL  REFER  MOUNTPOINT
ramdisk             1.60G  2.03G  1.60G  /tmp/ramdisk
zroot               3.82G   557M   424K  none
zroot/ROOT          3.81G   557M   424K  none
zroot/ROOT/default  3.81G   557M  3.81G  /mnt
zroot/home           436K   557M   436K  /mnt/home
zroot/tmp            436K   557M   436K  /mnt/tmp
zroot/usr           1.69M   557M   424K  /mnt/usr
zroot/usr/obj        436K   557M   436K  /mnt/usr/obj
zroot/usr/ports      436K   557M   436K  /mnt/usr/ports
zroot/usr/src        436K   557M   436K  /mnt/usr/src
zroot/var           2.56M   557M   424K  /mnt/var
zroot/var/audit      444K   557M   444K  /mnt/var/audit
zroot/var/crash      440K   557M   440K  /mnt/var/crash
zroot/var/log        436K   557M   436K  /mnt/var/log
zroot/var/mail       436K   557M   436K  /mnt/var/mail
zroot/var/tmp        440K   557M   440K  /mnt/var/tmp

FreeBSD # :> /mnt/etc/fstab

FreeBSD # zpool export zroot

If you would not clear that – you will get an error message like this in the first FreeBSD boot.

If you forgot that – and you find FreeBSD in that state when booting it – do instructions from below.

Enter full pathname of shell or RETURN for /bin/sh: [ENTER]
root@:/ # zfs set readonly=off zroot
root@:/ # :> /etc/fstab
root@:/ # exit

That should fix it.

We are now done with operations in the FreeBSD Live System mode – we will not reboot back into Windows system.

FreeBSD # poweroff

Windows Bootloader Entry

As I said before – we will use native Windows bootloader to boot FreeBSD – so we are sure that we will not break the Windows installation and boot configuration.

Same as earlier – hit the [Windows] key – then type cmd – and as Command Prompt will be displayed – select Run as Administrator on the right side.

Now – type bcdedit to show current Windows boot entries.

It will look more or less like below.

C:\Windows\system32> bcdedit

Windows Boot Manager
--------------------
identifier              {bootmgr}
device                  partition=\Device\HarddiskVolume1
path                    \EFI\Microsoft\Boot\bootmgfw.efi
description             Windows Boot Manager
locale                  en-US
inherit                 {globalsettings}
default                 {current}
resumeobject            {e9d80909-b296-11ef-af20-c59746508e06}
displayorder            {current}
toolsdisplayorder       {memdiag}
timeout                 30

Windows Boot Loader
-------------------
identifier              {current}
device                  partition=C:
path                    \Windows\system32\winload.efi
description             Windows 10
locale                  en-US
inherit                 {bootloadersettings}
recoverysequence        {e9d8090b-b296-11ef-af20-c59746508e06}
displaymessageoverride  Recovery
recoveryenabled         Yes
isolatedcontext         Yes
allowedinmemorysettings 0x15000075
osdevice                partition=C:
systemroot              \Windows
resumeobject            {e9d80909-b296-11ef-af20-c59746508e06}
nx                      OptIn
bootmenupolicy          Standard

The ‘upper’ part is the Windows bootloader config – the ‘lower’ part is the Windows entry that allows that Windows system to boot.

We will now copy that Windows entry into FreeBSD one.

The first command will return us the ‘key’ under which this entry will be known – it was {e9d8090d-b296-11ef-af20-c59746508e06} in my case – we will use that in the next commands.

C:\Windows\system32> bcdedit /copy {current} /d "FreeBSD"
The entry was successfully copied to {e9d8090d-b296-11ef-af20-c59746508e06}.

C:\Windows\system32> bcdedit /set {e9d8090d-b296-11ef-af20-c59746508e06} path \EFI\BOOT\fbsdX64.efi
The operation completed successfully.​

C:\Windows\system32> bcdedit /set {bootmgr} displaybootmenu yes
The operation completed successfully.​

The last option was to enable always showing the boot menu to choose from.

After our copying operation now the bcdedit output will look more or less like that.

C:\Windows\system32> bcdedit

Windows Boot Manager
--------------------
identifier              {bootmgr}
device                  partition=\Device\HarddiskVolume1
path                    \EFI\Microsoft\Boot\bootmgfw.efi
description             Windows Boot Manager
locale                  en-US
inherit                 {globalsettings}
default                 {current}
resumeobject            {e9d80909-b296-11ef-af20-c59746508e06}
displayorder            {current}
                        {e9d8090d-b296-11ef-af20-c59746508e06}
toolsdisplayorder       {memdiag}
timeout                 30
displaybootmenu         Yes

Windows Boot Loader
-------------------
identifier              {current}
device                  partition=C:
path                    \Windows\system32\winload.efi
description             Windows 10
locale                  en-US
inherit                 {bootloadersettings}
recoverysequence        {e9d8090b-b296-11ef-af20-c59746508e06}
displaymessageoverride  Recovery
recoveryenabled         Yes
isolatedcontext         Yes
allowedinmemorysettings 0x15000075
osdevice                partition=C:
systemroot              \Windows
resumeobject            {e9d80909-b296-11ef-af20-c59746508e06}
nx                      OptIn
bootmenupolicy          Standard

Windows Boot Loader
-------------------
identifier              {e9d8090d-b296-11ef-af20-c59746508e06}
device                  partition=C:
path                    \EFI\BOOT\fbsdX64.efi
description             FreeBSD
locale                  en-US
inherit                 {bootloadersettings}
recoverysequence        {e9d8090b-b296-11ef-af20-c59746508e06}
displaymessageoverride  Recovery
recoveryenabled         Yes
isolatedcontext         Yes
allowedinmemorysettings 0x15000075
osdevice                partition=C:
systemroot              \Windows
resumeobject            {e9d80909-b296-11ef-af20-c59746508e06}
nx                      OptIn
bootmenupolicy          Standard

We are now done on the Windows bootloader operation.

Reboot the Windows system.

First FreeBSD Boot

After the reboot the Windows loader menu will welcome us.

Reasonable person would think that after choosing the FreeBSD position – we would just boot into it … we will – but not directly.

… and yes – it will require from you to walk thru all these windows and buttons everytime you would want to boot FreeBSD – but your Windows ‘ecosystem’ remains unmodified and untouched.

I am not a Windows expert – maybe someone of you will point me into better Windows bootloader configuration for FreeBSD hopefully πŸ™‚

If you feel comfortable – you can switch to REFIND bootloader … but that is a topic for another story.

Next thing after choosing the FreeBSD system you will see Preparing Automatic Repair message.

… and after a moment the Diagnosing your PC one.

Its also VERY symbolic that in all words in the last two messages only the your part was in LOWERCASE … like it is not your PC at all πŸ™‚

Next on the Automatic Repair screen click the Advanced options button.

On the next Choose an option screen choose Use another operating system button.

… and finally on a screen Choose an operating system window choose FreeBSD position.

Now – finally – you will boot into FreeBSD UNIX system.

You will see FreeBSD loader(8) as shown below.

… and later – after FreeBSD finishes to boot – you will see the login: prompt.

Welcome to the FreeBSD world.

“A world where anything is possible. Where we go from there is a choice I leave to you.”

EOF

16 thoughts on “FreeBSD Alongside Windows

  1. Pingback: FreeBSD ao lado do Windows – linux-BR.org

  2. Donald

    I do concur, running Windows is sometimes required. I prefer an alternative method, creating a Windows to go USB disk via Rufus. Yes, this requires reasonably performant external drive, but no messing with boot loaders, etc… Just F12 or whatever β€œchoose boot device” key your system uses. Note: if your system supports multiple internal drives, even better/easier. Windows to go because my thinkpad doesn’t support a second internal SSD

    Like

    Reply
    1. vermaden Post author

      I usually also prefer ‘physical’ disks – but I guess such dual boot setup with Windows (I started my Slackware Linux journey long before FreeBSD with dual Windows boot) can be very helpful for some – just another gateway into the UNIX world.

      Like

      Reply
  3. Pingback: Valuable News – 2025/02/03 | πšŸπšŽπš›πš–πšŠπšπšŽπš—

  4. Robin

    I would never ever consider dual-booting again. My own experieince was messy and damaging. I would boot Windows or Linux or whatever from a second drive, chosen at startup.

    Like

    Reply
    1. vermaden Post author

      I generally do not dual boot anywhere – my favorite bootloader is either FreeBSD loader(8) to choose ZFS Boot Environment or F11/F12 BIOS loader to choose physical disk to boot from – but I guess such dual boot setup with Windows can be very helpful for some – I started my Slackware Linux journey long before FreeBSD that way – just another gateway into the UNIX world.

      Like

      Reply
    1. vermaden Post author

      Thanks.

      I believe with Linux it would be much harder – it often requires multiple partitions, LVM, separate /boot filesystem, etc.

      Does Debian provides images of its entire system like FreeBSD does?

      Like

      Reply
  5. rm9792357b3f4ed

    Last year I did far too much distro tourism. My preferred method for multiple OS installs was to chainload each OS’s native boot loader from rEFInd. I’d install distros and let them create their own EFI partition and set up their own bootloader. After they’d finish I’d survey and revert whatever damage they’d done (stepping on boot configs is NOT exclusive to Windows) then make a new rEFInd conf entry for chainloading GRUB/systemd-boot/etc. In my motherboard setup I’d put rEFInd back at the top. Boom, done. It worked quite well and never randomly broke, even after OS upgrades.

    Like

    Reply
    1. vermaden Post author

      When I searched for dual/multiple boot guides – most/all of them used REFIND as the bootloader – so I wanted to try something different.

      Like

      Reply
  6. Shiunbird

    My ThinkPad P1 Gen 4 has 2 NVMe slots. I have found a very interesting solution for dual booting.

    First NVMe has Windows EFI.
    Second NVMe has FreeBSD EFI.

    From Windows, I can boot FreeBSD inside VirtualBox and from FreeBSD I can boot Windows inside a VM. And on top of that, I get raidz1 =)

    It works perfectly fine and I am looking forward to upgrading BSD to improve support to this laptop, as FreeBSD is much worse here than on the W530, including idle power consumption.

    Like

    Reply
    1. vermaden Post author

      I also use that way on many devices – BIOS is always my favorite bootloader – to choose physical disks from which the system should start – but article was created for those who would like to try/learn FreeBSD on their own bare metal machine – even if they only have one disk – and to make sure that new/other bootloader will not break their current setup πŸ™‚

      Like

      Reply

Leave a comment