1

I have a problem during startup of my device running embedded Linux. My systemd service runs before some partitions get mounted which is not acceptable.

I list my mounts with systemctl list-units --type=mount and see the .mount files.

In my systemd service file i've now made modifications to wait until these get mounted. My mounts are opt-abc.mount and opt-def.mount for example and I use both After and Requires to wait for these to get mounted.

However, there are so many mixed opinions on the best way to do this. RequiresMountsFor= , some have recommended not to use this due to nonauto mounts.

Any help / experience with this would be appreciated.

The Unit section of my service file now looks as follows:

[Unit]
Description=My service 

After=opt-abc.mount
After=opt-def.mount
Requires=opt-abc.mount
Requires=opt-def.mount

1 Answer 1

1

First of all, both After= and Requires= can get space separated list of units. So, you don't need multiple assignments (More, I think thats potential for unexpectable result).

The next, After= and Requires= difference. Have a look at this https://www.freedesktop.org/software/systemd/man/systemd.unit.html manual. In two words: Requires= is for build dependencies. After= is for execution order.

I believe, that you need only After=. Remember that mount-targets may be generated by fstab or something. It seems, it's bad practice to use generated units in Requires=.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .