Root on ... something that needs configuration first
Booting a system is black art: first you need to load a kernel
from somewhere, and after that, a root filesystem needs to be found.
Even if the kernel gets loaded somehow, loading the root filesystem may
not be trivial if some additional setup is needed to access the
disk it is on. This is e.g. the case with cgd(4) encrypted disks and
vnd(4) disk-images. Before any of those disk devices can be accessed,
they need some configuration. As the tools to configure those disk
devices are usually on the disk, using the same disk for a root filesystem
creates a chicken-and-egg problem.
One possible solution is to boot a kernel with a small md(4) ramdisk
that configures the disk device, but after a problem remains because
the actual root filesystem is on the md(4) disk, and not the newly
created disk device. Even with chroot(2), some problems like getting
the right init(8) to read the right /etc/ttys file remains.
To bring this solution one step closer to a working state,
Lubomir Sedlacik has committed code by Jachym Holecek to init(8) that allows
modifying the "init.root" sysctl node in the md(4) /etc/rc file,
which then results in a chroot(2) operation and running
another /etc/rc file, this time from the chroot directory.
That way, the md(4) /etc/rc can configure vnd(4), cgd(4) and
whatnot, and then set the sysctl node to the new disk to
do the actual boot process from there.
for a bit more data, including a reference to
the setup he uses for / on cgd(4).