What is Stage One, /boot/boot1, and Stage Two, /boot/boot2?

According to FreeBSD Handbook, 12.3 The Boot Manager and Boot Stages,
Conceptually the first and second stages are part of the same program, on the same area of the disk. Because of space constraints they have been split into two, but you would always install them together. They are copied from the combined file /boot/boot by the installer or bsdlabel (see below).

They are located outside file systems, in the first track of the boot slice, starting with the first sector. This is where boot0, or any other boot manager, expects to find a program to run which will continue the boot process. The number of sectors used is easily determined from the size of /boot/boot.

But in FreeBSD Architecture Handbook, 1.5 boot2 stage, it says that
You might wonder, why boot2 comes after boot0, and not boot1. Actually, there is a 512-byte file called boot1 in the directory /boot as well. It is used for booting from a floppy. When booting from a floppy, boot1 plays the same role as boot0 for a harddisk: it locates boot2 and runs it.

I am a little confused with the first description.
Does it mean that boot2 and boot1 both come after boot0?
My current understanding is that boot0 is a boot manager which is installed in MBR and boot2 is a boot loader which is installed in the first sector (at first track of the boot slice).
Is it correct or not?

Could someone give an explanation about boot0 , boot1 and boot2?
 
If understand this correctly boot0 is only for a hard disks while boot1 is there to start booting from a floppy. You can only start booting from one device at the same time. In other words, if you boot from your HD you use boot0, if you start booting from your floppy it's boot1. The next step is the same: boot2

To summarize:

Start from HD: boot0 -> boot2

Start from floppy: boot1 -> boot2
 
Don't quote me as gospel, but my understanding of the boot process is as follows:

boot0 is the BootEasy boot manager, and shows you the simple menu where you can select which slice/OS to boot using the F1, F2, F3 etc keys. Most people don't bother installing this ("No boot manager, standard MBR" option in sysinstall). This gets installed into the MBR of the disk. This is configured and managed via the boot0cfg() app.

boot is the boot blocks that can be configured to either start the loader program (normal setup) or the kernel directly. I believe this is the BTX loader, and is what you see onscreen when the cursor is twirling around, loads kernel modules listed in /boot/loader.conf. This comes in many flavours depending on if you are booting off a floppy, an MBR-formatted disk, a GPT-formatted disk, a ZFS pool, via PXE, etc. These are listed as /boot/gptboot, /bootgptzfsboot, /boot/zfsboot, /boot/pxeboot, /boot/boot1, /boot/boot2, etc). This is installed in the first blocks of the disk/slice.

loader is the program that shows the nice boot menu, where you can select Normal, Safe Mode, Single-User, etc. This program is located at /boot/loader and is configured via /boot/loader.conf. This program loads the kernel and boots the OS.
 
Graaf_van_Vlaanderen said:
If understand this correctly boot0 is only for a hard disks while boot1 is there to start booting from a floppy. You can only start booting from one device at the same time. In other words, if you boot from your HD you use boot0, if you start booting from your floppy it's boot1. The next step is the same: boot2

To summarize:

Start from HD: boot0 -> boot2

Start from floppy: boot1 -> boot2
I am still not sure. According to FreeBSD Architecture Handbook, I will agree to your opion.
But for the FreeBSD Handbook, it description hears like that

boot0 -> boot1 -> boot2.
 
I don't have an in depth understanding of boot0's code, but it's possible that when boot0 boots a FreeBSD slice, it doesn't bother chain loading the first sector at the start of the slice (where boot1 resides) because it knows boot1 will just chainload boot2 in turn. It would be logical for boot0 to short circuit that and chainload boot2 itself.

Other chainloading boot managers will still need boot1. They won't know about FreeBSD's boot1/boot2 design and the norm is for boot managers to just chainload to the first sector of a slice.

On a floppy, there is no MBR. The bsdlabel is written directly to it, but the PC BIOS still looks for boot code at sector 0.

Without boot0 your disk will still have a boot manager. It's just a very basic boot manager that does nothing more than chainload the partition marked "active" in the MBR.
 
aragon said:
I don't have an in depth understanding of boot0's code, but it's possible that when boot0 boots a FreeBSD slice, it doesn't bother chain loading the first sector at the start of the slice (where boot1 resides) because it knows boot1 will just chainload boot2 in turn. It would be logical for boot0 to short circuit that and chainload boot2 itself.

Other chainloading boot managers will still need boot1. They won't know about FreeBSD's boot1/boot2 design and the norm is for boot managers to just chainload to the first sector of a slice.

On a floppy, there is no MBR. The bsdlabel is written directly to it, but the PC BIOS still looks for boot code at sector 0.

Without boot0 your disk will still have a boot manager. It's just a very basic boot manager that does nothing more than chainload the partition marked "active" in the MBR.

Thank you very much.
But it hears a little different from the FreeBSD Architecture Handbook.
:q
 
Back
Top