Build kernel

If you want to build a custom kernel yourself, you need to install the source code firstly (you can take post as a reference). Then enter the configuration directory of your machine:

  1. # cd /usr/src/sys/`uname -m`/conf

Copy a new kernel configuration file:

  1. # cp GENERIC NAN_FIRST_BUILD

You can modify the new configuration file (NAN_FIRST_BUILD) according to your needs.

Build the kernel:

  1. # cd /usr/src
  2. # make buildkernel KERNCONF="NAN_FIRST_BUILD"

Once it is finished, install the fresh kernel binary and reboot:

  1. # make installkernel KERNCONF="NAN_FIRST_BUILD"
  2. # reboot

Check the kernel version, you will find now the OS is harnessing your newly built kernel now:

  1. # uname -a
  2. FreeBSD FreeBSD 10.3-RELEASE-p5 FreeBSD 10.3-RELEASE-p5 #0: Tue Jul 19 17:52:57 CST 2016 root@FreeBSD:/usr/obj/usr/src/sys/NAN_FIRST_BUILD amd64

Reference:
How to build a custom kernel in FreeBSD.