Recompile FreeBSD Kernel
Friday, November 16, 2007
Here’s how I recompiled the kernel. I got this from the FreeBSD Handbook, but I wanted to post for my own notes. If you want more information, please refernence the handbook at FreeBSD.org
1) Before we start, make sure that we install the all the sources. Just go to sysinstall and navigate to Configure > Distributions > src, and choose ALL.
2) The handbook says to either copy the kernel or link it from another location. I chose to link it from the /root directory. Let’s just call the kernel MYKERNEL (ya ya, just like the handbook).
# cd /usr/src/sys/i386/conf
# mkdir /root/kernels
# cp GENERIC /root/kernels/MYKERNEL
# ln -s /root/kernels/MYKERNEL
3) Now we can edit either the kernel or edit any driver source code or modules, like the Areca drivers.
The next step is to compile and install the new kernel, but I wanted to mention this: If all you did was edit a driver, like in my future post, (insert link), and you don’t want to recompile all the modules, then open up /etc/make.conf (or create one) and use MODULES_OVERRIDE. This will only compile the modules or drivers you tell it to. It will definitely make the compile go much faster.
Here’s an example: Say you edited the Areca Driver, and acpi. Your MODULES_OVERRIDE line would look like this:
MODULES_OVERRIDE = acpi arcmsr
One thing to note is that this is all relative to the /usr/src/sys/dev/ directory. So if you wanted to recompile a sound driver and the modules I mentioned above, you would use this:
MODULES_OVERRIDE = acpi arcmsr sound/sound sound/driver/ds1
4) Now we can compile the kernel…
# cd /usr/src
# make buildkernel KERNCONF=MYKERNEL
5) and install it.
# make installkernel KERNCONF=MYKERNEL
And that’s it. Again, please reference the handbook at FreeBSD information.
Done!!
