Setting up OctoPrint on FreeNAS 11.2 server inside iocage Jails


I have a FreeNAS server setup wich I use to run a lot of services and would like to use it to run my OctoPrint instances to save resources and reallocate my Linux server for something else.

Since I didn’t find any documentation regarding setting up and running OctoPrint on FreeBSD (much less FreeNAS), I thought it was a good idea to post a guide describing how I did it and save some time for anyone else trying to accomplish the same. I plan to update and correct this guide from time to time, i’m open to suggestions as this is my first guide.

I won’t cover how to install FreeNAS or setup iocage as it is already well covered in theFreeNAS User Guide.

Creating a Jail for OctoPrint

Open your FreeNAS server dashboard on your browser, select Jails in the left-side drop-down list:

The Jails menu will open, now select add in order to create a new Jail:

Select advanced Jail Creation:

Give the Jail a recognizable name, select 11.2 for Release, select your NIC in IPv4 Interface, give it an IP address(we’ll use it to access the OctoPrint interface later) and an according Netmask. Mark Auto-start then click NEXT:

Now in Jail properties, change devfs_ruleset to 3, this will allow the Jail to access the /dev folder and consequently talk to USB devices , that wouldn’t be possible if you left it as default (ruleset 4), and the Jail wouldn’t be able to talk to your 3D Printer.

Mark mount.devfs, allow.mount and allow.mount.devfs

You don’t need to mess with anything else here, press SAVE, we’re done setting up the Jail.

Installing necessary packages

You need to install python, pip and other packages for OctoPrint to run on the Jail, for that we need to start a shell inside the Jail. There’s 2 ways you can go about it:

You can just click the 3 dots and start a Shell from the WebUI:

Or you can SSH into your FreeNAS server (you have to enable and setup SSH beforehand for that) and only then start a Shell inside the Jail using the commands
will list active Jails, useful for seing the Jail ID and name

root@freenas[~]# jls
JID IP Address Hostname Path
1 rslsync /mnt/cmon/iocage/jails/rslsync/root
2 OctoPrint /mnt/cmon/iocage/jails/OctoPrint/root
3 OctoPrint2 /mnt/cmon/iocage/jails/OctoPrint2/root
4 transmission /mnt/cmon/iocage/jails/transmission/root
5 plexmedia /mnt/cmon/iocage/jails/plexmedia/root

iocage console OctoPrint2

iocage is the default Jail manager used in FreeNAS 11.2, use this command with the respective name of your Jail.

root@freenas[~]# iocage console OctoPrint2
Last login: Wed Feb 6 18:13:18 on pts/2
FreeBSD 11.2-STABLE (FreeNAS.amd64) #0 r325575+fc3d65faae6(freenas/11.2-stable): Wed Dec 5 15:08:42 EST 2018

Welcome to FreeBSD!

Release Notes, Errata:
Security Advisories:
FreeBSD Handbook:
Questions List:
FreeBSD Forums:

Documents installed with the system are in the /usr/local/share/doc/freebsd/
directory, or can be installed later with: pkg install en-freebsd-doc
For other languages, replace "en" with a language code like de or fr.

Show the version of FreeBSD installed: freebsd-version ; uname -a
Please include that output and any error messages when posting questions.
Introduction to manual pages: man man
FreeBSD directory layout: man hier

Edit /etc/motd to change this login announcement.
root@OctoPrint2:~ #

Now that you have a shell as root inside the Jail, let’s install pkg, python, pip and everything else

root@OctoPrint2:~ #pkg install pkg

Now we can install the packages we want:

root@OctoPrint2:~ # pkg install nano python python27 py27-virtualenv git bash

now we can create a folder and download OctoPrint:

root@OctoPrint2:~ # mkdir OctoPrint && cd OctoPrint

root@OctoPrint2:~/OctoPrint # virtualenv venv

root@OctoPrint2:~/OctoPrint # source venv/bin/activate.csh

[venv] root@OctoPrint2:~/OctoPrint # pip install pip –upgrade

[venv] root@OctoPrint2:~/OctoPrint # pip install

You should then be able to start the OctoPrint server:

[venv] root@OctoPrint2:~/OctoPrint # venv/bin/octoprint serve –iknowwhatimdoing

OctoPrint should start without issues, press Ctrl + c to close it.

USB Connectivity

Connect your 3D Printer to an USB port on your FreeNAS server and run usbconfig inside the Jail and note wich serial device is your 3D Printer:

[venv] root@OctoPrint2:~/OctoPrint # usbconfig

ugen4.2: <FTDI FT232R USB UART> at usbus4, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (90mA)

ugen2.2: <Generic Mass Storage> at usbus2, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (200mA)

Here we can see that my 3D Printer is connected to usbus4 and is listed as ugen4.2 in FreeNAS.

Creating a Start script for OctoPrint in the Jail

This is what i’ve been currently using to run OctoPrint, i plan on creating an rc.d script to have OctoPrint automatically start with the Jail and be easily restarted through it’s WebUI.

For now i’ll create a simple bash script, only enough to start OctoPrint from it:

[venv] root@OctoPrint2:~ # nano octoprintstart

copy and paste this in the file and press Ctrl + o to save it:


echo "Starting OctoPrint, check port 5000"

nohup /root/OctoPrint/venv/bin/octoprint serve --iknowwhatimdoing

Now simply run the script to start OctoPrint:

[venv] root@OctoPrint2:~ # bash octoprintstart

Starting OctoPrint, check port 5000

appending output to nohup.out

For now, everytime you restart your Jail, you’ll have to SSH in and run the script.