I (re)mounted /var/opt/emoncms to an usb stick attached to my pi. Should i change certain things?

Hi,

I’ve setup emonSD on a raspberry pi3 i had laying around here to use instead of using the emoncms cloud version. Reason was that i created too many feeds and even have more now on the local version so i switched to a local install.

But i attached a 16GB usb stick to the pi and I (re)mounted /dev/sda1 (usb stick) to /var/opt/emoncms by editing fstab as i know SD Cards can fail. I did that by also creating an EXT2 file system on the usb stick and copying the initial contents of /var/opt/emoncms/ of the clean “install” to it and applying same ownerships to the directories and so on. Initially i used FAT32 but i noticed certain parts of backup (like restore) failed then so eventually went on with EXT2 as well and that seems to be working fine.
I also edited settings.ini (settings.php did not exist at all) of emoncms to make the redisbuffer be 30 seconds instead of the default 300 seconds since an usb stick is less or not even prone at all to wear out.

I wonder if i can do anything else besides lowering the feedwriter sleep to be 30 seconds (or can i set it even lower ?) since i don’t really need the low write anymore because of the usb stick. The reason i did this was to make sure in case of power loss that i still got most of the datapoints written to the feed files, with the default 300 seconds i guess data could be lost in case of a power outage.

or is there are a reason i should have left it at the default 300 seconds mark ?

Thanks

A USB stick, is a flash card in a case. Inherently the same technology (and often cheaper than a high quality SD Card).

Untrue AFAIK, just no one tests it. An SSD is a bit different. (there are plenty of discussions on this on this forum and elsewhere).

It is a balance between write wear and data loss. The balance is your choice.

If you worry about data loss, get an old laptop, install ProxmoxVE and run Emoncms in a container.

oh was not aware of that, so it would make no difference at all then

will have a look, so basically i should attach a small hard disk to the pi to prevent dataloss

yes but the laptop uses more power than a raspberry pi, i used to run emoncoms on an old intel nuc but i do not use the nuc anymore to save on power use

You’d be surprised - with the screen off, they are really efficient. I combined the systems from several Pis onto my PVE setup.

Right now, my work laptop (i5) is drawing 10W with screen on (spinning disc). I did measure my PVE laptop when I first set it up (it replaced an HP Micro Servr that was a power hog) and power draw was in single figures with 6 containers running. That was with a spinning disc. I fitted an SSD a while back.

NUCs are power hogs so not a good comparison.

10 Watt is indeed not much was not aware they draw so little, can’t remember exactly how much my nuc drew will have to attach it again some time but i think it was more than that. The problem will be to find a good old laptop that does not draw much power. After work i’ll check my nuc again and maybe install linux on it. I was running an old emoncms install on windows before but i got a feeling a linux install would draw a little less i also had plenty of external harddisks attached to them so that could have increased the power draw as well. I’ll do some testings after work but it’s good to know old laptops can be a good replacement for it

I was lucky I had a couple of old ones here and some spare memory chips.

If you are going to use it, I’d just install PVE, then run emoncms in an LXC container. Some one pointed me to this guy recently - Proxmox Helper Scripts | Proxmox Scripts For Home Automation for easy to use scripts - install Ubuntu then use the OEM emonscript to install emoncms. Running PVE will draw much less power than Windows (even if in a container or VM). Spinning Discs draw a surprising amount of power as well.

I installed it on my nuc and i already switched out one raspberry pi which was running pi-hole for a LXC container, it also runs a twitter bot and my python script to read out my wall plugs (wemo insights + meross plugs) and send it to emonpi. I still have to create an LXC container for emoncms and do its install but i’m just wondering how much ram and space did you assign for your container for emoncms ?

Ps on a side note power usage of nuc is really good, in windows it was hoovering around 10-15 Watt idle (but it was never really idle) with PVE it’s hoovering around 7-10 with one container running. Here is a small graph where the lower values are running the raspberry pi and the higher values the PVE, ignore the huge gaps i was having problems with my monitoring script and SSDP but i managed to fix it by disabling igmp snooping on the PVE. This is just a simple, very old nuc 5 i5RYH. So the power usuages i had seen under windows before was from having attached 4-6 extra (platter) disks, so i can replace 2-3 pi’s with it and i get about the same power usage and it’s in line with what you saw on your laptops.

i still have to explore more of PVE though but i got it running and can install LXC containers just awaiting on some input from you to see what kind of resources you assigned to your instance

Did you use the helper scripts?

My emoncms setup
image

There are instructions for using the install scripts on Ubuntu. You do need to edit the config as you will not want emonhub for instance.

For installing pihole and home assistant yes from the site you gave me.

Yes i did all that already actually, could not wait :slight_smile: i more or less have the same config except i assigned 1 GB of memory to use but i might lower it to 512MiB as well then and might have overdone it on the space requirements i assigned about 24GiB total.

image

I also noticed judging from the picture above the swap is not needed yet or not being used not sure if thats an error or it’s just not needed (yet) with 1 GB assigned

But will see i currently have 3 containers running emoncs, pihole (where also a twitter bot and my wemo + meross polling script is running on to send data from those plugs to emoncms) and home assistant and its hoovering around 7-9 Watt constantly, but there’s still plenty of cpu resources to use and i’m not sure i’ll install anything else.

I’ve also setup a backup of the containers and on my main pc i have sync program running that syncs the backup folder from the PVE to a local directory on my pc.

I only have a 256 GB ssd installed in the nuc and only 8 GB ram but for these 3 containers it’s currently enough and i can install some extra containers even

Excellent!

Even on a Pi, SWAP rarely gets used but there is no downside to it being there (I believe).

One of the key benefits of PVE :slight_smile:

Personaly, I’d be really happy with that!

Nice to see the install scripts worked fine. Which version of Linux did you install? We have had reports of issues with Swap in Pis on more recent versions.

I am also :slight_smile: thanks for suggesting pve

initialy i tried ubuntu-22.10-standard_22.10-1_amd64.tar.zst but during creation of the pxt i’ve gotten error that said unsupported system so then i tried ubuntu-20.04-standard_20.04-1_amd64.tar.gz and that went fine for creating the pxt. The OEM script also worked fine as far as i could tell, it did not report any errors. The only difference i noticed compared the version that was running on the pi is this screen

on the pi it showed selections all set to master, i still can choose master / stable for some reason it does not seem to remember it when going back to that page. So not sure if it that could be related to the install script or something else.

I also got the emoncms sensors (which i initially created a very long time ago) working in home assistant, its crazy how much home assistant has improved (i was still using a very old version before). So i can use the energy thing in home assistant as well (all i provided it was a cumulating KWH feed which i grabbed using the emoncms component from the local emoncms instance)

Yes I sort of expected that.

@TrystanLea for that one.

Yes rapid development, but always read the Breaking Changes notes and update at the end of the month!

One benefit of using a large partition with a relatively small amount of data is your USB stick will last
longer. Wear leveling will spread the writes over all of the allocated space, thus avoiding repeatedly writing data to the same part of the storage medium.

Hi Bill,

I actually am not using the usb stick setup anymore but the same system as borpin is using proxmox pve to be able to setup vm’s and linux containers. I replaced all my raspberry pi’s with just a single nuc running proxmox pve and there i created multiple containers to do what my rapsberry pi’s used to do (including one for emoncms / oem) it’s also easy to make backup of these containers. We kinda veered of to a switch from usb stick install to containers under proxmox pve

But yes you are right a bigger file system might improve things for usb sticks.

No doubt about it. It will definitely extend the USB stick’s life.

Same goes for a Solid State Drive, as they too use flash memory and employ wear leveling.