Some essential tweeks
You should now have a working TTN gateway, but to help with long-term robustness we should minimise
the number of writes made to the SD card. The chief culprit in this area is logging - the RAK gateway
software in particular is VERY verbose with its logs, at this stage in my set-up it was generating 6MB of log
data per hour to both daemon.log and syslog. Most of this being errors and warnings relating to
unconfigured extraneous software packages not required with a TTN-based gateway. These can easily be
stopped, once and for all with these command lines:
sudo systemctl disable loraserver
sudo systemctl disable lora-app-server
sudo systemctl disable lora-gateway-bridge
sudo systemctl disable postgresql
sudo systemctl disable mosquitto
sudo systemctl disable redis
Next are a load of error lines to do with the unused WiFi AP that the software tries to set up, this can be
disabled using: `sudo gateway-config` -> (5) Configure WiFi -> (2) Enable client mode/Disable AP
If you're not using GPS, but haven't configured for no GPS this will also generate copious errors.
OK, so hopefully you've been able to fix all those error messages in daemon.log but that still leaves roughly
3500 lines/hour of 'normal' log activity which I've found no way of further reducing. The next step is to remount all of Rasbian's highly volatile directories to tmpfs ramdisk. This is easily done with an edit to
/etc/fstab - simply add the following three lines:
tmpfs /tmp tmpfs defaults,noatime,nosuid,size=100m 0 0
tmpfs /var/tmp tmpfs defaults,noatime,nosuid,size=30m 0 0
tmpfs /var/log tmpfs defaults,noatime,nosuid,mode=0755,size=200m 0 0
This all massively improves long-term SD card write wear but we now still have the problem of large log files building up in our small ramdisk mounts. I added a few extra lines to PoEUPSPi.sh's while-done loop to
truncate syslog to a manageable size and delete daemon.log once a day:
date | grep 04:00:00 > /dev/null
if [ $? -eq 0 ] ; then
sudo bash -c 'echo "$(tail -1000 /var/log/syslog)" > /var/log/syslog'
sudo rm /var/log/daemon.log
fi
Finally, to save a few milliwatts of power and extend slightly the UPS hold-up time it's possible to turn off
some of the RPi's unused peripherals, HDMI is already dealt with in PoEUPSPi.sh, but we can do more: WiFi
and bluetooth can be disabled with a one-off edit to /etc/modprobe.d/raspi-blacklist.conf, add the lines:
blacklist brcmfmac
blacklist brcmutil
Likewise disable sound by editing /etc/modprobe.d/alsa-blacklist.conf to add:
blacklist snd_bcm2835