# Installing FreeBSD inside EBR



## TjPhysicist (Sep 23, 2013)

I recently got this laptop that came with Windows and three partitions. The third, in Windows, shows up inside an "extended partition" as a "logical partition". I shrank the third partition to make space to install *Free*BSD, which got me free space, but the space is INSIDE the "extended partition" box. 

In FreeBSD, it shows up as an "EBR" partition. `gpart show` results in something akin to:

```
0  ZZZZ md0s3  EBR  (120G)
>        0  YYYY         ntfs    (50G)
>        YYYY  ZZZZ         - free -  (70G)
```

(I'm using YYYY and ZZZZ because I don't remember the actual cylinder number's and I doubt they are important to the point I'm trying to get across here). 

Can someone tell me how to make a freebsd FreeBSD partition in the 70 GB free space?


----------



## kpa (Sep 23, 2013)

Can you just get rid of the extended partition and create a third primary partition? As far as I know FreeBSD does not support installing on a partition that is inside an EBR.


----------



## wblock@ (Sep 24, 2013)

From dim memory, FreeBSD will actually run from an extended partition.  It's just that /boot/mbr and /boot/boot0 can't boot into FreeBSD on an extended partition.  So it will require a non-FreeBSD multi-boot loader.


----------



## TjPhysicist (Sep 24, 2013)

Thanks guys, I have somehow managed to find a way to get the free space into a primary partition. So now I have two free primaries and was planning to use RootOnZFS/UFSBoot from the wiki. (I'm not sure If I should start a new topic for this, but it seemed wasteful, let me know If I should.)

The issue though, I am having NOTHING but issues. I figured I could configure BCD from Windows to boot up the UFS /boot partition and kickstart bsd FreeBSD from there.

Everything is fine, until this step: 
	
	



```
Fixit# gpart bootcode -b /mnt2/boot/boot0 ad0
```

I actually tried `gpart bootcode /boot/mbr ada0` (my disk shows up as ada).

I don't know how to convert that into 9.0+ talk. Additionally, If I just skip that part and start up the installer at that point to automate everything else (after mounting all the ZFS partitions into /mnt); I get this error during installation of base.txz:


```
can't set user=0/group=0 /var/empty
```

And obviously trying to boot into FreeBSD simply does not work; the computer just freezes on a blank screen.


----------



## dave (Sep 29, 2013)

My suggestion would be to reboot into Windows, download VirtualBox and install FreeBSD on that.  If you want to learn how to experiment with ZFS on root, create three virtual drives in VirtualBox and use those.


----------



## wblock@ (Sep 29, 2013)

TjPhysicist said:
			
		

> Everything is fine, until this step:
> 
> 
> 
> ...



That writes bootcode to the disk.  /boot/mbr is the standard bootcode that boots from the active partition.  /boot/boot0 is the multi-boot loader.

Since you are using BCD, neither of those should be written.  All they do is boot from a partition, and BCD will already do that.


----------



## wblock@ (Sep 29, 2013)

dave said:
			
		

> My suggestion would be to reboot into Windows, download VirtualBox and install FreeBSD on that.  If you want to learn how to experiment with ZFS on root, create three virtual drives in VirtualBox and use those.



Head contention will make that unpleasant.  The virtual drives could go on different physical drives, I guess.  But most VM software has a way to let the VM interact with real physical drives.  VirtualBox does that too, it requires creating a VMDK to point to the physical drive.


----------



## TjPhysicist (Oct 8, 2013)

I ended up sucking it up and moving a partition into the EBR so I can install FreeBSD on a primary. I did all the usual steps from the guide, except when I got to the bootloader part, on a random hunch I went with `gpart bootcode /boot/boot0 ada0` then finished the install via bsdinstall. I think part of the error with bsdinstall (the one I got while trying to intall base.txz) was due to the fact that I (as @wblock mentioned above) was trying to do it from a VM interacting directly with the drive it (and the host OS) was running on. Now I get boot0 which has F2 for FreeBSD and F3 for Windows and both boot awesomely.

Not exactly a solution to the original problem, I guess, but I guess trying to install ZFS root with dual boot on extended partition requires too much hoop-jumping.

Also: that guide needs to be updated to conform with the install disks, some of the commands there no longer work exactly as mentioned. (e.g. /mnt2/boot is not a folder, nor is there any need for it to be one).


----------

