Systemd start service early in boot

I am trying to create a systemd service to start before or in parallel with networking in the boot process.
I have tried a bunch of variations to try to get my script to start early that don’t work.

This may be getting it to start early but then networking doesn’t work. This is running /bin/true to be sure its not my script messing things up.

Description=MFM Emulator


I then get this error and ethernet isn’t set up.

ifup[530]: /sbin/ifup: failed to open statefile /run/network/ifstate: No such file or directory

Anyone know how to properly do this?

For now I went back to using init scripts which was easy to get it to do what I wanted.

It looks like you are programming that you want your service to start “Before” Networking Service.

From your description, you want your service to start “After” Networking Service.

You can also use systemd.timer to wait an absolute amount of time after the start of booting. Something around 25 to 30 seconds allows everything to boot and stabilize before starting your service.
Search for systemd.timer

— Graham

No, I am trying to get my stuff to start as early as possible. After networking starts is too long. Before would be best but in parallel is probably OK.

Well, it looks like you are starting it before networking, and it is failing because it depends on networking being running.
So, either you need to get rid of the dependency, or wait until the dependency is satisfied.
Your choice.
— Graham

Why would a MFM drive depend on networking ?

My stuff was working fine and has no dependency on networking. It was networking that stopped working when I tried to run before it. It appears that my .service file was changing how networking was staring. I still haven’t found a good description on how to set all this up but the following works for me though probably not ideal.

Description=MFM Emulator fsck-root.service fsck@.service