Register for the iXsystems Community to get an ad-free experience and exclusive discounts in our eBay Store.

The semi-official "adding packages to the FreeNAS image" devguide

Not open for further replies.


This is an advanced guide. If you aren't willing to spend the time figuring out how this works, wait until the plugins code is available and there's a properly documented API / procedure on how to accomplish this!


This document assumes:

1. That you're running a version of FreeNAS pre-8.2.0 .
2. That you're not scared of make, shell scripts, Makefiles, and reading logs.
3. You are familiar with FreeBSD and FreeBSD ports.
4. You're running FreeBSD when you're doing this development.
5. You've pulled the entire FreeNAS workspace at least once.

1. cd FreeBSD/ports .
2. cd to your port directory; search through for the port if you don't know the exact path.
3. Run the following command with all your desired options (replace $OPTIONS with 'WITHOUT_X11=y', etc) on the directory:

make describe $OPTIONS | cut -d'|' -f 12 | sed -e 's,/usr/ports/,,g' | tr ' ' '\n' | sed -E -e 's/^/add_port /g'

4. Edit freenas-common to add the lines printed out with the above command and the options you specified.
5. Run the build once to get a fat image and build the packages.
6. Run the build again to produce a thin image and sanity check the dependencies; the second pass will fail if you miss dependencies; you'll need to adjust freenas-common after adding the missing dependencies and try again. Repeat steps 4., 5., and 6. until the build passes.

Stripped down example of step 3. with nagios:

$ cd /usr/ports
$ cd net-mgmt/nagios
$ make describe WITHOUT_EMBEDDED_PERL=y | cut -d'|' -f 12 | sed -e 's,/usr/ports/,,g' | tr ' ' '\n' | sed -E -e 's/^/add_port /g'
add_port converters/libiconv
add_port devel/libltdl
add_port graphics/gd
add_port lang/php5
add_port net-mgmt/nagios-plugins

1. Add directions on how to debug trivial scenarios.
2. Make a more complete example


Dedicated Sage
Jul 1, 2011
Very nice post, good to have an official explanation! It will definitely help. I've figured out quite a bit and was going to post some when I had more time.

A couple of things to mention.

For some reason when building and it gets to the ports section, if the build bombs out AFTER the 'dbus' ports (like another port), if you try to rebuild with "-n", it will keep bombing out on dbus unless you cd to _.w/usr/ports/packages/All and rm *dbus*. For some reason the build script doesn't recognize the port has been built.

There are a bunch of build options in the FreeBSD/src/tools/tools/nanobsd/ script that can be used from, it might be helpful to copy those into the comments of for reference.

I've divided the script into the part that retrieves sources and the part that does the build. This give you a chance to tweak stuff before the build begins, but also lets you use those options I mentioned a little more effectively.

The "-n" option tells the build script to continue where it left off without cleaning/deleting all of the stuff (in obj.amd64 directory) it already built and can save hours if you made a minor mistake and just want to continue.
Not open for further replies.