[systemd-devel] How to add a dependency to a systemd.mount that is activated by /bin/mount?

Lennart Poettering lennart at poettering.net
Mon Sep 30 19:08:51 PDT 2013


On Wed, 25.09.13 01:11, Tim Landscheidt (tim at tim-landscheidt.de) wrote:

> On "mount /mnt/test", however, "systemctl status
> mnt-test.mount mount-wrapper" shows the latter service being
> "inactive (dead)", while the former is "active (mounted)".
> 
> How can I (or can I not?) set up a dependency that is hon-
> oured when /bin/mount is called as well?  The status of the
> mount unit shows that "mount /mnt/test" seems to be trans-
> lated to "ExecMount=/bin/mount /dev/$DEVICE /mnt/test -t
> auto -o noauto,user", so apparently systemd gets notified.

This cannot work really and is not supported.

/bin/mount more or less just invokes the mount() syscall internally. The
kernel then does its thing and doesn't give systemd any time to do
anything before that. And that's good that way, because we never want
the kernel to wait for userspace...

Or to say this with different words: in a way systemd is simply a
scheduler for /bin/mount invocations by means of the .mount units. A
corollary of that is that it is systemd which defers to /bin/mount for
the actual mounting and not /bin/mount that deferes to systemd. If
they'd defer to each other nothing would do anything or we'd have a
cyclic dep/deadlock...

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list