The ask: An installed service needs a specific filesystem (for example NFS) to be mounted in order to function properly. An attempt to start said service before the filesystem is mounted correctly results into fail. (if this happens during boot, boot time gets delayed and the service is not running after the boot sequence). How to configure the service file so that sytemd will always wait for the said mount to start the service?
1. The RequiresMountsFor option may be used. As per systemd.unit man page:
# man systemd.unit ... RequiresMountsFor= Takes a space-separated list of absolute paths. Automatically adds dependencies of type Requires= and After= for all mount units required to access the specified path. Mount points marked with noauto are not mounted automatically and will be ignored for the purposes of this option. If such a mount should be a requirement for this unit, direct dependencies on the mount units may be added (Requires= and After= or some other combination).
2. Add RequiresMountsFor to the [Unit] section in the /etc/systemd/system/[UNITFILE].service unit file. For example:
# /etc/systemd/system/example.service [Unit] Description=Example System Service RequiresMountsFor=/mnt/foo [...]