Zram-config

Tags: #<Tag:0x00007fc3fc9bb4d8> #<Tag:0x00007fc3fc9bb410>

Platform information:
- Hardware: Raspberry Pi 3B
- OS: Raspbian Buster
- Java Runtime Environment: Zulu (openjdk version “1.8.0_152”)
- openHAB version: 2.4.0 (Build)
- basicUI

In order to preserve the SD card I’m using zram as described here:
https://github.com/StuartIanNaylor/zram-config

In my setup zram is used to move all log files and the openHAB persistence files to RAM:

/var/log
/var/lib/openhab2/

Using the checking tools provided in the instructions zram seems to work.

To be really sure that nothing is written to the SD-card I use this command to see what files have been changed:
sudo find / -cmin -1

Curiously this indicates that data is written to the SD-card as well as to zram (excerpt):

/var/lib/openhab2/persistence/rrd4j/nCpuTemperature.rrd
/var/log/openhab2/events.log
/opt/zram/zram1/upper/persistence/rrd4j/nCpuTemperature.rrd
/opt/zram/zram2/upper/openhab2/events.log

Looking at these files using ls -al shows that they have the exact same time stamp which seems to confirm my apprehension.

The help section in the instruction says:

zram_dir is the directory you wish to hold in zram, the original is moved to a bind mount bind_dir and is synchronised on start/stop and write commands.

Does that mean that the SD card is written with every change of data in zram? If that’s so, what’s the benefit of zram?

How can I make sure the data only is written to zram and stored on the SD-card only when shutting down the system or maybe once a day?

Thanks a lot for any help!

I think that directory is to writes the contents of zram when the system is shut down cleanly.

No, that “and write commands” part of the sentence is misleading, forget about it.

If that was your intention then that’s a useless command.
It’s showing the current (overlay)FS (which of course is updated) and the ‘upper’ FS zram part (which of course is updated, too).

That’s right what it does: it syncs on (proper!) box shutdown (only).

PS: did you use openhabian to install it ?

1 Like

Thanks. So everything is alright then? I’m just a Linux newbie and search the internet for commands that might help to do what I need.

I don’t understand this part of your reply

It’s showing the current (overlay)FS (which of course is updated) and the ‘upper’ FS zram part (which of course is updated, too).

Does that mean that accessing the regular file /var/log/openhab2/events.log really shows the data in RAM?

So if sudo find / -cmin -1 doesn’t work, how do I find which files actually are written to the SD card?

I’m also using
iostat -m
which indicates that most data is written to zram but also still to the SD card:

Device             tps    MB_read/s    MB_wrtn/s    MB_read    MB_wrtn
mmcblk0           0,60         0,01         0,00        187         22
zram0             0,01         0,00         0,00          1          0
zram1             1,02         0,00         0,00          0        105
zram2             0,43         0,00         0,00          0         43

I’ve installed Raspian and the openHAB from the repository. Next time I will try openhabian.

yes

OK, I understand. Even though all data is stored in zram this is directly reflected in the regular file system.

Now, what about
iostat -m
which indicates that data is written the SD card:

Device             tps    MB_read/s    MB_wrtn/s    MB_read    MB_wrtn
mmcblk0           0,60         0,01         0,00        187         22
zram0             0,01         0,00         0,00          1          0
zram1             1,02         0,00         0,00          0        105
zram2             0,43         0,00         0,00          0         43

I’ve already disabled kernel logging. And I find that data is written to
/proc and /sys which both seem to be located in RAM only (using find / -cmin -1)

If find / -cmin -1 is not suitable to identify files that are actually written to the SD card which command could I use instead?

I would like to identify those files and also move them to zram.

Well you can browse those files but remember it’ll also show those that already are on zram.
And you would need to repeat this as some processes might be inactive during that minute while active during others.

For the second time in three weeks I had a hard reset due to failures in the main power line. For the second time my thinker board does not bootup anymore. The first time I reinstalled everything from scratch, however this time would prefer to avoid this as it is very time consuming. Is there a way to reboot my system? I run on a linaro linux and I have access to the SD card.

Thank you

Francesco

how does that relate to ZRAM which is available in openhabian only ?

I’m using ZRAM with linaro and openhab on my asus tinker board. It works but I have this issue. Is there any way to reboot the system without erasing the SD card? I had already a lot of hard resets during the past years however this no booting issue happened since I started to use ZRAM.

I don’t understand. Did you use openhabian to enable zram?
openHABian uses OverlayFS which syncs to disk on unmount (executed by default before shutdown) .
“Standard” zram only does not so if you use that your data will be gone.

Hello,
I guess I don’t use OverlayFS as I don’t use openhabian. However I don’t care too much about the data loss as I was using only /var/log folder and the swap. What I need is to boot the system as it does not boot anymore. Do you think that commenting out all the ztab rows could fix it? Do you

Unlikely. If it doesn’t boot something on disk is broken. Cannot comment on setups I don’t know.

I checked the two partitions using fsck and they are ok…I’ll try to see if I can reboot it in some way…I’ll let you know…

Francesco