Upcoming Maintenance Alert:

The UBNT Community will be upgraded at 5pm MDT on April 25th. During this time the community forums will be set to read-only status.

Learn more

×
Reply
Established Member
Posts: 1,172
Registered: ‎06-18-2010
Kudos: 195
Solutions: 9
Accepted Solution

Raspberry Pi and Unifi

Has this been done yet?
I received a model B raspberry Pi today in the mail, and ran it through some various O/S's and it works great for what i am going to use it for.
even XBMC plays very very solidly on it for a 35 dollar device.
that said i won't need it for a while, and since i hate linux i've decided i have no interest in trying to compile Unifi on it
so im throwing it out there. i can throw the Rp on a public ip and let someone who knows more about linux then me attempt this and see if they can get the build to work.
i have no unifi devices so you would need to setup this up as a l3 test.
it would have a 2gb sd card, and a 8gb usb mem stick if needed
if someone is seriously interested send me a pm and i can provide the infoIcon Razz

Accepted Solutions
Ubiquiti Employee
Posts: 10,503
Registered: ‎02-10-2014
Kudos: 2974
Solutions: 843
Contributions: 17

Re: Raspberry Pi and Unifi

If you're using Raspbian Jessie, it's super simple on the RPi2:

 

apt-get update; apt-get upgrade
apt-get install mongodb
wget http://www.ubnt.com/downloads/unifi/4.6.0/unifi_sysvinit_all.deb
dpkg -i unifi_sysvinit_all.deb

 

We're also investigating the possibility of hosting an image of UniFi for the Raspberry Pi 2 since the hardware is a substantial upgrade from the previous generation.  This doesn't mean that we are doing it, we're investigating the possibility and feasibility of it.  There will be some restrictions of course, due to the still limited hardware.


Many Questions are Answered in the KnowledgeBase
Don't forget to kudo helpful posts and mark threads as solved
Forum Rules

View solution in original post


All Replies
Established Member
Posts: 2,272
Registered: ‎09-11-2009
Kudos: 695
Solutions: 51

Re: Raspberry Pi and Unifi

Has this been done yet?

I received a model B raspberry Pi today in the mail, and ran it through some various O/S's and it works great for what i am going to use it for.

even XBMC plays very very solidly on it for a 35 dollar device.

that said i won't need it for a while, and since i hate linux i've decided i have no interest in trying to compile Unifi on it

so im throwing it out there. i can throw the Rp on a public ip and let someone who knows more about linux then me attempt this and see if they can get the build to work.

i have no unifi devices so you would need to setup this up as a l3 test.

it would have a 2gb sd card, and a 8gb usb mem stick if needed

if someone is seriously interested send me a pm and i can provide the infoIcon Razz


Sounds like a good idea, we will be testing this soon as well...

Also go with the 8gb stick, we filled some 2gig sticks up in a week or two with tons of stupid logs and it crashes the server.
Established Member
Posts: 1,172
Registered: ‎06-18-2010
Kudos: 195
Solutions: 9

Re: Raspberry Pi and Unifi

lol tell it to the guy compiling the software
lol i only got a 2gb sd card which has to be used to boot, then they can use the 8gb usb drive for whatever...
let me remind people i hate linux....
Regular Member
Posts: 400
Registered: ‎03-15-2012
Kudos: 105
Solutions: 6

Re: Raspberry Pi and Unifi

The RPi doesn't have enough wired ram to run UniFi without enabling a decent amount of swap; however you should be able to get it to work but I would expect it to be a little slow!

I have several UniFi controllers running on PandaBoards based on Ubuntu 12.04. It runs really quite well, although the PandaBoard does have 1GB RAM (vs 256MB on the RPi) and a dual-core OMAP4 CPU. Typically I see the UniFi controller using about 650MB virtual memory and mongod with about 250MB.

You'll also need an 8GB min SD card; also mongodb, won't enable journaling by default on a 32-bit system so you'll have to add --journal to the db.extraargs system property and --smallfiles otherwise the journal files are very large.

Finally, the RPi doesn't have a Real Time Clock, which I think was a huge omission on the part of the designers. Sure, you can use NTP, but it doesn't always work (esp. after a power outage when there's a race between ntpdate and the internet coming back up).
New Member
Posts: 12
Registered: ‎08-04-2012
Kudos: 4

Re: Raspberry Pi and Unifi

Doesn't the UniFi controller need Java? There is no Java runtime for the Pi (yet... I believe there is some work being done).
Also, there is a note in the FAQs on the Raspberry Pi site about the lack of an RTC. Apparently the cost of a clock chip and battery is prohibitive, plus it takes up board real estate.
It should be pretty simple to modify the boot script so that start up is delayed until Internet connectivity is established and the time is set.
Paul
Regular Member
Posts: 400
Registered: ‎03-15-2012
Kudos: 105
Solutions: 6

Re: Raspberry Pi and Unifi

Doesn't the UniFi controller need Java? There is no Java runtime for the Pi (yet... I believe there is some work being done).

Yes, UniFi is Java based. I have been using OpenJDK to run Java on ARM based devices. I personally haven't tried Java on the RPi, but as I would expect, reports indicate that it's a bit slow:
www.raspberrypi.org/phpBB3/viewtopic.php?f=51&t=8498
Also, there is a note in the FAQs on the Raspberry Pi site about the lack of an RTC. Apparently the cost of a clock chip and battery is prohibitive, plus it takes up board real estate.
It should be pretty simple to modify the boot script so that start up is delayed until Internet connectivity is established and the time is set.

As for the boot script setup, you would *think* it would be pretty simple, but I have run into all kinds of issues, last one I saw was that the NTP server didn't resolve via DNS, so ntpdate failed, but the network is otherwise up. Time ended up being set to I guess the last time it had booted? So it it was a week or two out ... not a big deal, but messes up the history for any devices that connect to UniFi while the clock is wrong.
Established Member
Posts: 1,172
Registered: ‎06-18-2010
Kudos: 195
Solutions: 9

Re: Raspberry Pi and Unifi

why not just run the ntp update off rc.local, or just script it with a time delay,
there is a java version for the pi, albiet it is a 700mhz arm. u can sometimes see the slowness when your use to real hardware.
but i will say the debian i am running has been rock solid so far and will work quite well
gonna mess with gpio soon on it
never thought a RTC was big deal, i guess it is, considering my mikrotik doesn't have one either and never found it to be a issue
New Member
Posts: 20
Registered: ‎05-14-2009
Kudos: 4

Re: Raspberry Pi and Unifi

I have the RPi running the UniFi controller software for a small business and it runs okay. I used Arch Linux Arm to the keep the os light. I have MongoDB 2.1.1 compiled and when it's running at most it uses 115mb of RAM. Since you are using SD media I would not use SWAP since it will shorten the life of the card, I have SWAP off turned off and it works fine. The clock could be an issue however if the device has access to the network and a time server the lack of an internal clock as not been a problem for me.
Snowball: I would like to see how well the MongoDB runs on a dual core system. I know the main problem I had with getting mongodb 2.x on the rpi was multithreading issues. If you see this and get a chance PM me about mongodb on dual core arm system.
The only real issue that I have seen is the initial load time. Once the system is running users have not had too much problem accessing via the guest access. I only have 35 uses which is about all that I would want to handle on an ARM based UniFi Controller. If anyone who reads this is interested I have instructions on getting mongdb 2.1.1 on the RPi www.timandpaige.com/technology
New Member
Posts: 12
Registered: ‎11-03-2013
Kudos: 2

Re: Raspberry Pi and Unifi

Anyone have this working stable yet? The Model B has 512 now and can allocate ram from the GPU to give the main more ram.

New Member
Posts: 8
Registered: ‎11-16-2013
Kudos: 51

Re: Raspberry Pi and Unifi

I managed to install the UniFi controller software on a Raspberry Pi and I must say it seems to be running quite well. I wrote a blog post about it.

Ubiquiti Employee
Posts: 7,691
Registered: ‎11-27-2012
Kudos: 2096
Solutions: 490
Contributions: 73

Re: Raspberry Pi and Unifi


P44T wrote:

I managed to install the UniFi controller software on a Raspberry Pi and I must say it seems to be running quite well. I wrote a blog post about it.


Nice !

Established Member
Posts: 1,705
Registered: ‎10-28-2010
Kudos: 1010
Solutions: 23

Re: Raspberry Pi and Unifi

[ Edited ]

How did you find an SD card big enough for mongodb?

Just kidding.  

But everyone is going to want to know how it survives under load

and if a prebuilt image is available.

and if now running it on EdgeRouters is justified.

New Member
Posts: 8
Registered: ‎11-16-2013
Kudos: 51

Re: Raspberry Pi and Unifi

I'm very curious about how it will survive load too, but I'll be deploying it with 'only' three access points soon. We'll see... It's not like the controller is mission critical in my case.

Running it on EdgeRouters would be a different story, because if I remember correctly, these have a MIPS cpu, not ARM. So you would need a Java Runtime Environment for MIPS.

Member
Posts: 171
Registered: ‎03-07-2014
Kudos: 42
Solutions: 4

Re: Raspberry Pi and Unifi

[ Edited ]

I "slaughtered" my test RPi and followed your excellent tutorial - and i now have UniFi running.

I was going to install it on either my Synology DS1511 or a VM on my Mac Mini media center, but if the Pi can handle the load, i would much rather have a dedicated machine for running it.

As for it handling the load, here are my preliminary measurements:

top - 18:43:58 up  2:33,  1 user,  load average: 0,17, 0,18, 0,14
Tasks:  72 total,   1 running,  71 sleeping,   0 stopped,   0 zombie
%Cpu(s):  2,3 us,  2,3 sy,  0,0 ni, 94,2 id,  0,6 wa,  0,0 hi,  0,6 si,  0,0 st
KiB Mem:    448180 total,   424516 used,    23664 free,    41376 buffers
KiB Swap:   102396 total,        0 used,   102396 free,   264352 cached

  PID USER      PR  NI  VIRT  RES  SHR S  %CPU %MEM    TIME+  COMMAND
12120 unifi     20   0  251m  61m 8012 S   0,6 14,1   1:28.59 java
12142 unifi     20   0  117m  34m  20m S   0,6  7,8   0:30.38 mongod

 

I'll be adding a few Unifi AP's during the week, and it'll be interesting to see how well it handles it.

I don't much care about response times for the UI. It'll only be used for guest vouchers / portal (great for Want todays Wifi password ?) and initial setup.

EDIT: I forgot the Memory Split. With memory split = 16mb, it looks like this

top - 19:39:05 up 41 min,  2 users,  load average: 0,29, 0,28, 0,24
Tasks:  76 total,   1 running,  75 sleeping,   0 stopped,   0 zombie
%Cpu(s):  4,0 us,  4,0 sy,  0,0 ni, 92,0 id,  0,0 wa,  0,0 hi,  0,0 si,  0,0 st
KiB Mem:    496948 total,   303608 used,   193340 free,    18752 buffers
KiB Swap:   102396 total,        0 used,   102396 free,   186420 cached

  PID USER      PR  NI  VIRT  RES  SHR S  %CPU %MEM    TIME+  COMMAND
 4018 unifi     20   0  260m  50m 7984 S   1,0 10,5   0:52.73 java
 4039 unifi     20   0  117m  34m  20m S   1,0  7,0   0:06.30 mongod

 

EDIT 2: I wrote a small blog entry on the various changes i made; start up script, logrotate etc.

Using Raspberry Pi as a UniFi Controller

New Member
Posts: 12
Registered: ‎11-03-2013
Kudos: 2

Re: Raspberry Pi and Unifi

I am testing this out on my RPI based on this thread. I am using a Sandisk Xtreme 95MB/sec card and so far it seems to be overkill. My APs are running a higher version so I need to get some newer jar files.

New Member
Posts: 3
Registered: ‎01-30-2014

Re: Raspberry Pi and Unifi

I did something similar, except I based my RPi system on PiBang (basically Raspbian with systemd). Here's my systemd unit file.

Also I've installed openjdk-7-jre-headless (with jamvm) instead of the Oracle JRE.

I guess I have to use symlinks if I want my logs in /var/log/ and other "dynamic" data in /var/ or /srv/ (depending on the distribution)? It would be very useful if I could change these paths using command-line arguments or config file options.

root@PiBang ~ # cat /etc/systemd/system/unifi.service

[Unit]
Description=Ubiquiti Unifi Controller
Wants=network.target
Before=network.target

[Service]
User=unifi
ExecStart=/usr/bin/java -jar /opt/unifi/lib/ace.jar start
ExecStop=/usr/bin/java -jar /opt/unifi/lib/ace.jar stop

[Install]
WantedBy=multi-user.target

Member
Posts: 171
Registered: ‎03-07-2014
Kudos: 42
Solutions: 4

Re: Raspberry Pi and Unifi

For what it's worth, i'm currently running UniFi on my Raspberry Pi, with 2 UniFi AP's connected.

Everything seems to be running smooth:

top - 22:59:59 up 1 day, 11:36,  1 user,  load average: 0,30, 0,23, 0,23
Tasks:  79 total,   1 running,  78 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0,8 us,  3,1 sy,  0,0 ni, 96,2 id,  0,0 wa,  0,0 hi,  0,0 si,  0,0 st
KiB Mem:    496948 total,   457048 used,    39900 free,    81348 buffers
KiB Swap:   102396 total,        0 used,   102396 free,   218292 cached

  PID USER      PR  NI  VIRT  RES  SHR S  %CPU %MEM    TIME+  COMMAND
 4188 unifi     20   0  268m 102m 8008 S   0,8 21,2  83:27.01 java
 4206 unifi     20   0  118m  36m  21m S   0,8  7,5  88:42.75 mongod

 Provided my RPi doesn't screw up my SDCard (as they are prone to do), this looks like a winner.

New Member
Posts: 3
Registered: ‎01-30-2014

Re: Raspberry Pi and Unifi

Nice.

Regarding screwing up SD cards - I already have some systems running (a different service) with the whole system mounted as read-only (and logging to tmpfs).

I'm thinking of doing something similar here. Only a different approach would be necessary for saving configuration (the other service can execute scripts before and after saving configuration so I use that to re-mount the filesystem with the configuration as R/W and R/O as necessary).

Highlighted
Member
Posts: 171
Registered: ‎03-07-2014
Kudos: 42
Solutions: 4

Re: Raspberry Pi and Unifi

[ Edited ]

So far I'm just accepting the risk Man Happy This is for my home network, so not exactly mission critical.

What i have done though, is make a backup of the running system, something like

sudo sh -c "dd if=/dev/mmcblk0 bs=1m | gzip -c > /mnt/backup_unifi_backup.img.gz"

As i see it, there is only one thing i don't want to lose, the mongodb data - the system itself took around 60 minutes to setup, which is acceptable should the SDCard become corrupted, so i think i'll just create a daily backup of the mongodb instance.

EDIT: Come to think of it, i'll just download the UniFi backup configuration whenever i make changes, and keep the above image around. Recovery would then be restore image above (10-12 mins), upload latest configuration to UniFi controller, reboot.

 

New Member
Posts: 8
Registered: ‎11-16-2013
Kudos: 51

Re: Raspberry Pi and Unifi

[ Edited ]

I'm not caring about the SD card too much. To me it's far from mission critical. I'm also downloading a config backup with every change I make, so restoring won't take more than 15 minutes.

I also wrote a new section about running the controller on startup, as I got some requests on this topic. The unifi package from the Debian repository (found here) contained a init script which only needed some slight adjustments. Read it here, if you want to: http://erikvanpaassen.tweakblogs.net/blog/10024/turning-a-raspberry-pi-into-a-unifi-controller-appli...

 

Update (December 30, 2015):

You can find a rewritten, up to date version of my blog here:

http://erikvanpaassen.tweakblogs.net/blog/12480/turning-a-raspberry-pi-into-a-unifi-controller-appli...

Reply