Install source code

Download FreeBSD source code according architecture, version:

  1. fetch ftp://ftp.freebsd.org/pub/`uname -s`/releases/`uname -m`/`uname -r | cut -d'-' -f1,2`/src.txz

Uncompress the source package:

  1. tar -C / -xvzf src.txz

Make sure the src is included in Components line in /etc/freebsd-update.conf, so when using freebsd-update to update system, also the source code is refreshed.

  1. # cat /etc/freebsd-update.conf
  2. ......
  3. # Components of the base system which should be kept updated.
  4. Components src world kernel
  5. ......

References:
A question about downloading FreeBSD kernel code;
Install FreeBSD kernel source after installed freebsd.