Friday, January 19, 2018

Unifi Cloud Key not updating firmware?

Was trying to update from 5.22 to 5.29 and it kept returning without updating or saying what happened anywhere I could find. After Googling for a bit I found a few posts suggesting to move of trim the DB along the lines of this
The problem with disk space is usually because the DB is growing too large for the original install location. Since the Cloud Key unit ships with an 8GB SD card which mounts as /data (as you pointed out) I was able to solve this problem by moving the db folder to the SD card and then setting up a symbolic link to the new location. This provides much more storage space for the DB to grow and should free up space to handle future firmware updates. Here are the steps to do this:

## STOP SERVICES
sudo /etc/init.d/unifi stop
sudo /etc/init.d/cloudkey-webui stop


## MOVE DB AND SETUP SYMBOLIC LINK
sudo mv /srv/unifi/data/db /data
sudo ln -s /data/db/ /srv/unifi/data/db

## START SERVICES
sudo /etc/init.d/unifi start
sudo /etc/init.d/cloudkey-webui start

I then also ran the script located here to clean out older data from the DB:
https://help.ubnt.com/hc/en-us/articles/204911424-UniFi-Remove-prune-older-data-and-adjust-mongo-database-size


I am thinking about setting this script as a cron job to run periodically on its own, but I haven't done that yet. So far everything seems stable but your mileage may vary. Be sure to check the log files for any errors.

This got me thinking so I checked the available space:
ssh ubnt@keyIP (password is your admin user password or default ubnt)
df -h
But the only even close to full filesystem was .rofs
Filesystem                     Size  Used Avail Use% Mounted on
aufs-root                      1.1G  319M  735M  31% /
udev                            10M     0   10M   0% /dev
tmpfs                          201M  372K  201M   1% /run
/dev/disk/by-label/userdata    1.1G  319M  735M  31% /mnt/.rwfs
/dev/disk/by-partlabel/rootfs  291M  291M     0 100% /mnt/.rofs
tmpfs                          503M     0  503M   0% /dev/shm
tmpfs                          5.0M     0  5.0M   0% /run/lock
tmpfs                          503M     0  503M   0% /sys/fs/cgroup
tmpfs                          503M   96K  502M   1% /tmp
/dev/mmcblk0p7                 1.5G  1.2G  321M  78% /srv
/dev/mmcblk1p1                 7.2G  1.6G  5.7G  22% /data

So I tried just compacting the DB instead.



Note much of a change but it did the trick

Filesystem                     Size  Used Avail Use% Mounted on
aufs-root                      1.1G  319M  735M  31% /
udev                            10M     0   10M   0% /dev
tmpfs                          201M  372K  201M   1% /run
/dev/disk/by-label/userdata    1.1G  319M  735M  31% /mnt/.rwfs
/dev/disk/by-partlabel/rootfs  291M  291M     0 100% /mnt/.rofs
tmpfs                          503M     0  503M   0% /dev/shm
tmpfs                          5.0M     0  5.0M   0% /run/lock
tmpfs                          503M     0  503M   0% /sys/fs/cgroup
tmpfs                          503M   96K  502M   1% /tmp
/dev/mmcblk0p7                 1.5G 1000M  449M  70% /srv
/dev/mmcblk1p1                 7.2G  1.6G  5.7G  22% /data