Kernel Development and Testing

I'm just starting kernel development ( custom kernels, drivers, patching and etc... ) and i'd like to find a good tutorial of how to setup and environment for FreeBSD Kernel Development. For instance, executing custom code on a live kernel as well as debugging. Will I actually need two machines? Can I use two VMs or better yet, will a jail or two be better?
Ultimately, my goal is to able to build a custom kernel and change some code
 
Ok thanks.
Now what if I want to execute my changes to the new kernel.
What is the safest way to accomplish that without causes damages to my live system?
 
Maybe the original question of the OP is answered so easily, once you have gathered some knowledge of FreeBSD (ZFS, sysutils/beadm). Nevertheless I shout "me too!" and would like to know if there is a commonly accepted good practice of how to do that. My current solution:
  • I set up ZFS datasets pool/src/{12.1-REL,12-STABLE,13-CUR}. Move /usr/src/* into /src/12.1-REL, symlink /usr/src to point to /src/12.1-REL, and fill the datasets pool/ROOT/{12-STABLE,13-CUR} as the DESTDIR of make install-{kernel,world}. In these boot environments, the symlink /usr/src needs to be adjusted.
  • (the STABLE and CURRENT source trees are filled and updated with svn(1))
  • For own development & patches:
    foreach tree (12.1-REL 12-STABLE 13-CUR)
    foreach? mount -t unionfs -o noatime -o below /src/$tree ~/Projects/FreeBSD/src/$tree
    foreach? end

    and in /etc/fstab (EDIT: added late mount option):
    Code:
    /src/13-CUR /home/paul/Projects/FreeBSD/src/13-CUR unionfs rw,late,below,noatime 0 0
    /src/12-STABLE /home/paul/Projects/FreeBSD/src/12-STABLE unionfs rw,late,below,noatime 0 0
    /src/12.1-REL /home/paul/Projects/FreeBSD/src/12.1-REL unionfs rw,late,below,noatime 0 0
  • This way I can switch between my RELEASE (used with pkg-software) and the two STABLE & CURRENT images with beadm(8), to test on "bare metal"
  • Should I decide I want some special options for ports or dive into helping the KDE on FreeBSD team, I'll clone the STABLE & CURRENT images.
Comments are welcome, the are many much more experienced people around here.
 
Giving this some thought, you might use Buildbot to regularly build kernel/world. You can set it up for various architectures or kernel confs.
Found this buildbot in the packages, never heard of it. Since it's python-based and unfortunately Python has a long history of security issues: is it safe to use? Can this be used on top of pouriere or synth or is it an alternative only for kernel & world? It has a package grid-view. Does that mean I can set up a grid of build hosts a là distcc? Personally, I have much more sympathy for Python than other script languages e.g. Java, for it's clean design.
 
  • Like
Reactions: a6h
Found this buildbot in the packages, never heard of it. Since it's pathon-based and unfortunately Python has a long history of security issues: is it safe to use? Can this be used on top of pouriere or synth or is it an alternative only for kernel & world? It has a package grid-view. Does that mean I can set up a grid of build hosts a là distcc? Personally, I have much more sympathy for Python than other script languages e.g. Java, for it's clean design.
Yes to all. It is not an alternative. You can reuse as you desire.
 
Nothing special is needed to build and boot several FreeBSD kernels. I have two custom kernels and default FreeBSD kernel that I can boot interchangeably.
FreeBSD has a nice feature that backs up last (working) kernel, so in the case that custom kernel fails to boot, it is possible to boot generic.
To install more than one kernel just use
KERNCONF=TEST to build
and
KERNCONF=TEST KODIR=/boot/kernel.test to install.
then edit lader.conf and add default kernel to boot.
However during boot process you can select whichever kernel you want as long as you know the name.
 
Back
Top