The first version of this article used a single shell script for stage one where all your customization had to be done by editing the script. After valuable user feedback I have decided to separate the code and data in the scripts. This allows to have different configuration data sets to install different systems without changing any of the code scripts.
The code script for stage one is
stage_1.sh
and when run with exactly one
argument, like
#
./stage_1.sh default
will read its configuration from
stage_1.conf.default
and write a log to
stage_1.log.default
.
Further below you find my stage_1.conf.default
.
You need to customize it in various places to match your idea of the
“perfect system”. I have tried to extensively comment
the places you should adapt. The configuration script must provide
four shell functions, create_file_systems
,
create_etc_fstab
, copy_files
and all_remaining_customization
(in case it
matters: this is also the sequence in which they will be called
from stage_1.sh
).
The points to ponder are:
Partition layout.
I do not subscribe to the idea of a single huge partition
for the whole system. My systems generally have at least
one partition for
/
,
/usr
and
/var
with
/tmp
symlinked to
/var/tmp
.
In addition I share the file systems for
/home
(user homes),
/home/ncvs
(FreeBSD CVS repository replica),
/usr/ports
(the ports tree),
/src
(various checked out src trees) and
/share
(other shared data without the need
for backups, like the news spool).
Luxury items.
What you want immediately after booting the new system and
even before starting stage two. The reason for not simply
chrooting to the new system during stage one and installing
all my beloved ports is that in theory and in practice there
are bootstrap and consistency issues: stage one has your old
kernel running, but the chrooted environment consists of new
binaries and headers. If the new binaries use a new system
call, these binaries will die with SIGSYS, Bad
system call
, because the old kernel does not have
that system call. I have seen other issues when I tried
building lang/perl5.8
.
Before you run stage_1.sh
make sure
you have completed the usual tasks in preparation for
make installworld installkernel
, like:
configured your kernel config file
successfully completed make buildworld
successfully completed make buildkernel
KERNCONF=
whatever
When you run stage_1.sh
for the first
time, and the config files copied from your running system to the
new system are not up-to-date with respect to what is under
/usr/src
, mergemaster
will
ask you how to proceed. I recommend merging the changes. If you get
tired of going through the dialogues you can simply update the files
on your running system once (Only if this is an
option. You probably do not want to do this if one of your systems
runs -STABLE
and the other
-CURRENT
. The changes may be incompatible).
Subsequent mergemaster
invocations will detect
that the RCS version IDs match those under
/usr/src
and skip the file.
The stage_1.sh
script will stop at the
first command that fails (returns a non-zero exit status) due to
set -e
, so you cannot overlook errors. It will
also stop if you use an unset environment variable, probably due
to a typo. You should correct any errors in your version of
stage_1.conf.default
before you go on.
In stage_1.sh
we invoke
mergemaster
. Even if none of the files requires a
merge, it will display and ask at the end
no
Please answer no
or just hit
Enter. The reason is that mergemaster
will have left a few zero sized files below
/var/tmp/temproot.stage1
which will be copied to the
new system later (unless already there).
After that mergemaster
will list the files it
installed and ask if the new login.conf
should be
generated:
The answer does not matter since stage_1.sh
will
run cap_mkdb(1) for you in any case.
Here is the author's stage_1.conf.default
,
which you need to modify substantially. The comments give you
enough information what to change.
Download stage_1.conf.default
.
Running this script installs a system that when booted provides:
Inherited users and groups.
Firewalled Internet connectivity over Ethernet.
Correct time zone and NTP.
Some more minor configuration, like
/etc/ttys
and
inetd
.
Other areas are prepared for configuration, but will not work until stage two is completed. For example we have copied files to configure printing and X11. Printing however is likely to need applications not found in the base system, like PostScript® utilities. X11 will not run before we have compiled the server, libraries and programs.
This, and other documents, can be downloaded from http://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>.