RXTX fhs_lock() Error: opening lock file: /var/lock/LCK..ttyUSB0: File exists. It is mine

I had been running OH as root when seeing this, but I recently changed to using an opehab account and found an issue that could be related. I mentioned this here. Check the permissions of /run/lock to see if the account running OH can’t write the lock file. If not, here is what I did…

Add openhab user to the lock group:

#usermod -a -G lock openhab

Verify membership:

#id openhab
uid=964(openhab) gid=963(openhab) groups=963(openhab),5(tty),18(dialout),54(lock)

Temporarily change group owner of /run/lock and add group write permission to see if this fix will work for you

#chown root:lock /run/lock
#chmod g+w lock

The /run/lock is recreated after each restart, so you need to make this change to set the group owner of /run/lock and add the group write permission:

#vi /usr/lib/tmpfiles.d/legacy.conf

Look for this line:

d /run/lock 0755 root root -

Comment it out (add a hash symbol before it) and insert a new line with:

d /run/lock 0775 root lock -

Save. Restart openHAB and verify functionality. Upon reboot, the permissions on /run/lock should be set with ownership root:lock and permission mask 775. I’m still investigating this, but I think it may be a new issue. I’m currently on 1330 and have not seen this issue again.

2 Likes