Mapdb doesn't restoreOnStartup

Tags: #<Tag:0x00007f617a7e7880>

Hi!
i moved to a new raspberry (openhab-cli restore) and i’m having problems with restoring items…
here’s my mapdb.persist:

Strategies {
    everyHour       : "0 0 * * * ?"
    everyDay        : "0 0 0 * * ?"
    
    default = everyChange
}

Items {
        *   :   strategy = everyChange,restoreOnStartup
}

here’s an example with my item “WT_RN_2”…
events.log

2020-07-24 22:56:11.889 [ome.event.ItemCommandEvent] - Item 'WT_RN_2' received command ON
2020-07-24 22:56:11.899 [vent.ItemStateChangedEvent] - WT_RN_2 changed from OFF to ON

/var/log/openhab2/openhab.log

2020-07-24 22:56:11.896 [DEBUG] [pdb.internal.MapDBPersistenceService] - store called for WT_RN_2
2020-07-24 22:56:11.899 [DEBUG] [pdb.internal.MapDBPersistenceService] - Stored 'WT_RN_2' with state 'ON' in mapdb database

this tells me, the service registered the change, right?

after reboot - events.log:

2020-07-24 22:59:57.537 [vent.ItemStateChangedEvent] - WT_RN_2 changed from NULL to OFF

i didn’t have any problems with my previous setup…
what can i do? :slight_smile:

edit: and also rrd4j doesn’t work properly… the values in my temps chart remain the same and are not updated.

best regards
Peter

Yes indeed. But did it write the change to a permanent file that can survive reboot?
Feels a bit like this report -


so we’d like to confirm your OH version, and if you have ZRAM in use.

It might be helpful to use REST API to inspect the persisted data for a sample Item that hasn’t been updated yet, just after boot. Expect only one record of course, but is there one at all? No record, no restore.

1 Like

i have lastest stable OH and zram is enabled. log files are present after reboot so i think zram syncs as intended. if there would be a problem with zram the item wouldn’t get any value on restart but remain NULL, right?

when should i check via REST API? before or after reboot? i checked before one of my multiple updates and the value was “there”.

Yes.

okay, here we go (reboot) again.

events.log before reboot:

2020-07-26 08:56:26.782 [ome.event.ItemCommandEvent] - Item 'WT_2' received command ON
2020-07-26 08:56:26.795 [vent.ItemStateChangedEvent] - WT_2 changed from OFF to ON

openhab.log:

2020-07-26 08:56:26.785 [DEBUG] [pdb.internal.MapDBPersistenceService] - store called for WT_2
2020-07-26 08:56:26.792 [DEBUG] [pdb.internal.MapDBPersistenceService] - Stored 'WT_2' with state 'ON' in mapdb database

http://oha2:8080/rest/persistence/items/WT_2?serviceId=mapdb
{"name":"WT_2","datapoints":"1","data":[{"time":1595746586787,"state":"ON"}]}

HERE COMES THE REBOOT

events.log:
2020-07-26 08:58:29.949 [vent.ItemStateChangedEvent] - WT_2 changed from NULL to OFF

http://oha2:8080/rest/persistence/items/WT_2?serviceId=mapdb
{"name":"WT_2","datapoints":"1","data":[{"time":1595623748111,"state":"OFF"}]}

hope this helps to help :wink:

have a nice day!

Peter

EDIT: this time also rrd4j persisted items lost all their data :frowning:

All looks like a successful mapdb write.
The record you manually read back with REST API has a timestamp
July 26, 2020 6:56:26.787 AM
which you might find odd, but persistence records in UTC and corrects for timezone, so that looks right to me. matching your events.log for a +2 timezone

Okay.

I am suspicious of this NULL-to-OFF change event.
because
restore-on-startup does NOT usually log events like that, doing its restore silently.
Maybe that’s changed; or maybe this Item is linked to a binding that provides this change log (in which case, where did the restore go?)
Something I don’t understand here.

Nevertheless, we certainly don’t get the expected (silent) restore to ON.

This record after reboot is timestamped
July 24, 2020 8:49:08.111 PM
so clearly your previous ON record has been lost (or replaced).
I would assume we get a view back into the “hard” database because nothing new is yet written to the “zram” copy.

I know nothing about ZRAM but it’s a pretty obvious candidate for the supposition that whatever the reason, it is not writing an in-memory copy of mapdb to permanent storage when system shut down.

As a final curiosity - did you take this REST API sample after that null-to-off change in the events log? Why didn’t that get recorded?

Anyway, I’ve come to the end of my knowledge. Need some ZRAM expertise here.

bah, i’ve had more than enough problem with ZRAM (this is the reason i went for a new setup…).

zramctl gives no output, so i assume something with ZRAM is the cause of my problems - again.

I’m gonna try a last time with fresh openHABian, manual backup (copying files and installing binding manually). if that doesn’t work i’m back to move root to USB (ssd) - even if that is not recommended. worked fine for over 3 years

i just flashed the actual openhabian image to a new sd card a waited until the setup was done.
i installed “needed and recommended system packages” and mosquitto via openhabian-config.
then i installed all needed bindings and copied all my *.things *items etc. files from my previous install.

i installed mapdb with this settings:

Strategies {
    everyHour       : "0 0 * * * ?"
    everyDay        : "0 0 0 * * ?"
    
    default = everyChange
}

Items {

        *   :   strategy = everyChange,restoreOnStartup

}

but my items are not restored on with their last value on reboot. see also this thread.

i didn’t mess with zram config, this is what what zramctl brings up:

[17:19:22] openhabian@oha2:~$ zramctl
NAME       ALGORITHM DISKSIZE  DATA  COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram1 lzo-rle       500M 17.3M 228.9K  588K       4 /opt/zram/zram1
/dev/zram0 lzo-rle       600M    4K    87B   12K       4 [SWAP]

didn’t touch /etc/ztab:

# swap  alg     mem_limit       disk_size       swap_priority   page-cluster    swappiness
swap    lz4     200M            600M            75              0               90

# dir   alg     mem_limit       disk_size       target_dir                      bind_dir
dir     lz4     150M            500M            /var/lib/openhab2/persistence   /persistence.bind
# do not enable as long as you make substantial config changes
#dir    lz4     30M             100M            /var/lib/openhab2/jsondb        /jsondb.bind

# log   alg     mem_limit       disk_size       target_dir                      bind_dir                oldlog_dir
log     lzo     150M            500M            /var/log                        /log.bind

EDIT: disables/removed ZRAM via openhabian-config and persistence behaves as expected.

What do you want to tell us with this post ?
And please stop posting here into this thread. This is tagged “Tutorials” for a reason.

that with the ZRAM config from the actual openHABian persisted data is lost on reboot.
i have no idea why and i’m pretty sure i’m not gonna find out on my own.
imho this isn’t a problem caused by my “private” setup but related to the acutal openHABian.

sorry, i thought it’s related to ZRAM and would fit here. wasn’t my intention to spam your tutorial.

could you move this to this thread?

why? They’re already there after installation.
You must not run anything else other than to install components marked as optional.

And why did you manually copy files instead of using openhab-cli backup/restore ?

If so then everybody must be having that problem, right ? But you’re the only one to report.
It must have to do with the things you did that others do not.
So stop pointing at openHABian again and again just because you don’t find your error.
I don’t know what your problem is and frankly I’ve lost motivation to help.
As a last attempt: Take a systematic approach. Stop rebooting all the time. That is a useless action. It never cures anything but creates new problems only. I believe I have told you that already.
I’d suggest you edit /usr/local/bin/zram-config and append a “-x” to the first line.
Then stop openhab and execute /usr/local/bin/zram-config stop (as root of course) to see what it is copying and if somethings fails in doing so.
Run openhab-cli reset-ownership and check the access rights of your persistence files. The original ones on the filesystem BEFORE ZRAM is started (don’t uninstall ZRAM. You can enable/disable startup during boot with systemctl disable|enable zram-config).

Then it isn’t active so it can’t be causing whatever problem you’re seeing.

that wasn’t obvious to me… (if i remember correclty some additional packages are added with this “command”.

did that already on a previous try, just thought maybe this would help…

that’s not what i said. i literally meant “in my humble opinion” and i know how humble my opinion in this matter is…

i just do this to be sure there’s no data loss on reboot :no_mouth:
is there a way to “simulate” a reboot? (stop openhab and zram-config stop?)

okay. tabula rasa, new openhabian image, no recommended packages, just mosquitto via openhabian-config and openhab-cli restore

(just to be sure: #! /bin/bash -x)

[19:55:06] openhabian@oha2:~$ sudo /usr/local/bin/zram-config stop
+ ZSHARE=/usr/local/share/zram-config
+ ZLOG=/usr/local/share/zram-config/log/zram-config.log
+ ZDIR=/opt/zram
+ [[ -f /boot/cmdline.txt ]]
+ grep -q init=/bin/ro-root.sh /boot/cmdline.txt
+ ZEPHEMERAL=false
+ case "$1" in
++ date +%Y-%m-%d-%H:%M:%S
+ echo 'zram-config stop 2020-07-27-19:55:45'
+ tac /usr/local/share/zram-config/zram-device-list
+ file=/usr/local/share/zram-config/zram-device-list.rev
+ read -r line
+ case "$line" in
+ set -- dir /zram1 /var/lib/openhab2/persistence /persistence.bind
+ echo 'ztab remove dir /zram1 /var/lib/openhab2/persistence /persistence.bind'
+ case "$1" in
+ ZTYPE=dir
+ ZRAM_DEV=/zram1
+ TARGET_DIR=/var/lib/openhab2/persistence
+ BIND_DIR=/persistence.bind
+ '[' false = false ']'
+ removeZdir
+ echo /zram1
++ echo /zram1
++ tr -dc 0-9
+ DEV_NUM=1
+ '[' '!' -z /var/lib/openhab2/persistence ']'
+ umount --verbose /var/lib/openhab2/persistence/
+ sleep .1
+ umount --verbose -l /var/lib/openhab2/persistence/
+ mergeOverlay
+ '[' '!' -z /zram1 ']'
+ umount --verbose /opt/zram/zram1/
+ umount overlay1
umount: overlay1: no mount point specified.
+ rm -rv /opt/zram/zram1
+ '[' '!' -z /persistence.bind ']'
+ umount --verbose /opt/zram/persistence.bind/
+ rm -rv /opt/zram/persistence.bind
+ echo 1
/usr/local/bin/zram-config: line 203: echo: write error: Device or resource busy
+ /sbin/zramctl -r /dev/zram1
+ echo '/dev/zram1 removed'
+ read -r line
+ case "$line" in
+ set -- swap /zram0 zram-config0
+ echo 'ztab remove swap /zram0 zram-config0 '
+ case "$1" in
+ ZTYPE=swap
+ ZRAM_DEV=/zram0
+ LABEL=zram-config0
+ removeZswap
++ echo /zram0
++ tr -dc 0-9
+ DEV_NUM=0
+ swapoff /dev/zram0
+ echo 0
+ /sbin/zramctl -r /dev/zram0
+ echo '/dev/zram0 removed'
+ read -r line
+ rm -fv /usr/local/share/zram-config/zram-device-list.rev /usr/local/share/zram-config/zram-device-list
[20:00:59] openhabian@oha2:~$ sudo openhab-cli reset-ownership

This command gives openHAB control of its own directories.
May resolve permission errors during startup or configuration.
openHAB directories will be owned by openhab:openhab

Okay to Continue? [y/N]: y
[20:09:01] openhabian@oha2:~$ ls -l /var/lib/openhab2/persistence/mapdb/
total 268
-rwxr-xr-x 1 openhab openhab     32 Jul 27 18:13 Readme.txt
-rw-r--r-- 1 openhab openhab  33064 Jul 27 19:55 storage.mapdb
-rw-r--r-- 1 openhab openhab 228192 Jul 27 19:55 storage.mapdb.p
-rw-r--r-- 1 openhab openhab     16 Jul 27 19:55 storage.mapdb.t

now i probably should start zram-config again?

I would first satisfy myself that persist-restore is working as expected across reboots!

No they are not. Why do people always do stuff other than what the installation guide tells them ? *sigh*
Did you even also install ZRAM from the menu ?

Your output is missing /var/log. Did you mess with that ?

Manually test things.
First, do

systemctl disable zram-config
systemctl disable openhab2
rm -f /usr/local/share/zram-config/zram-device-list*
reboot

and replace /usr/local/bin/zram-config with the latest version (here) to have a clean starting point.

Leave the -x in zram-config

After boot

cat /etc/systemd/system/zram-config.service
cat /etc/ztab
zramctl
/usr/local/bin/zram-config start
zramctl
date > /var/lib/openhab2/persistence/date
/usr/local/bin/zram-config stop
zramctl
cat /var/lib/openhab2/persistence/date

and show the output of zram-config and /usr/local/share/zram-config/log/zram-config.log

no. iirc openhab-cli restore does?

[10:46:11] openhabian@oha2:~$ sudo systemctl disable zram-config
Removed /etc/systemd/system/basic.target.wants/zram-config.service.
[10:46:22] openhabian@oha2:~$ sudo systemctl disable openhab2
Removed /etc/systemd/system/multi-user.target.wants/openhab2.service.
[10:46:34] openhabian@oha2:~$ rm -f /usr/local/share/zram-config/zram-device-list*
[10:46:43] openhabian@oha2:~$ sudo reboot

okay (copied data from link) and pasted on console with sudo nano

reboot

[11:09:00] openhabian@oha2:~$ cat /etc/systemd/system/zram-config.service
[Unit]
Description=zram-config
After=local-fs.target
Before=reboot.target halt.target smbd.service openhab2.service
PartOf=openhab2.service

[Service]
Type=oneshot
ExecStartPre=-/bin/rm -f /usr/local/share/zram-config/zram-device-list /usr/local/share/zram-config/zram-device-list.rev
ExecStart=-/usr/local/bin/zram-config start
ExecStop=-/usr/local/bin/zram-config stop
TimeoutSec=180
RemainAfterExit=yes

[Install]
WantedBy=basic.target

[11:09:11] openhabian@oha2:~$ cat /etc/ztab
# To comment out any line Add new drives with the first collumn providing the drive type and then drive details seperated by tab
# All algorithm in /proc/crypto are supported but only lzo/lz4 have zramctl text strings.
# lz4 is the fastest whilst deflate(zlib) has much better text compression.
# mem_limit is compressed memory limit and will set a hard memory limit for sys admin.
# disk_size is virtual uncompressed size approx 220-450% of mem allocated depending on algorithm and input file.
# Much higher than the compression alg is capable will waste mem as there is an approx 0.1% mem overhead even when empty.
# swap_priority set zram over alternative swap devices.
# page-cluster 0 means tuning to singular pages rather than default 3 which caches 8 for HDD tuning, which can lower latency.
# swappiness 80 due to improved performance of zram allows more usage without effect of raising from default 60.
# Can be up to 100 but will increase process queue on intense load such as boot.
# 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.
# bind_dir is a directory where the original dir will be mounted for sync purposes. Usually in /opt or /var, name optional.
# oldlog_dir will enable logrotation to an off device directory whilst retaining only live logs in zram. Usually in /opt or /var, name optional.
# If you need multiple zram swaps or zram dirs just create another entry in /ect/ztab.
# Stop the service sudo service zram-config stop edit /etc/ztab sudo nano /etc/ztab start the service sudo service zram-config start

# swap  alg     mem_limit       disk_size       swap_priority   page-cluster    swappiness
swap    lz4     200M            600M            75              0               90

# dir   alg     mem_limit       disk_size       target_dir                      bind_dir
dir     lz4     150M            500M            /var/lib/openhab2/persistence   /persistence.bind
# do not enable as long as you make substantial config changes
#dir    lz4     30M             100M            /var/lib/openhab2/jsondb        /jsondb.bind

# log   alg     mem_limit       disk_size       target_dir                      bind_dir                oldlog_dir
log     lzo     150M            500M            /var/log                        /log.bind
[11:09:21] openhabian@oha2:~$ zramctl
[11:09:27] openhabian@oha2:~$ /usr/local/bin/zram-config start
+ ZSHARE=/usr/local/share/zram-config
+ ZLOG=/usr/local/share/zram-config/log/zram-config.log
+ ZDIR=/opt/zram
+ [[ -f /boot/cmdline.txt ]]
+ grep -q init=/bin/ro-root.sh /boot/cmdline.txt
+ ZEPHEMERAL=false
+ case "$1" in
++ date +%Y-%m-%d-%H:%M:%S
+ echo 'zram-config start 2020-07-28-11:09:57'
/usr/local/bin/zram-config: line 256: /usr/local/share/zram-config/log/zram-config.log: Permission denied
+ rm -f /usr/local/share/zram-config/zram-device-list.new
/usr/local/bin/zram-config: line 257: /usr/local/share/zram-config/log/zram-config.log: Permission denied
+ file=/etc/ztab
+ ZTAB_EMPTY=true
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ set -- swap lz4 200M 600M 75 0 90
+ echo 'ztab create swap lz4 200M 600M 75 0 90  '
/usr/local/bin/zram-config: line 274: /usr/local/share/zram-config/log/zram-config.log: Permission denied
+ ZTAB_EMPTY=false
+ ZTYPE=swap
+ ALG=lz4
+ MEM_SIZE=200M
+ DISK_SIZE=600M
+ '[' -f /usr/local/share/zram-config/zram-device-list ']'
+ test -f /usr/local/share/zram-config/zram-device-list.new
+ case "$1" in
+ PRIORITY=75
+ PAGE_CLUSTER=0
+ SWAPPINESS=90
+ createZswap
+ createZdevice
+ '[' '!' -d /sys/class/zram-control ']'
+ modprobe --verbose zram
/usr/local/bin/zram-config: line 85: /usr/local/share/zram-config/log/zram-config.log: Permission denied
+ return 1
+ return 1
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ set -- dir lz4 150M 500M /var/lib/openhab2/persistence /persistence.bind
+ echo 'ztab create dir lz4 150M 500M /var/lib/openhab2/persistence /persistence.bind   '
/usr/local/bin/zram-config: line 274: /usr/local/share/zram-config/log/zram-config.log: Permission denied
+ ZTAB_EMPTY=false
+ ZTYPE=dir
+ ALG=lz4
+ MEM_SIZE=150M
+ DISK_SIZE=500M
+ '[' -f /usr/local/share/zram-config/zram-device-list ']'
+ test -f /usr/local/share/zram-config/zram-device-list.new
+ case "$1" in
+ TARGET_DIR=/var/lib/openhab2/persistence
+ BIND_DIR=/persistence.bind
+ '[' false = false ']'
+ createZdir
+ '[' '!' -z /persistence.bind ']'
+ mkdir -p /opt/zram/persistence.bind
/usr/local/bin/zram-config: line 31: /usr/local/share/zram-config/log/zram-config.log: Permission denied
+ return 1
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ set -- log lzo 150M 500M /var/log /log.bind
+ echo 'ztab create log lzo 150M 500M /var/log /log.bind   '
/usr/local/bin/zram-config: line 274: /usr/local/share/zram-config/log/zram-config.log: Permission denied
+ ZTAB_EMPTY=false
+ ZTYPE=log
+ ALG=lzo
+ MEM_SIZE=150M
+ DISK_SIZE=500M
+ '[' -f /usr/local/share/zram-config/zram-device-list ']'
+ test -f /usr/local/share/zram-config/zram-device-list.new
+ case "$1" in
+ TARGET_DIR=/var/log
+ BIND_DIR=/log.bind
+ OLDLOG_DIR=
+ '[' false = false ']'
+ createZlog
+ invoke-rc.d rsyslog stop
/usr/local/bin/zram-config: line 66: /usr/local/share/zram-config/log/zram-config.log: Permission denied
+ return 1
+ read -r line
+ '[' false = true ']'
[11:09:57] openhabian@oha2:~$ date > /var/lib/openhab2/persistence/date
-bash: /var/lib/openhab2/persistence/date: Permission denied
[11:12:09] openhabian@oha2:~$ sudo date > /var/lib/openhab2/persistence/date
-bash: /var/lib/openhab2/persistence/date: Permission denied

that’s as far as i got, i don’t think it makes sense to proceed until permission problem is solved?

Duh. You must do everything as root. Do sudo bash first.

reboot first? :zipper_mouth_face:

no.

i hope it was not wrong to stop zram-config beofre starting zram-config with su…

[11:46:32] root@oha2:/home/openhabian# /usr/local/bin/zram-config start
+ ZSHARE=/usr/local/share/zram-config
+ ZLOG=/usr/local/share/zram-config/log/zram-config.log
+ ZDIR=/opt/zram
+ [[ -f /boot/cmdline.txt ]]
+ grep -q init=/bin/ro-root.sh /boot/cmdline.txt
+ ZEPHEMERAL=false
+ case "$1" in
++ date +%Y-%m-%d-%H:%M:%S
+ echo 'zram-config start 2020-07-28-11:47:51'
+ rm -f /usr/local/share/zram-config/zram-device-list.new
+ file=/etc/ztab
+ ZTAB_EMPTY=true
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ set -- swap lz4 200M 600M 75 0 90
+ echo 'ztab create swap lz4 200M 600M 75 0 90  '
+ ZTAB_EMPTY=false
+ ZTYPE=swap
+ ALG=lz4
+ MEM_SIZE=200M
+ DISK_SIZE=600M
+ '[' -f /usr/local/share/zram-config/zram-device-list ']'
+ test -f /usr/local/share/zram-config/zram-device-list.new
+ case "$1" in
+ PRIORITY=75
+ PAGE_CLUSTER=0
+ SWAPPINESS=90
+ createZswap
+ createZdevice
+ '[' '!' -d /sys/class/zram-control ']'
+ modprobe --verbose zram
+ RAM_DEV=0
+ '[' '!' -z 200M ']'
+ echo 200M
+ '[' '!' -z 600M ']'
+ echo 600M
+ '[' '!' -z lz4 ']'
+ echo lz4
+ echo 'zram0 created comp_algorithm=lz4 mem_limit=200M disksize=600M'
+ mkswap --label zram-config0 /dev/zram0
+ '[' '!' -z 75 ']'
+ swapon -v -p 75 /dev/zram0
+ '[' '!' -z 0 ']'
+ sysctl vm.page-cluster=0
+ '[' '!' -z 90 ']'
+ sysctl vm.swappiness=90
+ echo 'swap            /zram0          zram-config0'
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ set -- dir lz4 150M 500M /var/lib/openhab2/persistence /persistence.bind
+ echo 'ztab create dir lz4 150M 500M /var/lib/openhab2/persistence /persistence.bind   '
+ ZTAB_EMPTY=false
+ ZTYPE=dir
+ ALG=lz4
+ MEM_SIZE=150M
+ DISK_SIZE=500M
+ '[' -f /usr/local/share/zram-config/zram-device-list ']'
+ '[' dir = swap ']'
++ egrep 'dir.*/var/lib/openhab2/persistence' /usr/local/share/zram-config/zram-device-list
+ entry=
+ '[' -n '' ']'
+ test -f /usr/local/share/zram-config/zram-device-list.new
+ case "$1" in
+ TARGET_DIR=/var/lib/openhab2/persistence
+ BIND_DIR=/persistence.bind
+ '[' false = false ']'
+ createZdir
+ '[' '!' -z /persistence.bind ']'
+ mkdir -p /opt/zram/persistence.bind
+ '[' '!' -z /var/lib/openhab2/persistence ']'
++ stat -c %a /var/lib/openhab2/persistence
+ dirPerm=755
++ stat -c %u /var/lib/openhab2/persistence
+ dirUser=110
++ stat -c %g /var/lib/openhab2/persistence
+ dirGroup=115
+ echo 'dirPerm /var/lib/openhab2/persistence 755 110:115'
+ mount --verbose --bind /var/lib/openhab2/persistence/ /opt/zram/persistence.bind/
+ mount --verbose --make-private /opt/zram/persistence.bind/
++ awk -v a=/opt/zram/persistence.bind '$2 == a {print $4}' /proc/mounts
++ head -1
+ dirMountOpt=rw,noatime
++ awk -v a=/opt/zram/persistence.bind '$2 == a {print $3}' /proc/mounts
++ head -1
+ dirFsType=ext4
+ echo 'dirMountOpt rw,noatime dirFsType ' ext4
+ createZdevice
+ '[' '!' -d /sys/class/zram-control ']'
++ cat /sys/class/zram-control/hot_add
+ RAM_DEV=1
+ '[' '!' -z 150M ']'
+ echo 150M
+ '[' '!' -z 500M ']'
+ echo 500M
+ '[' '!' -z lz4 ']'
+ echo lz4
+ echo 'zram1 created comp_algorithm=lz4 mem_limit=150M disksize=500M'
+ mke2fs -v -t ext4 /dev/zram1
+ mkdir -p /opt/zram/zram1
+ mount --verbose --types ext4 -o rw,noatime /dev/zram1 /opt/zram/zram1/
+ mkdir -p /opt/zram/zram1/upper /opt/zram/zram1/workdir /var/lib/openhab2/persistence
+ mount --verbose --types overlay -o redirect_dir=on,lowerdir=/opt/zram/persistence.bind,upperdir=/opt/zram/zram1/upper,workdir=/opt/zram/zram1/workdir overlay1 /var/lib/openhab2/persistence
+ chown 110:115 /opt/zram/zram1/upper /opt/zram/zram1/workdir /var/lib/openhab2/persistence
+ chmod 755 /opt/zram/zram1/upper /opt/zram/zram1/workdir /var/lib/openhab2/persistence
+ echo 'dir             /zram1          /var/lib/openhab2/persistence           /persistence.bind'
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ continue
+ read -r line
+ case "$line" in
+ set -- log lzo 150M 500M /var/log /log.bind
+ echo 'ztab create log lzo 150M 500M /var/log /log.bind   '
+ ZTAB_EMPTY=false
+ ZTYPE=log
+ ALG=lzo
+ MEM_SIZE=150M
+ DISK_SIZE=500M
+ '[' -f /usr/local/share/zram-config/zram-device-list ']'
+ '[' log = swap ']'
++ egrep 'log.*/var/log' /usr/local/share/zram-config/zram-device-list
+ entry=
+ '[' -n '' ']'
+ test -f /usr/local/share/zram-config/zram-device-list.new
+ case "$1" in
+ TARGET_DIR=/var/log
+ BIND_DIR=/log.bind
+ OLDLOG_DIR=
+ '[' false = false ']'
+ createZlog
+ invoke-rc.d rsyslog stop
+ invoke-rc.d nginx stop
+ return 1
+ read -r line
+ '[' false = true ']'
[11:47:52] root@oha2:/home/openhabian# zramctl
NAME       ALGORITHM DISKSIZE  DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram1 lzo-rle       500M 16.4M  7.1K   88K       4 /opt/zram/zram1
/dev/zram0 lzo-rle       600M    4K   87B   12K       4 [SWAP]
[11:48:48] root@oha2:/home/openhabian# date > /var/lib/openhab2/persistence/date
[11:49:48] root@oha2:/home/openhabian# /usr/local/bin/zram-config stop
+ ZSHARE=/usr/local/share/zram-config
+ ZLOG=/usr/local/share/zram-config/log/zram-config.log
+ ZDIR=/opt/zram
+ [[ -f /boot/cmdline.txt ]]
+ grep -q init=/bin/ro-root.sh /boot/cmdline.txt
+ ZEPHEMERAL=false
+ case "$1" in
++ date +%Y-%m-%d-%H:%M:%S
+ echo 'zram-config stop 2020-07-28-11:49:58'
+ tac /usr/local/share/zram-config/zram-device-list
+ file=/usr/local/share/zram-config/zram-device-list.rev
+ read -r line
+ case "$line" in
+ set -- dir /zram1 /var/lib/openhab2/persistence /persistence.bind
+ echo 'ztab remove dir /zram1 /var/lib/openhab2/persistence /persistence.bind'
+ case "$1" in
+ ZTYPE=dir
+ ZRAM_DEV=/zram1
+ TARGET_DIR=/var/lib/openhab2/persistence
+ BIND_DIR=/persistence.bind
+ '[' false = false ']'
+ removeZdir
+ echo /zram1
++ echo /zram1
++ tr -dc 0-9
+ DEV_NUM=1
+ '[' '!' -z /var/lib/openhab2/persistence ']'
+ umount --verbose /var/lib/openhab2/persistence/
+ echo 'umount /var/lib/openhab2/persistence/'
+ mergeOverlay
+ '[' '!' -z /zram1 ']'
+ umount --verbose /opt/zram/zram1/
+ umount overlay1
umount: overlay1: no mount point specified.
+ rm -rv /opt/zram/zram1
+ '[' '!' -z /persistence.bind ']'
+ umount --verbose /opt/zram/persistence.bind/
+ rm -rv /opt/zram/persistence.bind
+ echo 1
+ /sbin/zramctl -r /dev/zram1
+ echo '/dev/zram1 removed'
+ read -r line
+ case "$line" in
+ set -- swap /zram0 zram-config0
+ echo 'ztab remove swap /zram0 zram-config0 '
+ case "$1" in
+ ZTYPE=swap
+ ZRAM_DEV=/zram0
+ LABEL=zram-config0
+ removeZswap
++ echo /zram0
++ tr -dc 0-9
+ DEV_NUM=0
+ swapoff /dev/zram0
+ echo 0
+ /sbin/zramctl -r /dev/zram0
+ echo '/dev/zram0 removed'
+ read -r line
+ rm -fv /usr/local/share/zram-config/zram-device-list.rev /usr/local/share/zram-config/zram-device-list
[11:49:58] root@oha2:/home/openhabian# zramctl
[11:50:21] root@oha2:/home/openhabian# cat /var/lib/openhab2/persistence/date
Tue 28 Jul 11:49:48 CEST 2020
[11:50:28] root@oha2:/home/openhabian# zram-config
+ ZSHARE=/usr/local/share/zram-config
+ ZLOG=/usr/local/share/zram-config/log/zram-config.log
+ ZDIR=/opt/zram
+ [[ -f /boot/cmdline.txt ]]
+ grep -q init=/bin/ro-root.sh /boot/cmdline.txt
+ ZEPHEMERAL=false
+ case "$1" in
+ echo 'Usage: zram-config {start|stop|sync|enable-ephemeral|disable-ephemeral}'
Usage: zram-config {start|stop|sync|enable-ephemeral|disable-ephemeral}
+ exit 1
[11:51:43] root@oha2:/home/openhabian# cat /usr/local/share/zram-config/log/zram-config.log
ztab remove dir /zram1 /var/lib/openhab2/persistence /persistence.bind
/zram1
umount /var/lib/openhab2/persistence/
+ echo 'overlay --lowerdir=/opt/zram/persistence.bind --upperdir=/opt/zram/zram1/upper'
overlay --lowerdir=/opt/zram/persistence.bind --upperdir=/opt/zram/zram1/upper
+ cd /usr/local/lib/zram-config/
+ echo y
+ ./overlay merge -l /opt/zram/persistence.bind -u /opt/zram/zram1/upper
The script overlay-tools-SNgQMz.sh is created. Run the script to do the actual work please. Remember to run it when the OverlayFS is not mounted.
+ sh -x overlay-tools-SNgQMz.sh
+ set -x
+ rm -rf /opt/zram/persistence.bind/date
+ mv -T /opt/zram/zram1/upper/date /opt/zram/persistence.bind/date
+ rmdir /opt/zram/zram1/upper
+ rm -v overlay-tools-SNgQMz.sh
removed 'overlay-tools-SNgQMz.sh'
umount: /opt/zram/zram1/ unmounted
removed directory '/opt/zram/zram1'
umount: /opt/zram/persistence.bind/ unmounted
removed directory '/opt/zram/persistence.bind'
/dev/zram1 removed
ztab remove swap /zram0 zram-config0
/dev/zram0 removed
removed '/usr/local/share/zram-config/zram-device-list.rev'
removed '/usr/local/share/zram-config/zram-device-list'

You messed up the order of commands I gave.
“cat …/date” must be AFTER zram-config stop. The point of that command is to see if the file is synced back when you stop ZRAM. Try again.

Something is wrong with your /var/log. It was not mounted as ZRAM and it does not get mounted either when you restart it. I think it’s because you have not setup nginx.
Retrieve the latest zram-config from the link again and retry the commands, but pay attention to the order this time.