Re: "The installed loader is a binary, not a filesystem, so even minor changes require recompiling." -George W. Lucas in Absolute fBSD

From: Polytropon <freebsd_at_edvax.de>
Date: Mon, 18 Dec 2023 21:12:17 UTC
On Mon, 18 Dec 2023 20:17:58 +0000, Jop wrote:
> Though this aspect of his introduction to FreeBSD is not about
> FreeBSD directly, it seems vital for me to understand this
> correctly so that I can aptly understand FreeBSD as a sheer
> operating system and how an operating system boots.

You can find a nice description in the locally-available
documentation provided by FreeBSD, in "man 8 boot".



> I was confused about Lucas' description because he is implying
> there are some conditions in which a bootloader can be an actual
> filesystem.

That is technically not correct - it can _reside_ in a
filesystem.

While in classic MBR booting, the mentioned 512 B block
at a specific location is a binary - it will be executed
by the BIOS -, in EFI booting the boot loader, also being
a binary, has to reside on a FAT partition as a file.
Note again: The MBR boot block is not a file, it exists
outside of all and any partition.

However, it is not that simple. :-)

Normally, a boot loader boots one operating system. If
it allows you to select which OS to boot, i. e., which
partition transfer control to, it is often called a
"boot manager", but also it is a 512 B block. In case
of more advanced boot managers, this 512 B block boots
a specific partition, often called the "boot partition",
where the boot manager resides on, and that boot manager
then again is a binary in a file system (as with EFI).

Note that the concept of a file system is not tied to
a partition on a storage device, it can also reside as
a file system in memory, for example, by unpacking data
from a file into memory.



> This appears very illogical to me, as to me he seems
> to be saying the loader itself should be something like
> FAT32, UFS, or ZFS.

A boot loader cannot be a file system. It can be stored
on one, but that isn't a 1:1 relationship (read: "it
depends").



> Though filesystems, if my understanding is correct, help
> us organise our data, they do not themselves contain data
> but rather offer an organised space for that data, like a
> library with empty bookshelves that we are ourselves to fill.

Again, technically they are data, called meta-data. It
states where user data is actually stored, what access
paths get you to that data, what attributes the data
has and so on.

What I really recommend is the article about UFS (FFS)
by M. K. McKusick.



> Hence, if that "library" does not contain a bit of data
> (e.g. the bootloader) that tells the BIOS how to boot the
> operating system, the operating system cannot boot.

Correct - because there is no operating system (with just
a file system existing). In BIOS booting, a partition that
is marked active can be booted, which is what the BIOS does.
It transfers control to a specific location in that partition
and reads its content into memory to be executed. If that
what is found there is not a boot loader, nothing will happen.
It's like a freshly formatted FAT partition with the active
bit set - it doesn't boot DOS (not that DOS, the other one),
because there is no DOS on it (yet).

On FreeBSD, the boot process involves several steps, but
that also applies to Linux, where often the additional step
of a boot manager is included (but typically not required).
The first step transfers control to the active partition
with the boot program, that in turn reads the kernel, which
then boots, and constructs the requirements for the root
file system to be mounted, from where execution continues,
in order to run system services and startup programs, which
is the task of the "init" program. On the system boot level,
terms like "chain loading" or "second stage booting" are
common to describe those mechanisms.

As I said, "man 8 boot" contains a good overview on how
things work on FreeBSD, with SEE ALSO for parts like BTX
and boot0.


> Hence, it is logically implied that the bootloader cannot
> be called in itself a filesystem—not just sometimes under
> some conditions, but ever.

Yes. That is correct.



> Now, one a second note, I am new to the FreeBSD community,
> I have not before used mailing lists, and the FreeBSD forums
> were down. I understand IT communities can be strict about
> what and how things are communicated, and I hope i have done
> right by sending this email. I hope that I have done sufficient
> research by searching online, consulting the WiKi pages, the
> mailing list archives, and of course Lucas' book. I hope that
> my question is on-topic enough and that my beginner-level will
> not stagnate the flow of your erudite communications. Should
> I have not utilised this mailing list properly, kindly accept
> my apologies and let me know.

This mailing list is very friendly and polite, and you have
not done anything wrong. At least from my point of view. I
don't speak for anyone but myself, but allow me to welcome
you to FreeBSD and its user question mailing list, which
absolutely suits your inquiry. :-)



-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...