<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Nov 12, 2024 at 12:13 PM Tony Rodriguez <<a href="mailto:unixpro1970@gmail.com">unixpro1970@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hoping I can accomplish the following via a simple UNIT modification or <br>
service script?<br>
<br>
<br>
Questions:<br>
<br>
A) How can my service always runs "last" within local-fs-pre.target?<br>
<br>
For Example:<br>
<br>
Need my service to always run last within the local-fs-pre.target, even <br>
if others add another services later within local-fs-pre.target. Still <br>
want my service to always run last within this local-fs-pre.target.<br>
<br>
Note: I will not know services others may later add within the <br>
local-fs-pre.target<br></blockquote><div><br></div><div>Systemd deliberately doesn't have a definite concept of "last" or "first". (More importantly, what happens if another service also wants to be "last"?)<br></div><div><br></div><div>It's specifically the purpose of targets themselves to be used as barriers. Instead of "After=*.mount" you would have "After=local-fs.target" because all those mounts are in local-fs.target.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
<br>
B) How can I make my service run after all .mount(s) within <br>
local-fs-pre.target, before local-fs.target, especially if I don't know <br>
all the .mount(s)? The .mount files are located within <br>
/var/run/systemd/generator/*<br>
<br>
ls -l /var/run/systemd/generator/*.mount<br>
-rw-r--r-- 1 root root 390 Nov 12 00:59 <br>
/var/run/systemd/generator/boot-efi.mount<br>
-rw-r--r-- 1 root root 449 Nov 12 00:59 <br>
/var/run/systemd/generator/boot.mount<br>
-rw-r--r-- 1 root root 428 Nov 12 00:59 <br>
/var/run/systemd/generator/home.mount<br>
-rw-r--r-- 1 root root 239 Nov 12 00:59 /var/run/systemd/generator/-.mount<br>
-rw-r--r-- 1 root root 424 Nov 12 00:59 /var/run/systemd/generator/tmp.mount<br>
-rw-r--r-- 1 root root 241 Nov 12 00:59 /var/run/systemd/generator/usr.mount<br>
-rw-r--r-- 1 root root 424 Nov 12 00:59 /var/run/systemd/generator/var.mount<br>
<br>
-rw-r--r-- 1 root root 424 Nov 12 00:59 <br>
/var/run/systemd/generator/test.mount<br>
<br>
<br>
Appears the UNIT section doesn't support a wildcard for .mount(s)<br>
<br>
This doesn't work<br>
<br>
#After=local-fs-pre.target *.mount<br>
<br>
The following works, but have to hard code mounts. Would like to <br>
dynamically populate mounts for "After=" within my service file.<br>
<br>
After=local-fs-pre.target boot.mount boot-efi.mount -.mount usr.mount <br>
var.mount tmp.mount home.mount<br>
Before=local-fs.target<br>
<br>
[Unit]<br>
Description=mytest.service<br>
DefaultDependencies=no<br>
Wants=local-fs-pre.target<br>
After=local-fs-pre.target boot.mount boot-efi.mount -.mount usr.mount <br>
var.mount tmp.mount home.mount test.mount<br>
Before=local-fs.target<br>
<br>
</blockquote></div><div><br></div><div>How come your home.mount is in local-fs-pre? That is exactly the kind of mount that would be in local-fs. In fact, why do you have *any* mounts in local-fs-pre?<br clear="all"></div><br><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr">Mantas Mikulėnas</div></div></div>