How do I install FreeBSD kernel source code?

Q. I need to configure FreeBSD kernel but not able to find out source code in /usr/src/sys directory. How do I install FreeBSD source code?

A.Your kernel and all related source code is located at /usr/src/sys directory which is also accessible through the /sys path.

If there is not a /usr/src/sys directory on your system, then the kernel source has not been installed. The easiest way to do this is by running sysinstall as root, choosing Configure, then Distributions, then src, then base and sys
# sysinstall

Select Configure

Select Distributions

Select src

Then base and sys > Select ok

Further readings

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 8 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
8 comments… add one
  • SIFE Sep 17, 2009 @ 23:41

    Salamo Alikom
    does any way to get it with cvs ?

  • Cristian Navalici Oct 6, 2009 @ 16:57

    Thanks a lot for the information!
    It was helpful

  • Dask Jan 29, 2010 @ 17:56

    tnks man!
    It really help me!

  • Ben Feb 11, 2010 @ 12:26

    followed these steps, but got:

    Warning: Can’t find the ‘8.0-RELEASE-p2’ distribution on this FTP server.

    I chose many different servers. What now?

  • Ben Feb 11, 2010 @ 12:38

    actually, need to:

    # sysinstall

    then change the release name to 8.0-RELEASE and it works fine after that.

  • sateesh Jun 30, 2012 @ 18:04

    how do I install sources using pkg_add

  • bsd newbie Aug 22, 2012 @ 18:11

    Thanks. It’s very helpful. I have been benefiting from your website. Keep up the good work. :D

  • nixkid Nov 27, 2012 @ 19:51

    Sysinstall is mostly dead. It won’t install the source distribution for you any more. But now you can solve this problem in the Howto forum:

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum