[GH-ISSUE #4392] Directory /var/log/netbird should get created on each start if does not exist #9275

Open
opened 2026-08-05 01:21:33 -04:00 by saavagebueno · 4 comments
Owner

Originally created by @MichaelUray on GitHub (Aug 22, 2025).
Original GitHub issue: https://github.com/netbirdio/netbird/issues/4392

To check what happened I removed all the directories and re-installed everything:

root@r1:~# ls -l /var/lib/netbird /var/log/netbird
ls: /var/lib/netbird: No such file or directory
ls: /var/log/netbird: No such file or directory
root@r1:~# netbird service install --service-env="NB_CONFIG=/etc/netbird/config.json"
NetBird service has been installed

It looks the directory /var/log/netbird gets only created when the service gets installed:

root@r1:~# ls -l /var/lib/netbird /var/log/netbird
ls: /var/lib/netbird: No such file or directory
/var/log/netbird:
root@r1:~# netbird service start
NetBird service has been started

/var/lib/netbird gets created on each start of the Netbird process and I think the same should happen for /var/log/netbird.

root@r1:~# ls -l /var/lib/netbird /var/log/netbird
/var/lib/netbird:
-rw-------    1 root     root            45 Aug 22 09:37 active_profile.json
-rw-r--r--    1 root     root            58 Aug 22 09:37 resolv.conf
-rw-------    1 root     root           236 Aug 22 09:37 state.json

/var/log/netbird:
-rw-r--r--    1 root     root          5322 Aug 22 09:37 client.log
-rw-r--r--    1 root     root             0 Aug 22 09:37 netbird.err
-rw-r--r--    1 root     root             0 Aug 22 09:37 netbird.log

Originally posted by @MichaelUray in #4322

The directory /var/log/netbird only gets created during the installation of the service, but not later during the start of the service process, which could cause problems on systems with volatile /var directories like OpenWRT.
I think /var/log/netbird should get created on each start if it does not exist.

Originally created by @MichaelUray on GitHub (Aug 22, 2025). Original GitHub issue: https://github.com/netbirdio/netbird/issues/4392 > To check what happened I removed all the directories and re-installed everything: > ``` > root@r1:~# ls -l /var/lib/netbird /var/log/netbird > ls: /var/lib/netbird: No such file or directory > ls: /var/log/netbird: No such file or directory > ``` > > ``` > root@r1:~# netbird service install --service-env="NB_CONFIG=/etc/netbird/config.json" > NetBird service has been installed > ``` > > It looks the directory `/var/log/netbird` gets only created when the service gets installed: > ``` > root@r1:~# ls -l /var/lib/netbird /var/log/netbird > ls: /var/lib/netbird: No such file or directory > /var/log/netbird: > ``` > > ``` > root@r1:~# netbird service start > NetBird service has been started > ``` > > `/var/lib/netbird` gets created on each start of the Netbird process and I think the same should happen for `/var/log/netbird`. > ``` > root@r1:~# ls -l /var/lib/netbird /var/log/netbird > /var/lib/netbird: > -rw------- 1 root root 45 Aug 22 09:37 active_profile.json > -rw-r--r-- 1 root root 58 Aug 22 09:37 resolv.conf > -rw------- 1 root root 236 Aug 22 09:37 state.json > > /var/log/netbird: > -rw-r--r-- 1 root root 5322 Aug 22 09:37 client.log > -rw-r--r-- 1 root root 0 Aug 22 09:37 netbird.err > -rw-r--r-- 1 root root 0 Aug 22 09:37 netbird.log > ``` _Originally posted by @MichaelUray in [#4322](https://github.com/netbirdio/netbird/issues/4322#issuecomment-3213456500)_ The directory `/var/log/netbird` only gets created during the installation of the service, but not later during the start of the service process, which could cause problems on systems with volatile `/var` directories like OpenWRT. I think `/var/log/netbird` should get created on each start if it does not exist.
Author
Owner

@nazarewk commented on GitHub (Aug 22, 2025):

There are a lot of use cases where the NetBird client daemon does not have sufficient permissions to create this directory. It is usually handled through the service manager.

Do you observe any problems when the directory is missing?

<!-- gh-comment-id:3213562390 --> @nazarewk commented on GitHub (Aug 22, 2025): There are a lot of use cases where the NetBird client daemon does not have sufficient permissions to create this directory. It is usually handled through the service manager. Do you observe any problems when the directory is missing?
Author
Owner

@MichaelUray commented on GitHub (Aug 22, 2025):

Do you observe any problems when the directory is missing?

Yes, the service does not start, I described there the details:

https://github.com/netbirdio/netbird/issues/4322#issuecomment-3213456500

root@r1:~# /etc/init.d/netbird start
Starting netbird
/etc/init.d/netbird: line 43: can't create /var/log/netbird/netbird.log: nonexistent directory
Unable to start, see /var/log/netbird/netbird.log and /var/log/netbird/netbird.err
<!-- gh-comment-id:3214353437 --> @MichaelUray commented on GitHub (Aug 22, 2025): > Do you observe any problems when the directory is missing? Yes, the service does not start, I described there the details: https://github.com/netbirdio/netbird/issues/4322#issuecomment-3213456500 ``` root@r1:~# /etc/init.d/netbird start Starting netbird /etc/init.d/netbird: line 43: can't create /var/log/netbird/netbird.log: nonexistent directory Unable to start, see /var/log/netbird/netbird.log and /var/log/netbird/netbird.err ```
Author
Owner

@wehagy commented on GitHub (Aug 24, 2025):

I don't use the netbird service install, but manipulating the /etc/init.d/netbird from the OpenWrt work's for me(restarted the service, the router, and manually removed the file more than one time and is working):

root@OpenWrt:~# rm -rf /var/log/netbird /var/lib/netbird
root@OpenWrt:~# ls -la /var/lib/netbird /var/log/netbird
ls: /var/lib/netbird: No such file or directory
ls: /var/log/netbird: No such file or directory
root@OpenWrt:~# ls -la /etc/netbird/
drwxr-x---    2 root     root          1024 Aug 24 21:25 .
drwxr-xr-x    1 root     root          1024 Aug 24 21:23 ..
-rw-------    1 root     root          1715 Aug 24 21:23 hello-there.json
root@OpenWrt:~# cat /etc/init.d/netbird
#!/bin/sh /etc/rc.common

START=99
STOP=10

USE_PROCD=1

start_service() {
	procd_open_instance
	procd_set_param command /usr/bin/netbird
	procd_set_param env NB_CONFIG="/etc/netbird/hello-there.json" <<< SEE HERE 
	procd_append_param command service run
	procd_set_param pidfile /var/run/netbird.pid
	procd_close_instance
}
root@OpenWrt:~# service netbird start
root@OpenWrt:~# netbird status -A
OS: linux/amd64
Daemon version: 0.54.2
CLI version: 0.54.2
Profile: default
Management: Connected
Signal: Connected
Relays: 4/4 Available
Nameservers: 0/1 Available
FQDN: OpenWrt.netbird.cloud
NetBird IP: 100.127.32.225/16
Interface type: Kernel
Quantum resistance: false
Lazy connection: false
Networks: 198.51.100.0/24
Forwarding rules: 0
Peers count: 1/4 Connected
root@OpenWrt:~# ls -la /var/log/netbird/ /var/lib/netbird/
/var/lib/netbird/:
drwxr-x---    2 root     root            80 Aug 24 21:29 .
drwxr-xr-x    4 root     root            80 Aug 24 21:29 ..
-rw-------    1 root     root            45 Aug 24 21:29 active_profile.json
-rw-------    1 root     root           184 Aug 24 21:29 state.json

/var/log/netbird/:
drwxr--r--    2 root     root            60 Aug 24 21:29 .
drwxr-xr-x    3 root     root           100 Aug 24 21:29 ..
-rw-r--r--    1 root     root          8932 Aug 24 21:29 client.log
<!-- gh-comment-id:3218515171 --> @wehagy commented on GitHub (Aug 24, 2025): I don't use the `netbird service install`, but manipulating the `/etc/init.d/netbird` from the OpenWrt work's for me(restarted the service, the router, and manually removed the file more than one time and is working): ```shell root@OpenWrt:~# rm -rf /var/log/netbird /var/lib/netbird root@OpenWrt:~# ls -la /var/lib/netbird /var/log/netbird ls: /var/lib/netbird: No such file or directory ls: /var/log/netbird: No such file or directory ``` ```shell root@OpenWrt:~# ls -la /etc/netbird/ drwxr-x--- 2 root root 1024 Aug 24 21:25 . drwxr-xr-x 1 root root 1024 Aug 24 21:23 .. -rw------- 1 root root 1715 Aug 24 21:23 hello-there.json ``` ```shell root@OpenWrt:~# cat /etc/init.d/netbird #!/bin/sh /etc/rc.common START=99 STOP=10 USE_PROCD=1 start_service() { procd_open_instance procd_set_param command /usr/bin/netbird procd_set_param env NB_CONFIG="/etc/netbird/hello-there.json" <<< SEE HERE procd_append_param command service run procd_set_param pidfile /var/run/netbird.pid procd_close_instance } ``` ```shell root@OpenWrt:~# service netbird start root@OpenWrt:~# netbird status -A OS: linux/amd64 Daemon version: 0.54.2 CLI version: 0.54.2 Profile: default Management: Connected Signal: Connected Relays: 4/4 Available Nameservers: 0/1 Available FQDN: OpenWrt.netbird.cloud NetBird IP: 100.127.32.225/16 Interface type: Kernel Quantum resistance: false Lazy connection: false Networks: 198.51.100.0/24 Forwarding rules: 0 Peers count: 1/4 Connected root@OpenWrt:~# ls -la /var/log/netbird/ /var/lib/netbird/ /var/lib/netbird/: drwxr-x--- 2 root root 80 Aug 24 21:29 . drwxr-xr-x 4 root root 80 Aug 24 21:29 .. -rw------- 1 root root 45 Aug 24 21:29 active_profile.json -rw------- 1 root root 184 Aug 24 21:29 state.json /var/log/netbird/: drwxr--r-- 2 root root 60 Aug 24 21:29 . drwxr-xr-x 3 root root 100 Aug 24 21:29 .. -rw-r--r-- 1 root root 8932 Aug 24 21:29 client.log ```
Author
Owner

@dark-penguin commented on GitHub (May 15, 2026):

This would really be a welcome change! I'm keeping my /var/log in tmpfs, so I have to remember to fix the Netbird systemd service after installing it, otherwise it will not start after a reboot.

A simple solution would be to add a small config to /etc/tmpfiles.d/ (just include it in the package) that ensures that this directory always exists.

UPDATE: ...Or simply create the directory in the systemd service right before using it.

<!-- gh-comment-id:4462625939 --> @dark-penguin commented on GitHub (May 15, 2026): This would really be a welcome change! I'm keeping my /var/log in tmpfs, so I have to remember to fix the Netbird systemd service after installing it, otherwise it will not start after a reboot. A simple solution would be to add a small config to /etc/tmpfiles.d/ (just include it in the package) that ensures that this directory always exists. UPDATE: ...Or simply create the directory in the systemd service right before using it.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#9275