I wanted to have a custom service unit depend on a mounting point of a remote filesystem CVMFS. The remote filesystem has a strange setup in systemd which I do not completely understand. I have made a simple workaround with an intermediate service unit, so it works fine. But I would like to understand how the units of the remote filesystem work, in order to be aware of such behavior in systemd.
Here is the mounting point unit of the remote filesystem:
$ systemctl status cvmfs-sft.cern.ch.mount * cvmfs-sft.cern.ch.mount Loaded: loaded Active: active (mounted) since Wed 2024-07-31 23:31:49 CEST; 1min 32s ago Until: Wed 2024-07-31 23:31:49 CEST; 1min 32s ago Where: /cvmfs/sft.cern.ch What: cvmfs2 It does not list a unit file. The unit must have been created somehow dynamically. So, when I add a Requires=cvmfs-sft.cern.ch.mount to my unit, it fails during the Linux boot up with this:
localhost systemd[1]: Failed to start A one shot script ... <hostname> systemd[1]: ....service: Failed to schedule restart job: Unit cvmfs-sft.cern.ch.mount not found. However, if I launch my unit after the boot, it comes up fine. I.e. the Requires=cvmfs-sft.cern.ch.mount dependency works fine when I log in as a normal user, the server has reached the multiuser target, the cvmfs is mounted and that unit cvmfs-sft.cern.ch.mount is active.
What I expected is to have actual unit files for the cvmfs mounting points. The remote filesystem would take its time to mount those mounting points, and my units would proceed from there.
According to the CVMFS documentation, what really manages this filesystem is this autofs.service. The autofs service runs mount points like this:
$ systemctl status autofs * autofs.service - Automounts filesystems on demand Loaded: loaded (/usr/lib/systemd/system/autofs.service; enabled; preset: disabled) Drop-In: /usr/lib/systemd/system/autofs.service.d `-50-cvmfs.conf ... CGroup: /system.slice/autofs.service |-3405 /usr/bin/cvmfs2 ... sft.cern.ch /cvmfs/sft.cern.ch ... What I want to ask is what can create such units without unit files in systemd? If I have an init.d script, systemd always translates it into an actual unit file, doesn't it? In this particular case, the unit status says What: cvmfs2. Does it mean that cvmfs2 use the following feature of systemd.mount?
$ man systemd.mount ... DESCRIPTION ... The systemd-mount(1) command allows creating .mount and .automount units dynamically and transiently from the command line. I guess you need this transient behavior for mounting points, in the case when the user plugs a USB drive in the computer etc. But can other unit types be created transiently, i.e. on the fly without a unit file?
Is there a good way to find out what launched such a transient unit? In my case, the unit dependencies don't tell me anything:
$ sudo systemctl list-dependencies cvmfs-sft.cern.ch.mount cvmfs-sft.cern.ch.mount * |--.mount * `-system.slice $ sudo systemctl list-dependencies --reverse cvmfs-sft.cern.ch.mount cvmfs-sft.cern.ch.mount Is there some other systemctl command that could tell you something more about the provenance of a transient unit like this?