The code in the MBR or boot manager is sometimes referred to as stage zero of the boot process. This section discusses two boot managers: boot0 and LILO.
The boot0 Boot Manager: The MBR installed by FreeBSD's installer or boot0cfg(8) is based on /boot/boot0. The size and capability of boot0 is restricted to 446 bytes due to the slice table and 0x55AA identifier at the end of the MBR. If boot0 and multiple operating systems are installed, a message similar to this example will be displayed at boot time:
Other operating systems, in particular Windows®, will overwrite an existing MBR if they are installed after FreeBSD. If this happens, or you want to replace the existing MBR with the FreeBSD MBR, use the following command:
# fdisk -B -b /boot/boot0 device
where device is the boot disk, such as ad0 for the first IDE disk, ad2 for the first IDE disk on a second IDE controller, or da0 for the first SCSI disk. To create a custom configuration of the MBR, refer to boot0cfg(8).
The LILO Boot Manager: To install this boot manager so it will also boot FreeBSD, boot into Linux and add the following to the existing /etc/lilo.conf configuration:
other=/dev/hdXY table=/dev/hdX loader=/boot/chain.b label=FreeBSD
Specify FreeBSD's primary partition and drive using Linux specifiers, replacing
X with the Linux drive letter and Y with the Linux primary partition number. For a
SCSI drive, change /dev/hd to /dev/sd. The
loader=/boot/chain.b line can be omitted if both operating
systems are installed on the same drive. Next, run /sbin/lilo -v to commit the new changes. Verify these are
correct by checking the screen messages.
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 are always installed together. They are copied from the combined /boot/boot by the installer or bsdlabel.
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.
boot1 is very simple, since it can only be 512 bytes in size, and knows just enough about the FreeBSD bsdlabel, which stores information about the slice, to find and execute boot2.
boot2 is slightly more sophisticated, and understands the FreeBSD file system enough to find files, and can provide a simple interface to choose the kernel or loader to run.
loader is much more sophisticated and provides a boot configuration which is run by boot2.
bsdlabel(8) can be used to replace the installed boot1 and boot2:
# bsdlabel -B diskslice
where diskslice is the disk and slice to boot from, such as ad0s1 for the first slice on the first IDE disk.
The loader is the final stage of the three-stage bootstrap, and is located on the file system, usually as /boot/loader.
The loader is intended as an interactive method for configuration, using a built-in command set, backed up by a more powerful interpreter which has a more complex command set.
During initialization, the loader will probe for a console and for disks, and figure out which disk it is booting from. It will set variables accordingly, and an interpreter is started where user commands can be passed from a script or interactively.
The loader will then read /boot/loader.rc, which by default reads in /boot/defaults/loader.conf which sets reasonable defaults for variables and reads /boot/loader.conf for local changes to those variables. loader.rc then acts on these variables, loading whichever modules and kernel are selected.
Finally, by default, the loader issues a 10 second wait for key presses, and boots the kernel if it is not interrupted. If interrupted, the user is presented with a prompt which understands the command set, where the user may adjust variables, unload all modules, load modules, and then finally boot or reboot.
These are the most commonly used loader commands. For a complete discussion of all available commands, refer to loader(8).
Proceeds to boot the kernel if not interrupted within the time span given, in seconds. It displays a countdown, and the default time span is 10 seconds.
Immediately proceeds to boot the kernel, with any specified options or kernel name. Providing a kernel name on the command-line is only applicable after an unload command has been issued; otherwise the previously-loaded kernel will be used.
Goes through the same automatic configuration of modules based on specified variables, most commonly kernel. This only makes sense if unload is used first, before changing some variables.
Shows help messages read from /boot/loader.help. If the topic given is index, the list of available topics is displayed.
Processes the file with the given filename. The file is read in and interpreted line by line. An error immediately stops the include command.
Loads the kernel, kernel module, or file of the type given, with the specified filename. Any arguments after filename are passed to the file.
Displays a listing of files in the given path, or the root directory, if the
path is not specified. If
-l is specified, file
sizes will also be shown.
Lists all of the devices from which it may be possible to load modules. If
-v is specified, more details are printed.
Displays loaded modules. If
-v is specified,
more details are shown.
Displays the files specified, with a pause at each
Immediately reboots the system.
Sets the loader's environment variables.
Removes all loaded modules.
Here are some practical examples of loader usage:
To boot the usual kernel in single-user mode:
To unload the usual kernel and modules, and then load the previous or another kernel:
unload load kernel.old
Use kernel.GENERIC to refer to the default kernel that comes with an installation, or kernel.old to refer to the previously installed kernel before a system upgrade or before configuring a custom kernel.
Note: Use the following to load the usual modules with another kernel:unload set kernel="kernel.old" boot-conf
To load an automated kernel configuration script:
load -t userconfig_script /boot/kernel.conf
The splash screen creates an alternate boot screen. The splash screen hides all the boot probe messages and service startup messages before displaying either a command line or graphical login prompt.
There are two basic environments available in FreeBSD. The first is the default legacy virtual console command line environment. After the system finishes booting, a console login prompt is presented. The second environment is the graphical environment provided by Xorg. Refer to that chapter for more information on how to install and configure a graphical display manager and a graphical login manager.
The splash screen function supports 256-colors in the bitmap (.bmp), ZSoft PCX (.pcx), or TheDraw (.bin) formats. The splash image files must have a resolution of 320 by 200 pixels or less in order to work on standard VGA adapters.
To use larger images, up to the maximum resolution of 1024 by 768 pixels, load the VESA module during system boot. For a custom kernel, include the VESA kernel configuration option. Loading VESA support provides the ability to display a splash screen image that fills the whole display screen.
While the splash screen is being displayed during the booting process, it can be turned off any time by hitting any key on the keyboard.
The splash screen also defaults to being a screen saver outside. After a time period of non-use, the splash screen will be displayed and will cycle through steps of changing intensity of the image, from bright to very dark and over again. The configuration of the splash screen saver can be overridden by adding a saver= line to /etc/rc.conf. Several built-in screen savers are available and described in splash(4). The saver= option only applies to virtual consoles and has no effect on graphical display managers.
A few boot loader messages, including the boot options menu and a timed wait count down prompt, are displayed at boot time, even when the splash screen is enabled.
Sample splash screen files can be downloaded from the gallery at http://artwork.freebsdgr.org. By installing the sysutils/bsd-splash-changer port, splash images can be chosen from a collection randomly at each boot.
The splash screen .bmp, .pcx, or .bin image has to be placed on the root partition, for example in /boot.
For the default boot display resolution of 256-colors and 320 by 200 pixels or less, edit /boot/loader.conf so it contains the following:
splash_bmp_load="YES" bitmap_load="YES" bitmap_name="/boot/splash.bmp"
For larger video resolutions up to the maximum of 1024 by 768 pixels, edit /boot/loader.conf, so it contains the following:
vesa_load="YES" splash_bmp_load="YES" bitmap_load="YES" bitmap_name="/boot/splash.bmp"
This example assumes that /boot/splash.bmp is used for the splash screen. To use a PCX file, use the following statements, plus the vesa_load="YES" line, depending on the resolution:
splash_pcx_load="YES" bitmap_load="YES" bitmap_name="/boot/splash.pcx"
Beginning with FreeBSD 8.3, another option is to use ASCII art in TheDraw format.
splash_txt="YES" bitmap_load="YES" bitmap_name="/boot/splash.bin"
The file name is not restricted to “splash” as shown in the above example. It can be anything as long as it is one of the supported types such as, splash_640x400.bmp or bluewave.pcx.
Other interesting loader.conf options include:
This will stop the boot options menu from being displayed, but the timed wait count down prompt will still be present. Even with the display of the boot options menu disabled, entering an option selection at the timed wait count down prompt will enact the corresponding boot option.
This will replace the default words “FreeBSD”, which are displayed to the right of the boot options menu with the colored beastie logo.