openHABian - Mosquitto MQTT failed to start

check /opt/zram first and remove if exists
ls -l /opt/openHAB*
remove /opt/openHAB* then it should reinstall on reboot

[16:13:41] openhabian@openhab:/opt/zram$ rm /opt/zram
rm: cannot remove '/opt/zram': Is a directory
[16:14:27] openhabian@openhab:/opt/zram$ rmdir /opt/zram
rmdir: failed to remove '/opt/zram': Directory not empty
[16:15:20] openhabian@openhab:/opt/zram$ ls -la
total 32
drwxr-xr-x  8 root    root    4096 Jul 29 15:59 .
drwxrwxr-x  6 openhab openhab 4096 Jul 29 15:56 ..
drwxr-xr-x  9 root    root    4096 Jul 29 15:02 log.bind
drwxr-xr-x  5 root    root    4096 Jul 29 15:03 openhabian-zram
drwxr-xr-x  4 root    root    4096 Jul 29 15:03 overlayfs-tools
drwxrwxr-x+ 5 openhab openhab 4096 Jul 29 14:59 persistence.bind
drwxr-xr-x  5 root    root    4096 Jul 29 15:59 zram1
drwxr-xr-x  5 root    root    4096 Jul 29 15:59 zram2


[16:17:22] openhabian@openhab:~$ cd /opt/openhab
-bash: cd: /opt/openhab: No such file or directory
[16:17:39] openhabian@openhab:~$ cd /opt/openHAB*
-bash: cd: /opt/openHAB*: No such file or directory
[16:17:57] openhabian@openhab:~$ cd /opt/openHAB*
-bash: cd: /opt/openHAB*: No such file or directory
[16:18:44] openhabian@openhab:~$

rm -rf /opt/zram
doublecheck /boot/openhabian.conf for debugmode,
then reboot should trigger another install

[16:55:20] openhabian@openhab:~$ rm -rf /opt/zram
rm: cannot remove '/opt/zram/zram2': Permission denied
rm: cannot remove '/opt/zram/log.bind': Permission denied
rm: cannot remove '/opt/zram/zram1': Permission denied
rm: cannot remove '/opt/zram/persistence.bind': Permission denied
[16:55:31] openhabian@openhab:~$
[16:44:47] openhabian@openhab:~$ sudo rm -rf /opt/zram
[sudo] password for openhabian:
rm: cannot remove '/opt/zram/zram2': Device or resource busy
rm: cannot remove '/opt/zram/log.bind': Device or resource busy
rm: cannot remove '/opt/zram/zram1': Device or resource busy
rm: cannot remove '/opt/zram/persistence.bind': Device or resource busy
[16:45:04] openhabian@openhab:~$

Can i use openhabian-config to remove ?


# Modify your openHABian settings
# Handle with care, only touch if you need to!!

hostname=openhab
username=openhabian
userpw=openhabian

# Language and time. Be sure to set these to valid values
timeserver=0.pool.ntp.org
locales="en_US.UTF-8 de_DE.UTF-8"
system_default_locale="en_US.UTF-8"
#timezone=Europe/Berlin

# Wi-Fi settings. An ethernet connection is recommended
# Requirement: RPi3, RPi0W, PineA64 or a supported external Wi-Fi dongle
# Fill in your SSID and password below, leave empty to use ethernet
wifi_ssid=""
wifi_psk=""

# Wi-Fi setting. Select a two-letter country code suitable for your location
# E.g. US (default), DE, AU, NZ...
# You may infringe on local legislature otherwise
# See https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 or /usr/share/zoneinfo/zone.tab
wifi_country=""

# vim: filetype=sh
debugmode=maximum

as root of course:

sudo rm -rf /opt/zram /etc/ztab /opt/openHAB*

Then sudo reboot.

But this is getting complex.
If that does not result in reinstall, safest is to reflash

[17:03:18] openhabian@openhab:~$ sudo rm -rf /opt/zram /etc/ztab /opt/openHAB*
rm: cannot remove ā€˜/opt/zram/zram2ā€™: Device or resource busy
rm: cannot remove ā€˜/opt/zram/log.bindā€™: Device or resource busy
rm: cannot remove ā€˜/opt/zram/zram1ā€™: Device or resource busy
rm: cannot remove ā€˜/opt/zram/persistence.bindā€™: Device or resource busy
[17:07:15] openhabian@openhab:~$

Hello,
Unfortunately I have no idea what the problem is with the openhabian image recommended by the official site but with the help of Mr. Markus Storm I managed to make everything work.
I installed openhabian using the 32 bit image here and it worked from scratch on raspberry pi4 without any problems.
Mosquitto installs and runs perfectly - even after a restart.
It would be nice if someone could find the solution to this problem with the image recommended by openhab.org
Thanks for the help Markus Storm
All the best

The real issue here actually isnā€™t neither about Mosquitto nor ZRAM failing to initialize but related to the recent change in kernel version of Raspbian/RaspiOS.
Upgrading doesnā€™t work without an interim reboot.

Iā€™ve provided an official pre-release of the image at the openHABian download location.
(itā€™s the same as the one @dexterbot80 linked to but with the reboot built in)

1 Like

Markus

I used your pre-release and Iā€™m having the exact problems that Dexter has. The version on the web site is openhabian-pi-raspios32-202007302224 - but the version on Github that Dexter points to is openhabian-pi-raspios32-202007281750 which appears to be older.

Should I just use the older Github version? All I need is for the Mosquitto.service to run after a reboot.

The image version is not important as itā€™ll update itself to latest code anyway.
Just make sure that clonebranch=master in openhabian.conf
So try again with whatever recent image.

Yes did that, checked updates, reboot and same errors as above. Same output from systemctl and journalctl for mosquitto. Appears to linked to something to do with the filesystem with same error on accessing the mosquitto log file. I would copy all the logs, but they are exactly the same as above.

Just to add this is on a Pi4 4GB.

I just installed mosquitto on a box with the most current openHABian, no problem.
Start from scratch.

Will start again from scratch. It was a hard reboot (unpluged the wrong socket from wall plug :frowning: ). It worked perfectly till then. Openhab and most other things survived without a problem. Thanks for the support.

Hey. Downloaded the latest version of openhabian v1.6 (https://github.com/openhab/openhabian/releases/tag/v1.6) on RPI4 4GB. Installed Mosquitto via openhabian-config. In openhabe, I installed an MQTT broker and configured it. Its status is online. I checked the connection to mosquitto via Mqqt.fx, everything works. But after restarting RPI4, it writes the same error. Mosquitto wonā€™t start. Openhab does not see the server, nor does mqtt.fx. How to solve the problem?
in the logs everything is the same as in dexterbot80

If you installed the MQTT broker from within openHAB additionally, you have two brokers installed! You should have just created a MQTT Broker Thing (I e. the bridge to mosquirto)

made a mistake when writing. In openhub, I installed the mqtt binding

Hi Folks,

any progess on this subject? I also installed a brandnew Pi4B with 4 GB with the actual official openhabian image and have exactly the same issue (works fine until reboot; cannot find log-file).

which is not what @minorus wrote so it isnā€™t the same issue.
Properly state your problem if you want help.
What do systemctl status mosquitto.service and journalctl -xu mosquitto.service say?

I have just the same problem. I could not find a solution for mosquitto. I had to use embedded-mqtt-broker. There are no problems with him

Perhaps I used the wrong answer button. I refer to the start of this thread where @dexterbot80 wrote, that he had a fresh installation of openhabian from the official link, installed Mosquitto successfully through openhabian-config ending up with Mosquitto being unable to start after the first reboot caused by not beeing able to open the log-file, as the Mosquitto directory under var/log is not existing.

You helped him by guiding him to switch to the master version in openhabian-config, but as @Howard_Benn wrote, that did not help in my case either. And as this thread is some days old I hoped that there might be a solution now.

Here are the outputs you wanted, where you can see in journalctl, that the log-file is not available.

[08:22:45] openhabian@openhab2neu:~$ systemctl status mosquitto.service
ā— mosquitto.service - Mosquitto MQTT v3.1/v3.1.1 Broker
Loaded: loaded (/lib/systemd/system/mosquitto.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2020-11-04 08:19:29 CET; 3min 36s ago
Docs: man:mosquitto.conf(5)
man:mosquitto(8)
Process: 839 ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf (code=exited, status=1/FAILURE)
Main PID: 839 (code=exited, status=1/FAILURE)

Nov 04 08:19:29 openhab2neu systemd[1]: mosquitto.service: Service RestartSec=100ms expired, scheduling restart.
Nov 04 08:19:29 openhab2neu systemd[1]: mosquitto.service: Scheduled restart job, restart counter is at 5.
Nov 04 08:19:29 openhab2neu systemd[1]: Stopped Mosquitto MQTT v3.1/v3.1.1 Broker.
Nov 04 08:19:29 openhab2neu systemd[1]: mosquitto.service: Start request repeated too quickly.
Nov 04 08:19:29 openhab2neu systemd[1]: mosquitto.service: Failed with result ā€˜exit-codeā€™.
Nov 04 08:19:29 openhab2neu systemd[1]: Failed to start Mosquitto MQTT v3.1/v3.1.1 Broker.

 [08:23:46] openhabian@openhab2neu:~$ journalctl -xu mosquitto.service
    -- Logs begin at Tue 2020-11-03 08:20:43 CET, end at Wed 2020-11-04 08:25:01 CET. --
    Nov 03 18:15:42 openhab2neu systemd[1]: Starting Mosquitto MQTT v3.1/v3.1.1 Broker...
    -- Subject: A start job for unit mosquitto.service has begun execution
    -- Defined-By: systemd
    -- Support: https://www.debian.org/support
    --
    -- A start job for unit mosquitto.service has begun execution.
    --
    -- The job identifier is 109.
    Nov 03 18:15:43 openhab2neu mosquitto[504]: 1604423743: Error: Unable to open log file /var/log/mosquitto/mosquitto.log for writing.
    Nov 03 18:15:43 openhab2neu systemd[1]: mosquitto.service: Main process exited, code=exited, status=1/FAILURE
    -- Subject: Unit process exited
    -- Defined-By: systemd
    -- Support: https://www.debian.org/support
    --
    -- An ExecStart= process belonging to unit mosquitto.service has exited.
    --
    -- The process' exit code is 'exited' and its exit status is 1.
    Nov 03 18:15:43 openhab2neu systemd[1]: mosquitto.service: Failed with result 'exit-code'.
    -- Subject: Unit failed
    -- Defined-By: systemd
    -- Support: https://www.debian.org/support
    --
    -- The unit mosquitto.service has entered the 'failed' state with result 'exit-code'.
    Nov 03 18:15:43 openhab2neu systemd[1]: Failed to start Mosquitto MQTT v3.1/v3.1.1 Broker.
    -- Subject: A start job for unit mosquitto.service has failed
    -- Defined-By: systemd
    -- Support: https://www.debian.org/support
    --
    -- A start job for unit mosquitto.service has finished with a failure.
    --
    -- The job identifier is 109 and the job result is failed.
    Nov 03 18:15:43 openhab2neu systemd[1]: mosquitto.service: Service RestartSec=100ms expired, scheduling restart.
    Nov 03 18:15:43 openhab2neu systemd[1]: mosquitto.service: Scheduled restart job, restart counter is at 1.
    -- Subject: Automatic restarting of a unit has been scheduled
    -- Defined-By: systemd
    -- Support: https://www.debian.org/support
    --
    -- Automatic restarting of the unit mosquitto.service has been scheduled, as the result for
    -- the configured Restart= setting for the unit.
    Nov 03 18:15:43 openhab2neu systemd[1]: Stopped Mosquitto MQTT v3.1/v3.1.1 Broker.
    -- Subject: A stop job for unit mosquitto.service has finished
    -- Defined-By: systemd
    -- Support: https://www.debian.org/support
    --
    -- A stop job for unit mosquitto.service has finished.
    --
    -- The job identifier is 263 and the job result is done.
    Nov 03 18:15:43 openhab2neu systemd[1]: Starting Mosquitto MQTT v3.1/v3.1.1 Broker...
    -- Subject: A start job for unit mosquitto.service has begun execution
    -- Defined-By: systemd
    -- Support: https://www.debian.org/support
    --
    -- A start job for unit mosquitto.service has begun execution.
    --
    -- The job identifier is 263.
    Nov 03 18:15:43 openhab2neu mosquitto[597]: 1604423743: Error: Unable to open log file /var/log/mosquitto/mosquitto.log for writing.
    Nov 03 18:15:43 openhab2neu systemd[1]: mosquitto.service: Main process exited, code=exited, status=1/FAILURE
    -- Subject: Unit process exited
    -- Defined-By: systemd
    -- Support: https://www.debian.org/support
    --
    -- An ExecStart= process belonging to unit mosquitto.service has exited.
    --
    -- The process' exit code is 'exited' and its exit status is 1.
    Nov 03 18:15:43 openhab2neu systemd[1]: mosquitto.service: Failed with result 'exit-code'.
    -- Subject: Unit failed
    -- Defined-By: systemd
    -- Support: https://www.debian.org/support
    --
    -- The unit mosquitto.service has entered the 'failed' state with result 'exit-code'.
    Nov 03 18:15:43 openhab2neu systemd[1]: Failed to start Mosquitto MQTT v3.1/v3.1.1 Broker.
    -- Subject: A start job for unit mosquitto.service has failed
    -- Defined-By: systemd
    -- Support: https://www.debian.org/support
    --
    -- A start job for unit mosquitto.service has finished with a failure.
    --
    -- The job identifier is 263 and the job result is failed.
    Nov 03 18:15:43 openhab2neu systemd[1]: mosquitto.service: Service RestartSec=100ms expired, scheduling restart.
    Nov 03 18:15:43 openhab2neu systemd[1]: mosquitto.service: Scheduled restart job, restart counter is at 2.
    -- Subject: Automatic restarting of a unit has been scheduled
    -- Defined-By: systemd
    -- Support: https://www.debian.org/support