[SOLVED] /var/lib/openhab2 gone

I am just trying to help. Try rebuilding the package cache?
https://sites.google.com/site/longphanwiki/basic-skills/ubuntu-linux

in the name of science I’ve done reinstall of 2.5M2 (sudo apt reinstall openhab2) which resulted in working gui which shown 2.5 M2 as well as openhab-cli info

and after restart it’s 2.4 again, failing to start

something is changing permissions into /var/lib/openhab2 befween reboots

openhabian@openhab:~ $ openhab-cli info

Version:     2.4.0 (Build)

User:        openhab (Active Process 589)
User Groups: openhab tty dialout audio bluetooth gpio

Directories: Folder Name      | Path                        | User:Group
             -----------      | ----                        | ----------
             OPENHAB_HOME     | /usr/share/openhab2         | openhab:openhab
             OPENHAB_RUNTIME  | /usr/share/openhab2/runtime | openhab:openhab
             OPENHAB_USERDATA | /var/lib/openhab2           | openhab:openhab
             OPENHAB_CONF     | /etc/openhab2               | openhab:openhab
             OPENHAB_LOGDIR   | /var/log/openhab2           | openhab:openhab

URLs:        http://10.10.1.5:8080
             https://10.10.1.5:8443

openhabian@openhab:~ $ hostnamectl
   Static hostname: openhab
         Icon name: computer
        Machine ID: 97be99ca7d444a6e947e00caf4b3e3f9
           Boot ID: 2c5f9cea647740869b96d7715c2ec676
  Operating System: Raspbian GNU/Linux 10 (buster)
            Kernel: Linux 4.19.58-v7+
      Architecture: arm
openhabian@openhab:~ $ sudo reboot
Connection to 10.10.1.5 closed by remote host.
Connection to 10.10.1.5 closed.
kriznik@GMNG:~$ tv
Linux openhab 4.19.58-v7+ #1245 SMP Fri Jul 12 17:25:51 BST 2019 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Fri Aug  9 20:39:40 2019 from 10.10.1.100
openhabian@openhab:~ $ openhab-cli info

Version:     2.4.0 (Build)

User:        openhab (Active Process 590)
User Groups: openhab tty dialout audio bluetooth gpio

Directories: Folder Name      | Path                        | User:Group
             -----------      | ----                        | ----------
             OPENHAB_HOME     | /usr/share/openhab2         | openhab:openhab
             OPENHAB_RUNTIME  | /usr/share/openhab2/runtime | openhab:openhab
             OPENHAB_USERDATA | /var/lib/openhab2           | root:root
             OPENHAB_CONF     | /etc/openhab2               | openhab:openhab
             OPENHAB_LOGDIR   | /var/log/openhab2           | openhab:openhab

URLs:        http://10.10.1.5:8080
             https://10.10.1.5:8443

openhabian@openhab:~ $

edit: hmm it just looks like whole /var/lib/openhab2 is whiped out when reboot, so new folder is created empty by root after restart
because my test backup I’ve made on 2.5M2 after force reinstall is gone

If you enabled zram then /var/lib/openhab2 is in RAM.
You must properly shutdown your box in order for its contents to get synced to disk.
service zram-config stop
umount /var/lib/oepnhab2
(both of which should be executed if you properly shutdown instead of blindly typing “reboot”).

well reboot is standard server command which should not corrupt installed apps.
and which is executing proper restart sequence.

what if there will be power outage? which I believe time to time just happends and not always will UPS hold long enough. Then there will be corrupted /var/lib/openhab2 too?
:thinking:

That’s simply wrong. It skips properly shutting down the running services.

As zram dirs should be synced to disk when you properly shutdown this is the state you should find the dirs in.

… so what’s correct way then, when system command which reboots system is not the one?

for another round of science I’ve done another reinstall, verified that everything is 2.5M2
then i’ve stopped zram with sudo service zram-config stop
unfortunately there was nothing to umount as /var/lib/openhab2 was not mountpoint anywhere
and then rebooted

and after logging back 2.4 again :wink:

I know I’m just blindly rebooting system, but I would like to know how this should be done then

well… reboot uses shutdown -r , so what you are exactly pointing on?

I’m inclined to agree with @kriznik here, a command shutdown or reboot (which will stop these services) should absolutely not cause loss or reset of data.

If the command you use truely properly call service shutdown scripts, yes. Reboot usually doesn’t.

ok @mstormi please share with us that secret command which will not corupt openhabian zram

because I tend to believe relevant way to reboot linux is shutdown -r aka reboot

i’ve stopped zram manually before reboot as well resulting in same corrupted OH as without

It’s the same binary yes but behavior depends on how it’s called. It’s confusing I know. But just type in those two commands and you should notice the difference (shutdown -r will wait for a minute).

how exactly? did you check if files were there and zram really was gone ?

I’m certainly sure that this is not the issue
but for another science I’ve done what you recommended:

openhabian@openhab:~ $ openhab-cli info

Version:     2.5.0.M2 (Build)

User:        openhab (Active Process 3288)
User Groups: openhab tty dialout audio bluetooth gpio

Directories: Folder Name      | Path                        | User:Group
             -----------      | ----                        | ----------
             OPENHAB_HOME     | /usr/share/openhab2         | openhab:openhab
             OPENHAB_RUNTIME  | /usr/share/openhab2/runtime | openhab:openhab
             OPENHAB_USERDATA | /var/lib/openhab2           | openhab:openhab
             OPENHAB_CONF     | /etc/openhab2               | openhab:openhab
             OPENHAB_LOGDIR   | /var/log/openhab2           | openhab:openhab

URLs:        http://10.10.1.5:8080
             https://10.10.1.5:8443

openhabian@openhab:~ $ sudo shutdown -r
Shutdown scheduled for Sat 2019-08-10 10:42:43 CEST, use 'shutdown -c' to cancel.
openhabian@openhab:~ $ Connection to 10.10.1.5 closed by remote host.
Connection to 10.10.1.5 closed.
kriznik@GMNG:~$ tv
Linux openhab 4.19.58-v7+ #1245 SMP Fri Jul 12 17:25:51 BST 2019 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Fri Aug  9 20:39:40 2019 from 10.10.1.100
openhabian@openhab:~ $ openhab-cli info

Version:     2.4.0 (Build)

User:        openhab (Active Process 588)
User Groups: openhab tty dialout audio bluetooth gpio

Directories: Folder Name      | Path                        | User:Group
             -----------      | ----                        | ----------
             OPENHAB_HOME     | /usr/share/openhab2         | openhab:openhab
             OPENHAB_RUNTIME  | /usr/share/openhab2/runtime | openhab:openhab
             OPENHAB_USERDATA | /var/lib/openhab2           | root:root
             OPENHAB_CONF     | /etc/openhab2               | openhab:openhab
             OPENHAB_LOGDIR   | /var/log/openhab2           | openhab:openhab

URLs:        http://10.10.1.5:8080
             https://10.10.1.5:8443

openhabian@openhab:~ $

and 2.4 again

Yes, I‘ve enabled ZRAM (why? :slight_smile:). Rebooting was done with reboot command from ssh. Also toggling the power(I know that this is bad) caused same effect.
BTW might be worth adding correct reboot command to dashboard, like many routers are doing? It was first thing I looked in configuration page and found nothing.

Good because that’s what I’m worried about. Just tested on my own box with a fresh install from image and it works as designed (BTW even with “reboot” but that does not mean you should use it).

See above. You mustn’t use “reboot” or even pull the power plug.

Definitely not. openHABian is not a router or anything similar. It’s producing data that needs to be safely and permanently stored which is why you must shutdown it correctly to sync that data.
And you shouldn’t reboot at all. Under normal circumstances there is no need to, openHAB(ian) is designed to run 24/7.
Adding that to the dashboard would just make more people hit the button without a need to (which usually creates more trouble than it resolves).

well this is as well fresh instalation from yesterday, only thing which I’ve done to it is changed repo to 2.5M2 & zram enable & upgrade

So… that being said, what is troubleshoot procedure now?

Even if OH doesn‘t need reboots or shutdowns, the other services and hardware, connected to same Server might require it, especially when one changes settings and configs. In my case after it I have to take Z-stick and SD card out for backup, so I will need to shutdown OH properly.

So what is the right command?

You’re funny. This is not a commercial service with proven procedures let alone on an experimental feature…

I’m aware of that, sometimes it’s enough to say “I don’t know” but as you tried to point out that I’m not capable of rebooting properly I was keen to see what your magic solution is.

well, I’ll figure it out self then

(and because it is happening on two independed rpis running zram and 1.5openhabian I hardly believe your’s magically works out of the box)