KERNCONF is relevant. You can make the kernel small. Use
dmesg
with
grep
a lot to find what your kernel loads.
kldstat
helps too. Use man pages to find relevant entries to those modules which are loaded. The more a KERNCONF is trimmed, the more accurate you have to be, or functionality can break so that it won't boot.
It helps to keep backups kernels, by using
/boot/loader.conf through the "kernel" and "kernels" arguments.
kernel loads the default.
kernels has a list of working kernels, so I can pause on bootup and select a known working kernel from that list. I'll have a solid backup that doesn't get replaced every time a kernel install replaces
kernel.old. This is convenient so you won't have to rely on a bootcd for every time a kernel install doesn't work.
To start with: I remove all of the sound drivers, except for the ones I use. Then, I remove the network card drivers I don't use. miibus is needed for lots of network drivers, so I'm careful not to remove it if my card depends on it. Removing usb and harddisk/RAID controllers I don't have.
I'll have two KERNCONF's one which is a trimmed down GENERIC, and another with added customizations, which will also use the trimmed KERNCONF. This way, I'll keep updates to the GENERIC organized with another file for added customizations.
Estimates for a kernel size are based on swapspace and RAM during a build. Not enough of total from these, and a build stops. Also based on the size of
/boot/kernel/.
Other estimates are based on that base takes up space, and the size of a CD, then updating increases that. My root partition is about 800MB, excluding
/usr and
/var, bc those are on their own partitions. Use
df -m
and
du -m
.
I later realized that you said kernel, not base. Don't worry about
src.conf(5) which has to do with base as I previously described about. I found it's better to have the whole base, and to trim the kernel and to use pf to block unneeded services. This is what I wrote about earlier, when thinking about FreeBSD's base, so I'll leave the information:
To try
https://www.minibsd.org/ for a smaller BSD base system.
That, or spending a lot of time hands on. That would be a lot of your own exploring with
src.conf and KERNCONF. There's some information in the forums from those who've played with different
src.conf and KERNCONF options to rebuild base, and have rebuilt base with different options. The Kernel is relevant, because when a needed component is removed from base, that part related to the kernel must be removed too, or the computer won't boot.
In my experience, I lost a lot of functionality in ability to recompile the base, and what worked one time didn't work the same way when components of base were consolidated for the next FreeBSD release. When removing toolchains, each time a recompile was made, more needed components were excluded for 2 more times. The components were there for the compile, but no longer available for the next. On one release, I could replace the base toolchains with one from ports, but for future releases, I could no longer do this, when they kept changing the base or while they were updating Clang/LLVM functionality for each release. I learned this from trial and error.
The easiest thing to remove without breaking functionality were cleartext networking programs from source.