Z-Way on a read-only filesystem

Discussions about Z-Way software and Z-Wave technology in general
Post Reply
vbertola
Posts: 5
Joined: 15 Sep 2016 18:26

Z-Way on a read-only filesystem

Post by vbertola » 15 Sep 2016 18:45

Hello,

I have looked for this issue in the documentation and in the forum but I didn't find anything.

I am building my first Raspberry/Razberry installation, and I've been highly recommended to install the Raspberry on a read-only filesystem - that is, install it normally, then move all the parts of the filesystem that need to be continually written upon to RAM-based temporary filesystems, and mount the main partitions read-only; you can switch them to read-write mode whenever you need to install a new package or edit configurations, but keep the Raspberry normally running in read-only mode. This increases the Raspberry's resilience, as it is highly likely that, if the Raspberry is not shut down cleanly (e.g. due to a power outage), the filesystem on the SD card will become corrupted and you may have to fix it manually or even reinstall it altogether.

My Raspberry works fine in this configuration, except when I try to use the Z-Way server. If I boot the system in read-only mode, the server doesn't start properly; apparently, it has to overwrite some configuration files every time it starts up, even if no configuration was actually changed. If I then remount the filesystem in read-write mode and restart the server, it works fine - however, as soon as the filesystem is changed to read-only mode, the server stops working.

I'm not sure why the Z-Way server needs to write stuff in its own directories all the time (logs are not an issue, as /var/log points to a writable tmpfs). I understand that the server needs to write down whatever configuration change is made through the interface, but as long as you don't edit anything it should be able to work without touching the filesystem; and any temporary stuff should be written to /var and not in the application's own directory.

Anyway, I'd like to know if anyone has ever experimented running Z-Way on a read-only filesystem, whether it worked and how, or whether there is any documentation on which are the specific files and directories that need to be writable; there are some alternatives to reduce the risk of filesystem corruption (for example, moving /opt/z-way-server to a separate read-write partition and keeping all the rest read-only) but I'd prefer to solve the issue cleanly.

Thanks!

gsaw
Posts: 65
Joined: 22 Aug 2016 00:26

Re: Z-Way on a read-only filesystem

Post by gsaw » 19 Sep 2016 16:22

one place on disk I know where z-way server writes data is /opt/z-way-server/automation/storage/. The folder contains configuration and there z-way-server writes dynamic data.

Try to rename the folder "storage" to "storage.master"

Code: Select all

sudo mv /opt/z-way-server/automation/storage /opt/z-way-server/automation/storage.master
then create soft link

Code: Select all

sudo ln -s /var/storage.master /opt/z-way-server/automation/storage 
and then edit /etc/init.d/z-way-server add before calling z-way-server something like

Code: Select all

cp -rp /opt/z-way-server/automation/storage.master /var/

vbertola
Posts: 5
Joined: 15 Sep 2016 18:26

Re: Z-Way on a read-only filesystem

Post by vbertola » 21 Sep 2016 14:24

Yes, that's the approach I'm working upon, though I guess that I also have to save the files from the temporary directory onto the SD card whenever I shut down the server. (Also, /opt/z-way-server/config is another directory that needs to be written upon.)
It would be nice to get some more details from the developers, though, or possibly a configuration option that can be activated to include this behaviour in the standard startup scripts.

McX
Posts: 1
Joined: 17 Apr 2019 15:19

Re: Z-Way on a read-only filesystem

Post by McX » 17 Apr 2019 15:27

Using https://github.com/graysky2/anything-sync-daemon it is easy to automate saving to read-only system.

In /etc/asd.conf :

Code: Select all

WHATTOSYNC=('/opt/z-way-server/automation/storage' '/opt/z-way-server/config')
In /etc/systemd/system/asd.service :

Code: Select all

ExecStart=/bin/mount -o remount,rw /
ExecStart=/usr/bin/anything-sync-daemon sync
ExecStart=/bin/mount -o remount,ro /
ExecStop=/bin/mount -o remount,rw /
ExecStop=/usr/bin/anything-sync-daemon unsync
ExecStop=/bin/mount -o remount,ro /
In /etc/systemd/system/asd-resync.timer adjust timer as needed :

Code: Select all

OnUnitActiveSec=1d

Post Reply