Instructions for openHAB on FreeNAS?

It seems like several people here on the forum managed to install openHAB in a FreeNAS jail. Does somebody have any instructions on how to do this? Or even just some pointers on how to start out? Thanks.
Documenting my progress

  • Create a jail with the name ‘openHAB’ from within the webGUI

  • Install openjdk8 and git on FreeBSD:

pkg install openjdk8 git
  • Install maven via ports (otherwise it’s going to download jdk7 for some reason)
cd /usr/ports/devel/maven33
make install clean
  • Create a local clone of the openHAB repository by running
git clone
  • go into the new ‘openhab’ directory and install (this will take a few minutes - it took 24’ for me) openHAB
cd openhab
mvn clean install
  • Create a local clone (is that right? of the nrjavaserial repository by running (and I’m not quite sure from which directory this should be done - from the maven33 one or openhab one - but I am trying the former)
cd ..
git clone
  • install gradle - again as port
cd /usr/ports/devel/gradle
make install clean
cd usr/ports/devel/maven3/nrjavaserial
patch -p0 -l -i freebsd.patch
  • When I run the patch, it asks me the following:
root@openHAB:/usr/ports/devel/maven3/nrjavaserial # patch -p0 -l -i freebsd.patch
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
|Index: nrjavaserial/Makefile
|--- nrjavaserial/Makefile      (revision 185)
|+++ nrjavaserial/Makefile      (working copy)
File to patch:

Does anybody have any idea on what to enter here? I tried Makefile, which it accepts; but it then asks me for a pom.xml, which is not in that directory…

Somehelp please :smiley:

I am just starting in FreeNAS 11.2 and especially an iocage jail since this is the future supported format on FreeNAS.

I found a very detailed guide for this for… HomeAssistant.

The best thing is he also shows how to install seperate iocage jails for Mosquitto and TasmoAdmin. I think that this is a great way for systems independence. Seperate jails for every service. And seperate data volumes mounting for everything. Mosquitto, Node-Red, Influx DB, Grafana etc…

I think a similar guide is essential for OH. As i said i am just staring the process, don’t know where it’s going to lead

This is going very well… I have seperate jails for every service and OH, i made 3 mount points for OH on a seperate FreeNAS Dataset and these mount points are SMB shares, just like Openhabian installations.
I am so happy to leave the Raspi and SD cards… Now i am on RAID security, i have snapshots ability for the OH data and jail.

Maybe the part of moving the OH data on a seperate dataset is not necessary, thoughts welcome…

I am making small steps on my free time on this, but it seems pretty easy and strait forward if you are a bit familiar.
The easiest part was the OH installation on a jail. There is a maintained FreeBSD port currently with OH2.4 perfectly installed. On a service owned by openhab:openhab user.

I also started with migrating my setup to a freenas iocage. I got stuck because is seems openhab on freenas cannot access the serial ports on my system. Do you also have this issue?

I am only using this as a network server. nothing physical is going to be pluged or wired, no USB either.
So i can’t help you with that.

Everything i need to feed to the system, i do it with ESP8266 nodes. For example, i am using Modbus. I didn’t use a USB-RS485 converter. I used a Tasmota-ESP8266 with TTL-RS485 converter.

I have moved my OH instance to OH.
You should create new jail and run:
pkg install openhab2
and add to /etc/rc.conf inside jail:

I have Modbus via RS485, it resolved with custom TCP2RTU gateway. (

Did anyone try to get the UUID and pass for the cloud service?

I have installed openhab2 in a jail and thought it would be nice to do a quick summerize:
Nothing realy new. But I had to visit al lot of websites to gather all the correct information.

Like mentioned before:

  1. Create jail.
    From within the jail
  2. pkg update
  3. pkg install openhab2
  4. pkg install openhab2-addons
  5. edit rc.conf. nano -w /etc/rc.conf
  6. add the lines:
    You should be able to open the website of openHab(default http://ip-adres:8080).

To add an usb stick en show up in the jail (in my case the Aetoec Z-stick).
7. Create a script in the Freenas host (on the location of your choosing).


# Create custom devfs_ruleset NUMBER


/sbin/devfs rule -s ${NUMBER} add include 1
/sbin/devfs rule -s ${NUMBER} add include 2
/sbin/devfs rule -s ${NUMBER} add include 3
/sbin/devfs rule -s ${NUMBER} add path zfs unhide
/sbin/devfs rule -s ${NUMBER} add path 'bpf*' unhide
/sbin/devfs rule -s ${NUMBER} add path 'cua*' unhide

  1. chmod +x

  2. Add the script as a startup script in the FreeNas Gui.

  3. Add the created alternative devfs ruleset to your openHAB jail (ruleset 99 created in step 7).
    screenshot 2 next reply

  4. Restart your server.

  5. From within your openHAB jail add the ‘openhab’ service account to the ‘dialer’ group. To be able to acces the z-wave usb stick.
    screenshot 3 next reply

  6. Go to the openHAB website and install the ‘Z-Wave binding’.

  7. Go to the ‘Things’ tab and add the usb z-stick.
    Serial port should be configured something like /dev/cuaU0



screenshot 3

just tried to update my Freenas iocage jail.

first i upgraded the jail from 11.2-RELEASE to 11.3-RELEASE. have done this to 6 more jails, everything went smooth. I have done that because 11.2 now is EOL and some updates are sending notifications…

after this was done i went for the pkg upgrades.

Installed packages to be UPGRADED:
        xorgproto: 2019.1 -> 2019.2
        readline: 8.0.0 -> 8.0.1
        python36: 3.6.9 -> 3.6.9_3
        python27: 2.7.16_1 -> 2.7.17_1
        py36-setuptools: 41.2.0 -> 41.4.0_1
        py27-setuptools: 41.2.0 -> 41.4.0_1
        openjdk8: ->
        openhab2: 2.4.0 -> 2.5.0
        npm: 6.11.3 -> 6.12.1
        node: 12.10.0 -> 13.3.0
        libxml2: 2.9.9 -> 2.9.10
        libuv: 1.32.0 -> 1.34.0
        libnghttp2: 1.39.2 -> 1.40.0
        libidn2: 2.2.0 -> 2.3.0_1
        libX11: 1.6.8,1 -> 1.6.9,1
        javavmwrapper: 2.7.3 -> 2.7.4
        icu: 64.2,1 -> 65.1,1
        giflib: 5.1.9 -> 5.2.1
        ca_root_nss: 3.46.1 -> 3.49

final thing needed, noted on

Notes from UPDATING
These upgrade notes are taken from /usr/ports/UPDATING
Affects: users of misc/openhab2
  If you upgrade from a pevious version, make a backup of
  read about the breaking changes in the release notes at
  and run
  which takes care about changes for:
        - Textual Configuration
        - Next Generation Rule Engine

i run the script

and i think i am done. restart the jail and…
NOTHING. nothing works.

i have to search what is wrong…

be carefull and always take a snapshot before proceeding!

1 Like

ok, seems clearing the cache is a MUST

empty these folders inside the jail

maybe a nice addon to the free-bsd update script?

be aware of

Could not process config file 'runtime.cfg': /usr/local/etc/openhab2/services/runtime.cfg (Permission denied)
Could not process config file 'classicui.cfg': /usr/local/etc/openhab2/services/classicui.cfg (Permission denied)
Could not process config file 'basicui.cfg': /usr/local/etc/openhab2/services/basicui.cfg (Permission denied)

the upgrade script replaces these and root user takes ownership. give it back to openhab user.

1 Like

I have upgraded from 2.4.0 to 2.5.0 with success today.
Attempt 1: upgrade jail to 11.3-STABLE, upgrade all as mentoned above with command pkg update -f && pkg upgrade. All looks ok but openhhab didn’t start with very strange exception (no key generator or no algorithm during establish https connection).I spent 10-15 minutes on investigation exception but without success. Also i got no java on service openhab2 stop but java -version wors ok. So, i just restore my previous state from snapshot ant try again.
Attempt 2:

  1. Backup config. I didn’t find openhab-cli on FreeBSD, so i prepare script
    setenv OPENHAB_HOME “/usr/local/libexec/openhab2”
    setenv OPENHAB_CONF “/usr/local/etc/openhab2”
    setenv OPENHAB_RUNTIME “/usr/local/libexec/openhab2/runtime”
    setenv OPENHAB_USERDATA “/var/db/openhab2/userdata”
    setenv OPENHAB_LOGDIR “/var/log/openhab2”
    run this script and /usr/local/libexec/openhab2/runtime/bin/backup to backup current config
  2. upgrade all exept java and openhab:
    pkg update -f
    pkg lock openjdk8
    pkg lock openhab2
    pkg upgrade
  3. Backup jail here to save time if somethig went wrong
  4. pkg unlock openjdk8 and run pkg upgrade. Upgrade java, restart and check that all works ok on new java version.
  5. pkg unlock openhab2
  6. pkg upgrade
  7. run /usr/local/libexec/openhab2/runtime/bin/update.freebsd
  8. service openhab2 start

all work ok after this flow. I don’t know why. I guess - i stopped OH before step 6. In first attempt i did upgrade without stop OH.

I didn’t have issues with permission. But my jail contains grafana, i had issues with permissions for grafana.

i typically stop the service prior to its upgrade. also, i have one jail for each service. ie, grafana, mqtt, tasmoadmin, influx-db, node-red evething in its own jail. thats the purpose of jails, right ?

Can you please explain this for an absolute beginner? I missed my “openhab2-conf” directory, where i can put my rules etc. to work with Visual Studio Code.

These steps i tried by myself:

By a little odyssey i located the directory in


and made a Mount-Point

Source: /mnt/MYPOOL/openHAB

Destination: „/mnt/MYPOOL/iocage/jails/openHAB/root/usr/local/etc/openhab2“

This didn’t work because of folders and files so i deleted everthing is this directory via ssh, made a SMB-Share to „/mnt/MYPOOL/openHAB“ and putted the folders „html, icons, items“ etc. in it.

Well, i’m a totally beginner and hope, that you or someone else could help me with my problem, because i love my openhab but i also want to minimize my hardware and hope, that one day it all will run on my FreeNAS resp. TrueNAS.

ok i will drop here my notes on FreeBSD directories the package uses.

# openhab2_user           openhab (UID 235)
# openhab2_group          openhab (GID 235)
# openhab2_home_dir       /usr/local/libexec/openhab2          (/usr/share/openhab2)
#                         /usr/local/libexec/openhab2/addons   (/usr/share/openhab2/addons)
# openhab2_conf_dir       /usr/local/etc/openhab2              (/etc/openhab2)
# openhab2_runtime_dir    /usr/local/libexec/openhab2/runtime      
# openhab2_userdata_dir   /var/db/openhab2/userdata
# openhab2_backup_dir     /var/db/openhab2/backups                   
# openhab2_log_dir        /var/log/openhab2

These are the directories inside the jail.

Now for the dataset. We need to be sure of the UserID (UID) kai GroupID of the jail’s openhab user and use the same on the FreeNAS user.
BY DEFAULT the ports version creates user openhab with UID 235 and GID 235 inside the jail.

  1. So make a user group on FreeNAS main menu. Name of the group will be openhab AND SET MANUALLY THE GID TO BE 235. Next step is to create a user with name openhab and now set the UID to be 235. (Do not use UID or GID 1000 as FreeNAS suggests)

  2. Make a new FreeNAS dataset. Give correct permission to the FreeNAS openhab user.

  3. Make a SMB - Windows share for the dataset. Give correct permission to the FreeNAS openhab user.

  4. Connect to your new share from windows, just to test its ok. It’s empty. Make these new directories
    These will be the mount points for the directories you would want to edit config files and read the logs.
    These are the same as Openhabian installations and their SMB ready to use configuration.

WE MUST CONFIGURE 3 MOUNT POINTS. Not one for the whole scheme.

  1. My method is to stop the OH service or even better shut down the jail. Then just to be sure, i go and rename the 3 directories on the jail, in their respective paths, to “clear” the way for the mount point later.
    What i mean is : go to usr/local/etc/openhab2 and rename it to openhab2-not-used
    If you FTP through FreeNAS root account you can find it as
    I see you already got that.
    I repeat the 3 directories inside the OH jail

  2. To create the mount points, jail must be stopped. Create these 3 mount points
    /mnt/MYDATAPOOL/MYOHSHARE/OPENHAB_LOGDIR -> /mnt/MYPOOL/iocage/jails/openhab/root/var/log/openhab2
    /mnt/MYDATAPOOL/MYOHSHARE/OPENHAB_CONF -> /mnt/MYPOOL/iocage/jails/openhab/root/usr/local/etc/openhab2
    /mnt/MYDATAPOOL/MYOHSHARE/OPENHAB_USERDATA -> /mnt/MYPOOL/iocage/jails/openhab/root/var/db/openhab2/userdata

  3. Start the OH jail. You should see now the directories inside the jail with user openhab:openhab and permissions 755

  4. just to be on the safe side, do these inside the jail and check previous step.

# chown -R openhab:openhab /usr/local/etc/openhab2
# chown -R openhab:openhab /var/log/openhab2
# chown -R openhab:openhab /var/db/openhab2/userdata
# chown -R openhab:openhab /var/run/openhab2
# chmod -R 755 /usr/local/etc/openhab2
# chmod -R 755 /var/log/openhab2
# chmod -R 755 /var/db/openhab2/userdata

You should be able to see the directories on your Windows share and have write permission


Thank you very much for your detailed explanation! I’ll to my very best to follow your points step by step!

ευχαριστώ· :slight_smile: (i mean “efcharisto”, hope the internet is correct with the spelling :smiley:

Let us know if this worked for you. Greek was 100% :slight_smile:

1 Like

Of course, I’ll do. But I’m really busy at the moment. My first try went wrong. The SMB-Part works well and copied the things from the “not-used” directory to the new one. But after it, the openhab doesn’t work. I think I put some permissions wrong (absolute beginner). At Sunday, I tried to install openhab again, but it doesn’t work.
I think your instructions are really good. I’ll give my best and keep you up to date :slight_smile: