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?

ADVERTISEMENTS

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
sysinstall-1.jpg

Select Configure
sysinstall-2.jpg
Select Distributions
sysinstall-3.jpg
Select src
sysinstall-4.jpg
Then base and sys > Select ok
sysinstall-5.jpg

Further readings

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig 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 jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
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
    configure
    options

    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: http://forums.freebsd.org/showthread.php?t=29172.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.