I'm trying to set up a new service (under Debian Jessie) that needs to set up some mounts where the network configuration is stored and thus this service must complete before networking.service starts.
I tried the following:
[Unit]
Description=mount/repair remaining filesystems (all persistent fs beyond "/")
#Before=network-pre.target
Before=networking.service
[Service]
Type=oneshot
ExecStart=/opt/intermodul-mounts/start.sh
TimeoutSec=0
RemainAfterExit=yes
[Install]
RequiredBy=networking.service
Using systemd-analyze plot
I can see that my service starts, but networking.service
starts about 3 seconds earlier:
Apparently my config is wrong, but I'm having a hard time finding the problem… Any help greatly appreciated..
Update
I currently solved it by changing the service config to start before local-fs.target
instead of networking.service
:
[Unit]
DefaultDependencies=no
Description=mount/repair remaining filesystems (all persistent fs beyond "/")
Before=local-fs.target
[Service]
Type=oneshot
ExecStart=/opt/intermodul-mounts/start.sh
TimeoutSec=0
RemainAfterExit=yes
[Install]
RequiredBy=local-fs.target
Still, I'd like to understand why my first configuration didn't work as expected…?
Best Answer
You want to use
network-pre.target
if you want to setup something before network startsYou should put these under
[Unit]
section:Reference