<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 29 Oct 2024 at 02:50, Adam Nielsen <<a href="mailto:a.nielsen@shikadi.net">a.nielsen@shikadi.net</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">Hi all,<br>
<br>
I'm having some problems getting a systemd unit to start during system<br>
boot. Can anyone advise what I'm doing wrong?<br>
<br>
The service starts fine if I run `systemctl start myservice`, the issue<br>
is that it fails to start during boot.<br>
<br>
The service runs off a network share, so if it starts too early in the<br>
boot process the share is not mounted and it fails for that reason and<br>
systemd does not try to restart it later, despite the unit file saying<br>
to restart forever.<br>
<br>
I tried using ConditionPathExists=/mnt/share/something however because<br>
the path does not exist when the service is run during boot, the unit<br>
is never started and it is not retried later when the path does exist.<br>
<br>
I tried using RequiresMountsFor=/mnt/share however again, if it runs too<br>
early in the boot process the mount is not there and the unit fails to<br>
start, and is not retried (logs just say "Job myservice.service/start<br>
failed with result 'dependency'.")<br>
<br>
Currently I have to wait until the machine has booted, SSH into it, and<br>
then use systemctl to start the service. I'm sure there must be a way<br>
to get this service to start automatically during boot, however I<br>
haven't yet worked it out.<br>
<br>
Any suggestions how I can indicate that the service should start after<br>
a specific path is mounted?<br></blockquote><div><br></div><div>I had a similar requirement and the way I implemented it was to create a systemd.mount for the NFS mount and then ensure that I have the mount in the "After" and add a "
Requires" in the service that will depend on the mount. An example below:</div><div><br></div><div>
After=network.target nfs.mount <br></div><div>
Requires=nfs.mount <br></div><div><br></div><div>I hope this helps. <br></div><div><br></div><div>Kind regards</div><div>Henti<br></div></div></div>