Chapter 7. Kernel Configuration

7.1. I would like to customize my kernel. Is it difficult?
7.2. Why is my kernel so big?
7.3. Why does every kernel I try to build fail to compile, even GENERIC?
7.4. Which scheduler is in use on a running system?
7.5. What is kern.sched.quantum?

7.1.

I would like to customize my kernel. Is it difficult?

Not at all! Check out the kernel config section of the Handbook.

Note:

The new kernel will be installed to the /boot/kernel directory along with its modules, while the old kernel and its modules will be moved to the /boot/kernel.old directory. If a mistake is made in the configuration, simply boot the previous version of the kernel.

7.2.

Why is my kernel so big?

GENERIC kernels shipped with FreeBSD are compiled in debug mode. Kernels built in debug mode contain debug data in separate files that are used for debugging. FreeBSD releases prior to 11.0 store these debug files in the same directory as the kernel itself, /boot/kernel/. In FreeBSD 11.0 and later the debug files are stored in /usr/lib/debug/boot/kernel/. Note that there will be little or no performance loss from running a debug kernel, and it is useful to keep one around in case of a system panic.

When running low on disk space, there are different options to reduce the size of /boot/kernel/ and /usr/lib/debug/.

To not install the symbol files, make sure the following line exists in /etc/src.conf:

WITHOUT_KERNEL_SYMBOLS=yes

For more information see src.conf(5).

If you want to avoid building debug files altogether, make sure that both of the following are true:

  • This line does not exist in the kernel configuration file:

    makeoptions DEBUG=-g
  • Do not run config(8) with -g.

Either of the above settings will cause the kernel to be built in debug mode.

To build and install only the specified modules, list them in /etc/make.conf:

MODULES_OVERRIDE= accf_http ipfw

Replace accf_httpd ipfw with a list of needed modules. Only the listed modules will be built. This reduces the size of the kernel directory and decreases the amount of time needed to build the kernel. For more information, read /usr/share/examples/etc/make.conf.

Unneeded devices can be removed from the kernel to further reduce the size. See Q: 7.1 for more information.

To put any of these options into effect, follow the instructions to build and install the new kernel.

For reference, the FreeBSD 11 amd64 kernel (/boot/kernel/kernel) is approximately 25 MB.

7.3.

Why does every kernel I try to build fail to compile, even GENERIC?

There are a number of possible causes for this problem:

  • The source tree is different from the one used to build the currently running system. When attempting an upgrade, read /usr/src/UPDATING, paying particular attention to the COMMON ITEMS section at the end.

  • The make buildkernel did not complete successfully. The make buildkernel target relies on files generated by the make buildworld target to complete its job correctly.

  • Even when building FreeBSD-STABLE, it is possible that the source tree was fetched at a time when it was either being modified or it was broken. Only releases are guaranteed to be buildable, although FreeBSD-STABLE builds fine the majority of the time. Try re-fetching the source tree and see if the problem goes away. Try using a different mirror in case the previous one is having problems.

7.4.

Which scheduler is in use on a running system?

The name of the scheduler currently being used is directly available as the value of the kern.sched.name sysctl:

% sysctl kern.sched.name
kern.sched.name: ULE

7.5.

What is kern.sched.quantum?

kern.sched.quantum is the maximum number of ticks a process can run without being preempted in the 4BSD scheduler.

All FreeBSD documents are available for download at https://download.freebsd.org/ftp/doc/

Questions that are not answered by the documentation may be sent to <freebsd-questions@FreeBSD.org>.
Send questions about this document to <freebsd-doc@FreeBSD.org>.