<div dir="ltr">Hi Andrei,<span>
</span><p dir="ltr">Thank you for your reply!</p><span></span>Just to confirm: there are about 10 passive system targets in systemd.special(5):<div><br></div><div>- getty-pre.target</div><div>- cryptsetup-pre.target</div><div>- local-fs-pre.target</div><div>- network.target</div><div>- network-pre.target</div><div>- nss-lookup.target</div><div>- nss-user-lookup.target</div><div>- remote-fs-pre.target</div><div>- rpcbind.target</div><div>- time-sync.target</div><div><br></div><div>Are they all related to early days initscripts?<br><div><br></div><div>Thanks.<br><div dir="auto"><br></div><div dir="auto">John</div></div><div><div dir="auto"><div dir="auto"><br><div class="gmail_quote"><div dir="ltr">Andrei Borzenkov <<a href="mailto:arvidjaar@gmail.com" target="_blank">arvidjaar@gmail.com</a>> 於 2017年10月18日 週三 00:58 寫道:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">16.10.2017 18:15, 林自均 пишет:<br>
> Hi folks,<br>
><br>
> I am reading systemd documents, and I find passive target units a little<br>
> bit confusing.<br>
><br>
> Take "network.target" for example:<br>
><br>
> "systemd-networkd.service" specifies "Wants=network.target" and<br>
> "Before=network.target". That effectively makes starting<br>
> "systemd-networkd.service" brings up both "systemd-networkd.service" and<br>
> "network.target", and make sure that "network.target" is active after<br>
> "systemd-networkd.service" being active. It also implies that the shutdown<br>
> order is correct: "network.target" will be stopped before<br>
> "systemd-networkd.service". Everything is fine.<br>
><br>
> What if we use an active target unit to achieve all this? Can we specify a<br>
> "WantedBy=network.target" in "systemd-network.target"? So that we can<br>
> enable "systemd-network.service" (which makes a symbolic link in the<br>
> "network.target.wants" directory) and start "network.target" to pull in<br>
> "systemd-networkd.service". That also makes sure "network.target" is active<br>
> after "systemd-networkd.service" because of the target unit default<br>
> dependencies. And shutdown order will be correct too.<br>
><br>
> The only difference I can tell is the units to start. With a passive<br>
> "network.target", we start "systemd-networkd.service". With an active<br>
> "network.target", we start "network.target".<br>
><br>
> Is there any benefits of passive target units over active target units?<br>
><br>
<br>
I think it's historical artefact from the very early days when systemd<br>
had to rely on initscripts. initscript implementing networking did<br>
provide $network a.k.a network.target, but of course did not hook itself<br>
into native systemd units. As long as you are sure to use native units<br>
only there is no practical difference.<br>
</blockquote></div></div></div></div></div></div>