Skip site navigation (1)Skip section navigation (2)
Date:      24 Nov 1999 02:40:58 +0100
From:      naddy@mips.rhein-neckar.de (Christian Weisgerber)
To:        freebsd-questions@freebsd.org
Subject:   Re: boot prompts
Message-ID:  <81ffna$1qqv$1@bigeye.rhein-neckar.de>
References:  <383B1BA1.D804596D@dogma.freebsd-uk.eu.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Jonathon McKitrick <jcm@dogma.freebsd-uk.eu.org> wrote:

> I have seen two different boot prompts.
> One when the F1/F2 prompt is shown (DOS,
> FreeBSD)  and then another if i hit a
> key while the countdown is going on.
> What is the difference between these

Let me give you a quick rundown of the FreeBSD/i386 boot process.

It all starts out with the PC BIOS. Now, you have to understand
that the PC BIOS is incredibly stupid. All it can do is load the
first sector (512 bytes) from a hard disk. In its industry standard
version this "master boot record" contains a slice table and a
piece of code that silently checks which slice entry has a boot
flag set, then loads the first sector of that slice and executes
it in turn.

The MBR program can only boot whichever slice is currently set to
active. That's sufficient for booting FreeBSD. However, if you have
installed several operating systems, it doesn't give you a choice.
For that you need some kind of boot manager. FreeBSD comes with
Booteasy (boot0) which can replace the default MBR program. Booteasy
will scan its slice table, check the slice type, and offer you a
simple menu to choose from. That's the F1, F2, etc prompt.  Yes,
it's simplistic, but that's all you can you cram into 512 bytes
minus slice table.

In a FreeBSD slice, the first 8kB contain the basic boot strap.
It's split into the first sector (boot1), a sector for the disklabel
with the partition table, and the main part of the boot strap
(boot2). boot1 is loaded by the MBR (whether the default code or
Booteasy). Its main task is to pull in boot2. The FreeBSD bootstrap
is already quite powerful. It can support a serial console as well
as the local graphics adapter and keyboard, it allows you to enter
some options, and it can read a file straight from a UFS file
system. In fact, the boot strap can directly boot the kernel.

Nowadays, though, the bootstrap typically loads a program called,
appropriately enough, loader. This is by comparison a monstrous
(136kB on my box) piece of code, which contains a full-fledged
Forth interpreter, and allows for complex start up scripts *before*
the kernel has even been loaded. It is this loader which gives you
the ten second countdown for breaking to a command line or autobooting.
Ultimately, loader boots /kernel (or whatever kernel you specify).

Still with me? If you have a "dangerously dedicated" disk, there
are no slices, all the disk is implicitly a single FreeBSD slice,
and there is no traditional MBR. Instead, the first sector of the
disk is already the boot1 part of the FreeBSD bootstrap, which is
then directly loaded and executed by the BIOS. Some misguided BIOSes
refuse to boot a first sector that doesn't contain what looks to
them like a valid slice table--that's the "dangerous" part.

Here's a rough asciigram of the whole process:


                   PC BIOS
                    /  |
                   /   |
        if        /   MBR
    dangerously  |     or (sector 0 of disk)
     dedicated    \ Booteasy (boot0)
                   \   |
                    \  |
                    boot1 (sector 0 of FreeBSD slice) \  FreeBSD
                    boot2                             /  bootstrap
                    /  |
                   /   |
                  /    |
                 |  /boot/loader (optional)
                  \    |
                   \   |
                    \  |
                    /kernel


Or, expressed horizontally:

    BIOS --->  boot0 --->  boot1+boot2 ---> loader ---> kernel
                (not on
               dedicated                    (optional)
                 disk)

-- 
Christian "naddy" Weisgerber                  naddy@mips.rhein-neckar.de



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?81ffna$1qqv$1>