Kernel Build Steps for pfsense 2.1.5

  • I wasn't certain where to post this, exactly, so if it has to be moved I won't be offended.  The purpose of the post is to cover the steps required to build a custom pfsense kernel, as a form of documentation.  This required many hours of research on my part, since as near as I can tell it is not documented anywhere, so this is to help other people like me who are new to pfsense build scripts.  I wanted to rebuild a pfsense kernel to support new hardware supported by freeBSD and found the instructions to do so sparse.

    I assume you know unix.  This is not how to login to ubuntu, it's a messy, convoluted process, probably made far worse by my own lack of knowledge.

    I've never built pfsense before.  If you are an actual, knowledgeble pfsense dev (or just someone smarter than me) and I say something idiotic, please correct me.  In a couple of cases I made changes that I think were irrelevant dead ends, I did not include them.  If you think I missed something, let me know.

    The old, outdated build instructions can be found here:

    Some more updated instructions can be found here:

    Both of these were of help to me.

    STEP 1

    The first thing to do is get freeBSD 8.3 installed and functional.  This is made more difficult because freeBSD broke their ports tree intentionally for 8.3.  No really, on purpose Thus, after you have installed freeBSD you are still going to need to convince it to build.

    What they changed was mostly that they changed the ':U' suffix to ':tu' and ':L' to ':tl', which is fortunately trivial.  What this means for us is that we can use sed to (mostly) fix this:

    find -print0 /usr/ports -name Makefile| xargs -0 sed -i '' 's/\:tl/\:L/'
    find -print0 /usr/ports -name Makefile| xargs -0 sed -i '' 's/\:tu/\:U/'

    Sometimes a ./configure script will generate a makefile which will be incompatible and you'll have to repair that one as well.  Enter the directory in /usr/ports and re-edit the Makefile if needed, your clue is that you'll get an error like:

    unknown modifier 't'

    Make sure you intall subversion, as svn replaced cvs as the freebsd repository software.  Look at the above link marked newer build instructions.

    STEP 2

    Get access to the tools repository for pfsense.  There is way too much documentation on this already, I sugest the sticky on the pfsense development forum.  I will assume pfsense-tools is in /home/pfsense/tools.

    STEP 3
    Set the version of pfsense that you want to build for.  I was genuinely confused by this as it seems only 2.1 or 2.2 toolchains can be built using RELENG_8_3 or RELENG_10_0.  It seems giving the pfsense version that you want works, however, as: RELENG_2_1_5 or so.  This seems to set it up to use freebsd 8.3 but build for pfsense 2.1.5

    cd /home/pfsense/tools/buiilder_scripts
    ./ RELENG_2_1_5

    STEP 4
    Sync your sources preparing for build:

    svn checkout /usr/src

    STEP 5

    Now, you are ready to build the kernel.

    First, copy files to /usr/pfSensesrc.  This must be redone if the –clean-builder option is run, as that apparently deletes needed files and patching fails.  Also do not run out of as that apparently auto-cleans if you build the iso.

    cp -iprv /usr/src /usr/pfSensesrc/

    to build all kernels:

    ./ --apply-patches --build-kernels

    to build only one:

    ./ --apply-patches --build-kernel $KERNEL

    Select $KERNEL from /home/pfsense/builder_scripts/conf/kernel

    For example, I'm on amd64 building for FreeBSD 8 so I would have:

    to choose from.

    STEP 6
    Your kernel(s) are in /tmp/kernels/kernels

    Do a happy dance.  Or at least stop cursing at your computer.

    I hope that this will save someone some time.  Major thanks to PiBa for giving me a couple clues that got me to figure this out.

Log in to reply