2

I am trying to test how the BindPaths= directive works on a Debian 8 system with systemd.

Currently I have a basic unit file for a service:

[Unit]
Description="Simple Test Service"
BindPaths=/path:/bindmount/path:norbind

[Service]
ExecStart=/usr/bin/long_running_program --flags
Restart=always

[Install]
WantedBy=multi-user.target

When I run findmnt before and after starting the service I do not see the bind mount at /bindmount/path listed at all.

When I ls or ls -a the bind mount location /bindmount/path I do not see any files that are in /path.

Why is this not working as expected?

I see in the systemd BindPath= man page it says:

This option is only available for system services and is not supported for services running in per-user instances of the service manager.

How do I know if I am running in a per-user instance of the service manager vs running a system service? Is it based on if my service is located in /etc/systemd/system vs /lib/systemd/system?

1 Answer 1

0

The BindPaths option make the file visible to the process ran by the unit. This is not visible at all from the shell where you type the command to start the service. At any moment you may check what file systems are mounted looking at /proc/mounts, but if you run a service with BindPaths, I think the only way to check if the file system is correctly mounted is to check /proc/pid-of-service/mounts. The latter is the list of mounted file system for that process.

About your final questions: /lib/systemd/system contains all normal unit files, while /etc/systemd/system contains custom unit files and all dependencies between units. Per user instances are run with systemctl --user and refers to unit files in the home directory tree.

4
  • I do not see them in /proc/PID/mounts as well. :( BindPaths=/etc/node/confs/.apt:/etc/node/.apt/confs Jul 24, 2023 at 14:26
  • 1
    Might it be that you are running it as user service? What do the commands "systemctl status yourserviceunitname" and "systemctl --user status yourserviceunitname" print?
    – eppesuig
    Jul 25, 2023 at 15:19
  • Failed to connect to bus: $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR not defined (consider using --machine=<user>@.host --user to connect to bus of other user). I do specify the user and group I create to run the service. Jul 26, 2023 at 7:58
  • What is the complete pathname of your unit file? What is the exact and complete command line you use for starting it?
    – eppesuig
    Jul 27, 2023 at 8:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .