Generated unit files are not automatically activated by systemd. There's nothing special about them as far as systemd is concerned. Each individual generator has to explicitly create symbolic links that connect a generated unit to a target, so that activating the target activates the generated unit via a dependency in the normal way.
This takes advantage of the fact that not all connections between units are expressed inside the unit files. Wants and Requires dependencies can be expressed with symbolic link farms in *.wants/
and *.requires/
subdirectories. And those symbolic link farms encompass subdirectories of /run/systemd/
amongst other things.
In other words: Rather than write out a unit with WantedBy=local-fs.target
and then have to explicitly invoke sytemctl enable
to make the symbolic link (which is what enabling does), the generator short-circuits the process and makes the symbolic link itself. And it makes it in an ephemeral place, which systemctl enable
normally would not, thereby preventing the symbolic link from continuing to exist after the next shutdown and confusing the next startup.
Specifically, you'll find on your system that /run/systemd/generator/boot.mount
is symbolically linked from /run/systemd/generator/local-fs.target.wants/boot.mount
. systemd-fstab-generator
created this symbolic link, and it makes boot.mount
wanted by local-fs.target
. The generator is run early in the bootstrap before the system gets around to activating local-fs.target
, which means that when it does get around to activating local-fs.target
the generated dependency is there to be followed.
Further reading
/run/systemd/generator/local-fs.target.requires
directory. What makes this directory (/run/systemd/generator
) a directory where we can put unit files? I have not found it in any man pages. – Gradient Dec 26 '16 at 16:57systemd.generator(7)
, it seems like it is the generator that makes this directory known to systemd. – Gradient Dec 26 '16 at 17:08/etc/rcX.d
with an appropriate runlevel. – Benoit Duffez Jun 13 '23 at 18:10