There are four categories of trouble that can occur when building a custom kernel:
configfails, it will print the line number that is incorrect. As an example, for the following message, make sure that line 17 is typed correctly by comparing it to
config: line 17: syntax error
makefails, it is usually due to an error in the kernel configuration file which is not severe enough for
configto catch. Review the configuration, and if the problem is not apparent, send an email to the FreeBSD general questions mailing list which contains the kernel configuration file.
- The kernel does not boot
If the new kernel does not boot or fails to recognize devices, do not panic! Fortunately, FreeBSD has an excellent mechanism for recovering from incompatible kernels. Simply choose the kernel to boot from at the FreeBSD boot loader. This can be accessed when the system boot menu appears by selecting the “Escape to a loader prompt” option. At the prompt, type
boot, or the name of any other kernel that is known to boot properly.
After booting with a good kernel, check over the configuration file and try to build it again. One helpful resource is
/var/log/messageswhich records the kernel messages from every successful boot. Also, dmesg(8) will print the kernel messages from the current boot.
When troubleshooting a kernel, make sure to keep a copy of
GENERIC, or some other kernel that is known to work, as a different name that will not get erased on the next build. This is important because every time a new kernel is installed,
kernel.oldis overwritten with the last installed kernel, which may or may not be bootable. As soon as possible, move the working kernel by renaming the directory containing the good kernel:
- The kernel works, but ps(1) does not
If the kernel version differs from the one that the system utilities have been built with, for example, a kernel built from -CURRENT sources is installed on a -RELEASE system, many system status commands like ps(1) and vmstat(8) will not work. To fix this, recompile and install a world built with the same version of the source tree as the kernel. It is never a good idea to use a different version of the kernel than the rest of the operating system.