Weewx running on Raspberry Pi using NAS and Read-Only SD Card

82 views
Skip to first unread message

Peter_F

unread,
Jun 14, 2019, 8:21:47 AM6/14/19
to weewx-user
Just thought I would share the following in case anyone else is interested...

Up until a few months ago I was running weewx on a Raspberry Pi but with the following three directories mounted from an NFS share on a Synology NAS:

/var/lib/weewx
/usr/share/weewx
/etc/weewx

This basically kept the weewx configs and SQLite3 database off the SD Card.  My main reason for doing this was just in case the SD Card died.  I could rebuild a new one, install weewx again and mount the same directories and everything should be back to normal with nothing lost.  This all worked very well and I never had any problems.

A few months ago I decided to take it a step further.  I discovered a Raspberry Pi bootloader called BerryBoot (https://www.berryterminal.com/doku.php/berryboot).  It's main purpose is to allow you to have multiple Linux distributions on a single SD Card and select which one you want to run using a boot menu at boot time.  It uses squashfs base images and overlay technology to only write changes to the filesystem - delete these changes and you are back to the base image again.  BerryBoot facilitates having multiple base images on the one SD Card.

The other feature that BerryBoot supports, which sparked my interest, is to be able to use an iSCSI network drive to store the files instead of the SD Card.  Using this method, you end up with the whole Linux operating system running on network storage and the SD Card is purely for booting up.  Basically the root filesystem is on the NAS and the /boot filesystem is the only thing on the SD Card.  The only time anything is written to the card is if the Linux kernel is updated when using 'sudo apt update/upgrade'.

I have been running this way for a few months now and it has been working beautifully.  The only thing you need to think about is to make sure you shut down the Raspberry Pi when you want to reboot the NAS.  I still leave those three weewx directories as NFS mounts (on the same NAS).  That way they are still separate from the operating system - but this is completely optional.  You could leave everything within the iSCSI disk if you wanted to.

The steps for setting up BerryBoot to use iSCSI on a Synology NAS is here (https://www.berryterminal.com/doku.php/storing_your_files_on_a_synology_nas_using_iscsi).  The screen shots are from an older version of DSM (Synology Operating System) but you should get the idea.  Also, any standard iSCSI Target should work - it doesn't have to be on a Synology NAS.

Cheers,

Peter

Pat

unread,
Jun 14, 2019, 10:55:02 AM6/14/19
to weewx-user
This is an interesting idea and pretty cool to try and safeguard against SD failure. I know Tom has a Raspberry Pi weewx test running for 4+ years - but personally I can't seem to keep my class 10 SD cards working longer than a year or 18 months. Maybe I have too much logging turned on :) 

What if there's a power failure? Do you have to babysit the BerryBoot to boot to the NAS correctly or can you automate that?

vince

unread,
Jun 14, 2019, 12:27:49 PM6/14/19
to weewx-user
On Friday, June 14, 2019 at 5:21:47 AM UTC-7, Peter_F wrote:
The only thing you need to think about is to make sure you shut down the Raspberry Pi when you want to reboot the NAS.  I still leave those three weewx directories as NFS mounts (on the same NAS).

Yecccch - there has to be some way to deal with it via the os startup files.

I haven't ever failed a SD card on a pi3 or pi3+ for what that's worth.   Haven't failed even a model-B in years since I started logging 'those' to tmpfs and mounting basically all the filesystems in tmpfs.  I have a post or three somewhere here on how to do that, basically just edit your fstab and it runs fine.

Peter_F

unread,
Jun 15, 2019, 4:57:37 AM6/15/19
to weewx-user
I initially tried BerryBoot out of curiosity and did not expect to keep using it but decided to do so when I found it worked so well. I have only had one SD Card fail in about five year of using weewx - and that by conincidence was one week after I configured the NFS mounts so I was lucky I didn't lose anything. Even before that I was using log2ram to minimise writes to the SD Card.

Once BerryBoot has been configured with the iSCSI Target and an OS installed, it can be flagged as the default OS so it boots up automatically, no manual intervention required. It displays the boot menu for 20 secs (default time) before booting the default OS. If you run headless (no monitor attached), it can be configured to run up a VNC server so you can view the boot menu and configure remotely. Once the OS starts booting, you do lose the VNC.

The other advantage is that you end up with a fast filesystem - faster than the SD card. It will also work over WiFi but I have not tried it. I expect it wouldn't be as stable (or as fast) as using an Ethernet cable. Also, because it uses the NAS filesystem, you can also utilise the NAS's snapshot and backup features - depends on how paranoid you want to be.

It's not a solution for everyone but it impressed me so I kept using it.

Peter

Reply all
Reply to author
Forward
0 new messages