Roland's homepage

My random knot in the Web

Updating FreeBSD from source

Sometimes I need to update my FreeBSD operating system. I prefer to do that from the source code, so that my customizations in (/etc/src.conf) remain.

At the writing of this article, I’m tracking the 10-STABLE branch. To start this, I removed the contents of /usr/src and checked out the correct branch.

# rm -rf /usr/src/*
# svnlite checkout /usr/src

Before running a build, I update the sources;

# svnlite update /usr/src

Rebuilding the OS and/or kernel can be done for various reasons;

  • Fix vulnerabilities
  • New features
  • Configuration changes

The latter is mainly for when I’ve made changes to /etc/src.conf (see the manual) to indicate which features/programs shouldn’t be built.


The handbook has a very elaborate procedure for this. Mine is somewhat simpler. I’m documenting it here at least partially so that I have the instructions at hand.

Note that all the following has to be done as the root user (as indicated by the #-prompt). Running the build of both the OS and the kernel;

# rm -rf /usr/obj/usr
# cd /usr/src
# make -j4 buildworld
# make -j4 buildkernel

Installing the kernel, reboot and install the new OS;

# make installkernel
# reboot
  • Boot into single user mode
  • Log in with the root password
  • Press <enter> to start the default /bin/sh.
# mount -a
# mergemaster -p
# cd /usr/src
# make installworld
# mergemaster -i -U
# make -DBATCH_DELETE_OLD_FILES delete-old
# make delete-old-libs
# reboot

If the OS boots up normally, the contents of /usr/obj can be deleted;

# chflags -R noschg /usr/obj/usr
# rm -rf /usr/obj/usr
# cd /usr/src
# make cleandir
# make cleandir

For convenience, the permissions of umount are modified to allow regular user to unmount. And the group of shutdown is modified to permit members of the wheel group to call it.

# chmod u+s /sbin/umount
# chown root:wheel /sbin/shutdown

For comments, please send me an e-mail.

Related articles

←  Switching IPython to Python 3 Python bindings for libmagic  →