RAM disc for web server data

160 views
Skip to first unread message

James Muirhead

unread,
Jul 24, 2019, 9:55:42 AM7/24/19
to weewx-user
In case this is useful to anyone...

As the web server data is written to the SD every 5 minutes, I felt it would be appropriate to create a RAM disc for it. Should, in theory, improve lifespan of the SD card.

Anyhow, I just created an entry in /etc/fstab for the folder which is just the weather data, in my case it's the root of the web server /var/www/html but in your case (and default) may be /var/www/html/weather.

The entry is...

tmpfs /var/www/html tmpfs nodev,nosuid,size=20M 0 0

I gave it 20MB of RAM even though the web server is currently using ~700KB, but I have 1GB of RAM total to play with and will allow for potential expansion. Plus, it's the only thing I have on this particular Pi (Orange Pi PC running Armbian).

Just means, that on boot it can take up to 5 minutes for the web server to be populated with files and will likely return a 403 error when you try to look at it from a browser.

I also created a temporary splash page that just says "loading, please wait." which is loaded by a cron entry on @reboot.

cp /home/pi/temp-splash.html /var/www/html/index.html

Hope this is useful to someone. Has been quite fun to instigate.

-James Muirhead.

vince

unread,
Jul 24, 2019, 10:09:30 AM7/24/19
to weewx-user
On Wednesday, July 24, 2019 at 6:55:42 AM UTC-7, James Muirhead wrote
As the web server data is written to the SD every 5 minutes, I felt it would be appropriate to create a RAM disc for it. Should, in theory, improve lifespan of the SD card.
[...]
 
Just means, that on boot it can take up to 5 minutes for the web server to be populated with files and will likely return a 403 error when you try to look at it from a browser.

I also created a temporary splash page that just says "loading, please wait." which is loaded by a cron entry on @reboot.

cp /home/pi/temp-splash.html /var/www/html/index.html


Yes - I think several folks (including me) have posted something similar along the same lines.   I have one pi that I run basically 'everything' in ramdisk, although that of course loses you the syslogs if you need them for forensics after a crash or the like.

One thing you might think about is stashing your NOAA files to disk periodically (couple times a day) and restoring them, as they take a long time to regenerate as you get more and more data.  The other stuff will regenerate quickly on firstboot of course.


James Muirhead

unread,
Jul 24, 2019, 11:06:37 AM7/24/19
to weewx-user
Does it not regenerate all of the files on the webserver side every 5 minutes? Or does it only generate the ones it can't find? I got the impression it regenerated everything.

-James Muirhead

vince

unread,
Jul 24, 2019, 1:23:55 PM7/24/19
to weewx-user
On Wednesday, July 24, 2019 at 8:06:37 AM UTC-7, James Muirhead wrote:
Does it not regenerate all of the files on the webserver side every 5 minutes? Or does it only generate the ones it can't find? I got the impression it regenerated everything.



The historical NOAA files are a weewx bootup thing only (ie, my previous 12 years of summaries, in my case).

Thomas Keffer

unread,
Jul 24, 2019, 2:16:48 PM7/24/19
to weewx...@googlegroups.com
Weewx generates any missing NOAA files on every reporting cycle.

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/76401500-fba3-424a-9d72-aba1a89d1679%40googlegroups.com.
--
-tk

vince

unread,
Jul 25, 2019, 7:10:30 PM7/25/19
to weewx-user
On Wednesday, July 24, 2019 at 11:16:48 AM UTC-7, Thomas Keffer wrote:
Weewx generates any missing NOAA files on every reporting cycle.



I did a little test (admittedly a bit contrived) in which I deleted the NOAA file for a month from earlier this year and weewx did 'not' generate the missing intermediate month file. 

R A Lichtensteiger

unread,
Jul 29, 2019, 12:37:55 PM7/29/19
to weewx...@googlegroups.com
("Long time listener, first time caller")

vince wrote:

> On Wednesday, July 24, 2019 at 6:55:42 AM UTC-7, James Muirhead wrote
>>
>> As the web server data is written to the SD every 5 minutes, I felt it
>> would be appropriate to create a RAM disc for it. Should, in theory,
>> improve lifespan of the SD card.
>> [...]
>
> One thing you might think about is stashing your NOAA files to disk
> periodically (couple times a day) and restoring them, as they take a long
> time to regenerate as you get more and more data. The other stuff will
> regenerate quickly on firstboot of course.

Like many, I stumbled onto the tmpfs ram drive solution a while ago.

Killing three birds with one stone ... I have an init script
(attached) that:

o Backs up the web directory on shutdown or when called with
"sync" or "reload"
o Restores the web directory on startup

Cron entry runs the "sync" nightly, the other two modes are self
explanatory.

R

People using systemd are on their own
--
R A Lichtensteiger

Power corrupts. Absolute power corrupts absolutely. But it rocks
absolutely, too.

R A Lichtensteiger

unread,
Jul 29, 2019, 12:41:33 PM7/29/19
to weewx...@googlegroups.com
I wrote:

> Killing three birds with one stone ... I have an init script
> (attached) that:

OFFFS ... first post and I screw up by failing to attach the script
<blush>

R
--
R A Lichtensteiger

“Don’t make something unless it is both necessary and useful; but if it is
both necessary and useful, don’t hesitate to make it beautiful.”
—Shaker philosophy
weewx-ramdisk
Reply all
Reply to author
Forward
0 new messages