0

I have a custom package for service which works fine on Debian10. I want run it on Debian11 or Ubuntu 22 but mount commands in ExecStartPre does not works. Or better they are executed without errors but mount points are not available. When I execute mount commands manually and then start service it looks good. But when server is restarted service cannot start due to missing mount points. Below is small snippet from file:

[Service]
...
ExecStartPre=-mount -o bind,ro /etc/myservice /chroot/%i/etc/myservice.d
ExecStart=/usr/sbin/myservice-%i -n -f /etc/myservice.d/myservice-%i.conf
....

Any idea why mount commands are ignored?

Edit:

It works fine with systemd 245.4-4ubuntu3.18 but when I upgrade to 249.11-0ubuntu3.4 I can't mount anymore. Exit code for commands is "status=0/SUCCESS". Debug mode report more entries than on the previous version of systemd (not sure if logging was extended)

Sep 29 15:44:48 myhostname systemd[18647]: Bind-mounting / on /run/systemd/unit-root (MS_BIND|MS_REC "")...
Sep 29 15:44:48 myhostname systemd[18647]: Applying namespace mount on /run/systemd/unit-root/run/credentials
Sep 29 15:44:48 myhostname systemd[18647]: Successfully unmounted /run/systemd/unit-root/run/credentials/systemd-sysusers.service
Sep 29 15:44:48 myhostname systemd[18647]: Bind-mounting /run/systemd/inaccessible/dir on /run/systemd/unit-root/run/credentials (MS_BIND|MS_REC "")...
Sep 29 15:44:48 myhostname systemd[18647]: Successfully mounted /run/systemd/inaccessible/dir to /run/systemd/unit-root/run/credentials
Sep 29 15:44:48 myhostname systemd[18647]: Applying namespace mount on /run/systemd/unit-root/run/systemd/incoming
Sep 29 15:44:48 myhostname systemd[18647]: Followed source symlinks /run/systemd/propagate/myservice → /run/systemd/propagate/myservice.
Sep 29 15:44:48 myhostname systemd[18647]: Bind-mounting /run/systemd/propagate/myservice on /run/systemd/unit-root/run/systemd/incoming (MS_BIND "")...
Sep 29 15:44:48 myhostname systemd[18647]: Successfully mounted /run/systemd/propagate/myservice to /run/systemd/unit-root/run/systemd/incoming
Sep 29 15:44:48 myhostname systemd[18647]: Remounted /run/systemd/unit-root/run/credentials.
Sep 29 15:44:48 myhostname systemd[18647]: Remounted /run/systemd/unit-root/run/systemd/incoming.
Sep 29 15:44:48 myhostname systemd[18647]: Remounted /run/systemd/unit-root/run/credentials

Basic folder structure is created with jailtool what is old package but I tried same with jailkit with same result.

Start/restart/stop of service was done with root user.

2 Answers 2

1

At the end I had to define MountAPIVFS to false to be able see mount points.

0

What status or error code of the mount command do you see in the output of systemctl status for this service?

Does your service switch to a different user, so that the mount command does not run with the required (root?) privileges? In this case you can prefix your ExecStartPre command with an "+" sign, like this:

ExecStartPre=+/sbin/mount -o bind,ro /etc/myservice /chroot/%i/etc/myservice.d

You must log in to answer this question.

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