Read only approach on Rasp Pi 2? MQTT API latest?

I'm ordered the new RPi 2 and am looking to use this as an all-in-one web server / OEM server / data collector via USB (from a Current Cost Envi CC128).

The idea is to move all the database actions onto an external hard drive and perhaps having a read-only OS (as per IPE-R1 - I wish to stick with Raspbian).

What is the latest on the best db to be used with OEM - I'll be starting afresh, so historical data not required to be brought in.

Is there any significant movement towards bringing in MQTT as a main backbone? I would prefer to use this as a method of pushing my external data into OEM rather than use the HTTP API method (such overkill).

Appreciate any advice

Nick

fluppie007's picture

Re: Read only approach on Rasp Pi 2? MQTT API latest?

Also ordered one, should have it by the end of this week. Hopefully setting it up is the same :).

pb66's picture

Re: Read only approach on Rasp Pi 2? MQTT API latest?

I'm also looking forward to trying the Pi 2, I too will be using a hdd, although I prefer a full "write" OS on a hdd. however I do keep a read-only version on the SDcard that serves as a back-up and a "back door" in case I do something disabling access or breaking the OS on the HDD, by whipping out the SDcard and editing the "cmline.txt" on a pc I can boot onto the SD card, mount the hdd and sort out any issues or restoring etc before re-editing the cmdline.txt and booting back to the HDD.

I like the safety of the "spare OS" but also believe (untested or proven) the HDD gives better performance not only because of disk access times but also because of not restricting memory caching by running read-only from the SD. I don't think either of these slow the Pi significantly when using as a simple headless data forwarder or personal server, but I also like to use a Remote Desktop Program to access the Pi to remotely edit and upload sketches using arduino IDE so any speed boost is welcome.

The idea of having a read-only OS and writeable "data" partition is used on the current SDcard image which has emonhub and a low-write version of emoncms as it's intended to be run entirely on the SD, but the data partition is easily replaced with a hdd rather than using the 3rd SD partition.

I wouldn't recommend RPI-R1 as we have had some issues with it and the support is a little scarce see Updating the OEM Rock Solid Gateway image for more info on that. Currently OEM uses a stock raspbian image with minimal changes to make it read-only and it has worked well. The only real issue was with the "fake-hwclock" which now has a reliable fix (see Read-only image time issues)

​Paul

 

Bill Thomson's picture

Re: Read only approach on Rasp Pi 2? MQTT API latest?

Looking forward to trying it here too. It'll be interesting to see how it compares (performance-wise) to the Odroid C1.

 

elyobelyob's picture

Re: Read only approach on Rasp Pi 2? MQTT API latest?

Oh interesting. I'll have tons of space on my HDD (2TB!) (just need to receive my powered USB hub as my early Pi isn't powering it up). Hadn't thought about using the HDD as the OS. Any instructions on how to do this? I'm now looking at also adding in OwnCloud as well to use up some of that space. So, likely creating 3 partitions on the drive.

pb66's picture

Re: Read only approach on Rasp Pi 2? MQTT API latest?

if starting a fresh hdd install by far the easiest way is to put the latest raspbian OS image on the hdd, then after connecting it to the pi, mount the hdd and edit a couple of files and reboot, job done!

Assuming a "stock" setup and the hdd is /dev/sda (ie the first USB device discovered) these few lines can be cut and pasted to automate the process

sudo tune2fs -U random -L hdd  /dev/sda2

​sudo mkdir ~/hdd

sudo mount /dev/sda2 ~/hdd

sudo mv ~/hdd/etc/fstab ~/hdd/etc/fstab.orig

sudo sh -c "echo 'proc            /proc           proc    defaults              0    0' >> hdd/etc/fstab"

sudo sh -c "echo '/dev/mmcblk0p1  /boot           vfat    defaults              0    2' >> hdd/etc/fstab"

sudo sh -c "echo '/dev/sda2       /               ext4    defaults,noatime      0    1' >> hdd/etc/fstab"

sudo sh -c "echo '# a swapfile is not a swap partition, so no using swapon|off from here on, use  dphys-swapfile swap[on|off]  for that' >> hdd/etc/fstab"

sudo sh -c "echo ' ' >> hdd/etc/fstab"

sudo mv /boot/cmdline.txt /boot/cmdline.txt.ORIG

sudo sh -c 'echo "dwc_otg.lpm_enable=0 console=tty1 root=/dev/sda2 rootfstype=ext4 elevator=deadline rootwait" > /boot/cmdline.txt'

This will mount the hdd, change the UUID,  create back-ups of the files to be changed, make the changes.

When rebooted it will be running on the hdd. But before you reboot you can use fdisk to increase the size of the file system partition and add the partitions you want. Plus if needed you should comment out the last line in  the inittab to free up the serial port. (remember until you reboot the filesystem you need to edit is mounted as /home/pi/hdd/filesystem, eg /home/pi/hdd/etc/inittab not /etc/inittab until rebooted)

This is by far and away the easiest way but it does leave you with a redundant copy of the boot partition on the hdd, it's only only 58MB though, but as you can only have up to 4 primary partitions you may want to change this at some point. It's not difficult but must be done along with some other edits so you can still boot.

Paul

pb66's picture

Re: Read only approach on Rasp Pi 2? MQTT API latest?

@ fluppie007, I have a RPi 2B up and running now and aside from the OS (needs to be latest 31/01/15 raspian iso) everything seems to install ok so far.

@ Bill - I have no idea about comparing to a "Odroid C1" but it's sooooooooooooo much faster than B+ !

Paul

fluppie007's picture

Re: Read only approach on Rasp Pi 2? MQTT API latest?

Perfect just received mine and I'm downloading the latest Raspbian and Ubuntu Snappy Core.
For people who like unboxing video's: https://www.youtube.com/watch?v=08Q11_DDUvg :-D.

fluppie007's picture

Re: Read only approach on Rasp Pi 2? MQTT API latest?

pb66's picture

Re: Read only approach on Rasp Pi 2? MQTT API latest?

I would think so, If you are running read-only you should also install ntp-backup and if you may need to manually set the com_baud in emonhub.conf if you are still running your RFM2Pi(rfm69) at 57600, that speed was dropped for a more reliable 38400 in the RFM2Pi firmware, so emonhub was changed to only support 9600 and 38400.

(sidenote - 57600 will be reintroduced next emonHub update as the jeelinks are 57600)

Paul

mtran's picture

Re: Read only approach on Rasp Pi 2? MQTT API latest?

Hi Paul, I followed your instructions and it works like a charm.

Just a silly question, the rpi2 still can't fully boot from usb eg ext hdd, ie it'll always need an sd card to start the boot process?

 

 

pb66's picture

Re: Read only approach on Rasp Pi 2? MQTT API latest?

Yes you do still need an SDcard to start the boot process. Old small capacity mobile phone micro SD cards are perfect for freeing up a larger SDcard that can be used elsewhere. I have a couple of 64MB Nokia that I use.

Paul

fluppie007's picture

Re: Read only approach on Rasp Pi 2? MQTT API latest?

Up and running! Nothing special, only the need to manually set the baud rate to 57600 in emonhub.conf
 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.