Update, build and install world and kernel

The canonical way to build and install

by ross at 08:10:57 on April 27, 2017

Working with mergemaster

Mergemaster is a tool that allow updating of configuration files. It will compare installed /etc files to the new files in /usr/src.

When a file should be changed mergemaster will display the difference using diff(1) format.

Now you have the options: install new file (replacing the current one), delete new file (from temporary location, /etc and /usr/src won't be changed) or merge the current and new file.

Select "install" for files you haven't modified (like in /etc/rc.d/*) and merge the files you altered.

Choosing to merge the files will run sdiff(1) utility which will split the screen in two parts: left one is line(s) from current file and right one is line(s) from new file.

Now you just press 'l' (el, left) to keep the old line and 'r' (right) to replace the line with the new content.

This might sound complicated but it's realy not. You usually press 'r' for new FreeBSD cvs id line and for new lines (left side of the screen is empty — the lines are added). And press 'l' for lines you have changed and want to keep.

Upgrade the system

Build world and kernel in multiuser mode:

# cd /usr/obj
# chflags -R noschg *
# rm -rf *
# mergemaster -p
# cd /usr/src
# make -j4 buildworld
# make -j4 buildkernel KERNCONF=COFFIN
# make installkernel KERNCONF=COFFIN

Note the -j4 flag: it is the number of parallel jobs. Using it is not so canonical but greatly speeds up the process. Make it something reasonable, i.g. number of cores multiplied by 2 but between 4 and 10. Never use -j flag to install targets, but only for building.

Optionally, if this is the first installation of a kernel you can backup the original one:

# mv /boot/kernel.old /boot/kernel.GENERIC

Reboot into single user mode and then:

If you boot from zfs (and the pool name is "system"):
# zfs mount -a
# zfs set readonly=off system
# fsck -p
# mount -a -t ufs
# swapon -a
# adjkerntz -i
# cd /usr/src
# make installworld
# mergemaster

Not so canonical but very helpful: run mergemaster -iF instead in the last step. This means "If the files differ only by VCS Id ($FreeBSD) install the new file and install files that do not exist in the current system automatically".


# make delete-old
# make delete-old-libs

If you don't want to be asked if you want to delete each file you can pass option BATCH_DELETE_OLD_FILES=YES:

# make BATCH_DELETE_OLD_FILES=YES delete-old delete-old-libs