FreeBSD From Scratch
Prev |  | Next

# 2 Why would I (not) want FreeBSD From Scratch?

This is a legitimate question. We have sysinstall and the well known way to compile the kernel and the userland tools.

The problem with sysinstall is that it is severely limited in what, where and how it can install.

- It is normally used to install pre-built distribution sets and packages from some other source (CD, DVD, FTP). It cannot install the result of a `make buildworld`.

- It cannot install a second system under a directory in a running system.

- It cannot install in Vinum or ZFS partitions.

- It cannot compile ports, only install precompiled packages.

- It is hard to script or to make arbitrary post-installation changes.

- Last but not least, sysinstall is semi-officially at its End-Of-Life.

The well known way to build and install the world, as described in the Handbook, by default replaces the existing system. Only the kernel and modules are saved. System binaries, headers and a lot of other files are overwritten; obsolete files are still present and can cause surprises. If the upgrade fails for any reason, it may be hard or even impossible to restore the previous state of the system.

FreeBSD From Scratch solves all these problems. The strategy is simple: use a running system to install a new system under an empty directory tree, while new partitions are mounted appropriately in that tree. Many config files can be copied to the appropriate place and mergemaster(8) can take care of those that cannot. Arbitrary post-configuration of the new system can be done from within the old system, up to the point where you can chroot to the new system. In other words, we go through three stages, where each stage consists of either running a shell script or invoking `make`:

1. `stage_1.sh`: Create a new bootable system under an empty directory and merge or copy as many files as are necessary. Then boot the new system.

2. `stage_2.sh`: Install desired ports.

3. `stage_3.mk`: Do post-configuration for software installed in previous stage.

Once you have used FreeBSD From Scratch to build a second system and found it works satisfactorily for a couple of weeks, you can then use it again to reinstall the original system. From now on, whenever you feel like an update is in order, you simply toggle the partitions you want to wipe and reinstall.

Maybe you have heard of or even tried Linux From Scratch, or LFS for short. LFS also describes how to build and install a system from scratch in empty partitions using a running system. The focus in LFS seems to be to show the role of each system component (such as kernel, compiler, devices, shell, terminal database, etc) and the details of each component's installation. FreeBSD From Scratch does not go into that much detail. My goal is to provide an automated and complete installation, not explaining all the gory details that go on under the hood when making the world. In case you want to explore FreeBSD at this level of detail, start looking at `/usr/src/Makefile` and follow the actions of a `make buildworld`.

There are also downsides in the approach taken by FreeBSD From Scratch that you should bear in mind.

- While compiling the ports during stage two the system can not be used for its usual duties. If you run a production server you have to consider the downtime caused by stage two. The ports compiled by `stage_2.conf.default` below require about 8 hours (of which 4 hours are due to OpenOffice.org) to build on a contemporary system. If you prefer to install packages instead of ports, you can significantly reduce the downtime to about 10 minutes.

Prev | Home | Next
FreeBSD From Scratch |  | Prerequisites

This, and other documents, can be downloaded from ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/.

For questions about FreeBSD, read the documentation before contacting <questions@FreeBSD.org>.
For questions about this documentation, e-mail <doc@FreeBSD.org>.