Why To Not Use Extended Partitions With FreeBSD

I wanted to install FreeBSD inside an extended partition (slice in FreeBSD parlance) on a MBR formatted disk. Most of the information on this topic amounts to:
  • This is not supported
  • Don't do that
  • Why don't you make some other tradeoff?
But not so much about the technical reason WHY this is not possible for people who don't like no for an answer. So, while plowing forward with trying to "do the impossible," I've found a couple of technicalities hindering or preventing this. I wrote this up so that other people will NOT waste their time trying to do the same thing I did. I suppose they could also take it as a personal challenge to overcome what stopped me, but I'm currently satisfied with "Don't do this" based on the reasons below. Hopefully anyone searching will find this and come to the same conclusion.

#1: The defaults for GEOM in the kernel (which affect gpart operation) make working with extended partitions difficult

GEOM_PART_EBR (kern.features.geom_part_ebr) is enabled by default as a kernel option, but so is GEOM_PART_EBR_COMPAT (kern.features.geom_part_ebr_compat) which disables the ability to modify partitions in the extended partition using gpart(8), including labeling them. The sysctl variables are read only, so no, you can't just change them after booting. If you even want to attempt doing this on a live install, you'll have to compile your own custom kernel and replace the existing one.

Personally, I didn't bother trying to solve this problem and tried skipping to the next one by making my own partition table with other tools like gparted. This is also difficult, since
  • BSD disklabel support is absent
  • It's hard to make small enough partitions for freebsd-boot without careful sector-counting
  • The tools won't tag partitions as some FreeBSD partition types and you aren't going to convince gpart(8) to do it
So, I'm not even sure enabling these options in the right order (EBR on, EBR_COMPAT off) would have helped.

#2: bsdinstall will refuse to help you install into an extended partition

Obviously understandable. This is actually the "easiest" problem to overcome by choosing the Shell option, learning how to write a fstab where indicated, and mounting existing partitions.

#3: boot1 doesn't seem to search extended partitions

This where I stopped trying. Boot1 needs to fit in a very very small space (512 bytes), so it needs to be very simple. Finding and traversing extended partitions are too esoteric a feature to be wasting bytes on. I would imagine it would be possible to make a more brittle boot1 that sacrifices other features to achieve extended partition booting, but that's beyond my patience to dive into the assembler knowledge just to discover BTX or loader also have issues.