Re: [PATCH] bluez5: install /var/lib/bluetooth directory

Stefan Herbrechtsmeier

Am 08.04.2022 um 22:03 schrieb Markus Volk via
also had this issue and found out, that the bluetooth service did come up, once bluetooth was enabled
My fix was to edit like this
The colon ensures that the service won't fail if the directory doesn't exist
Regarding the documentation the ReadOnlyPaths and ReadWritePaths makes not sense because ProtectSystem=full mounts /usr, boot loader and /etc directories read-only.

Have somebody report the problem to the bluez project?


Am 08.04.22 um 13:01 schrieb Yi Zhao:

On 4/8/22 18:51, Stefan Herbrechtsmeier wrote:
Am 08.04.2022 um 11:23 schrieb Yi Zhao:

On 4/8/22 16:34, Stefan Herbrechtsmeier wrote:
Am 08.04.2022 um 10:15 schrieb Yi Zhao via
There is a bluetooth service startup failure:
bluetooth.service: Failed at step NAMESPACE spawning /usr/libexec/bluetooth/bluetoothd: No such file or directory
bluetooth.service: Failed to set up mount namespacing: /run/systemd/unit-root/var/lib/bluetooth: No such file or directory

This is because the directory /var/lib/bluetooth has been listed in
ReadWritePaths= in the service unit file but does not exist. We need to
create it before service startup.

Signed-off-by: Yi Zhao <yi.zhao@...>
  meta/recipes-connectivity/bluez5/ | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/meta/recipes-connectivity/bluez5/ b/meta/recipes-connectivity/bluez5/
index 79d4645ca8..ee2cdbcc59 100644
--- a/meta/recipes-connectivity/bluez5/
+++ b/meta/recipes-connectivity/bluez5/
@@ -102,6 +102,8 @@ do_install:append() {
      # Patch python tools to use Python 3; they should be source compatible, but
      # still refer to Python 2 in the shebang
      sed -i -e '1s,#!.*python.*,#!${bindir}/python3,' ${D}${libdir}/bluez/test/*
+    install -d ${D}${localstatedir}/lib/bluetooth
Please use systemd StateDirectory= [1]. Maybe it is reasonable to replace the ReadWritePaths= with StateDirectory=.


Thanks Stefank, but the ReadWritePaths= is set by bluez:
And who creates the directory before the patch?
There is no need this directory before the patch. The service can startup without this directory.

The systemd solution to create a state directory is StateDirectory= (or tmpfiles.d for older versions of systemd). Systemd supports stateless system [1] and therefore every service must work with an empty /var/lib.

I'll try adding StateDirecotry to service unit file to  see if this can solve the problem.  Thanks.


This patch hide a bug in bluez and the problem should be fixed in bluez.


Join to automatically receive all group messages.