© 2013 Warren Block

Last updated 2013-09-09

Available in HTML or PDF. Links to all my articles here. Created with AsciiDoc.

Building FreeBSD world and kernel: the concise version.

Introduction

Building the world and kernel on FreeBSD need not be a big deal. The Handbook has the long, detailed procedure. Most of the time, that procedure can be greatly reduced. Here we’ll use a shorter, simpler, faster version. If there are problems, try the Handbook procedure, or check /usr/src/UPDATING for instructions.

The Really Short Version

# rm -rf /usr/obj       1
# cd /usr/src
# make buildworld       2
# make kernel           3
# make installworld     4
# mergemaster -Ui       5
# shutdown -r now
# cd /usr/src
# make check-old        6
1 Deleting the old object directory speeds up the build. If /usr/obj has special permissions or flags like nodump, deleting /usr/obj/usr is usually enough and preserves the parent directory. If the system has enough RAM, a tmpfs(5) filesystem can be used in /etc/fstab:
# Device        Mountpoint      FStype  Options         Dump    Pass#
tmpfs           /usr/obj        tmpfs   rw,mode=01777   0       0
2 Using the -j option can increase speed by running multiple jobs. How many jobs to use depends on the processor; number of cores plus one is a start. Test other values, because hardware varies. The devel/ccache port can also increase speed if you update regularly.
3 The kernel target builds and installs the new kernel. If you have a custom kernel, set the name in the KERNCONF variable (make kernel KERNCONF=MYKERNEL). The official Handbook procedure recommends a reboot into single user mode after installing the new kernel, but it is not required.
4 Do not use -j with installworld.
5 -Ui speeds mergemaster usage. Set IGNORE_FILES= in /etc/mergemaster.rc to skip files that don’t need to be merged. See mergemaster(8).
6 If old files are found, use the delete-old and delete-old-libs targets to remove them. Programs that are still using old libraries will be broken until they have been recompiled.