Ask Your Question

systemd service start order

asked 2015-08-05 03:55:55 -0500

Hi guys,

Is anyone could direct me to the information about how can I modify service file, for example "/usr/lib/systemd/system/dnsmasq.service" to start only after my vagrant directory is mounted in this guest?

I am using tftproot in dnsmasq configuration that places inside directory that shared from my host system through "vagrant guestshared folder" feature, that itself is nfs share.

In systemctl I can see unit vagrant.mount, but it is another subsystem that I could not refer to, isn't it? So systemd does know nothing about this unit. This directory is mounting by nfs client, not nfs server, so it is useless to refer nfs-server in dependencies.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2015-08-06 07:57:30 -0500

Copy /usr/lib/systemd/system/dnsmasq.service to /etc/systemd/system/dnsmasq.service. Changes made in the latter location will override the system defaults from /usr/lib/.

I think the most appropriate directive would be RequiresMountsFor=, described as follows in man systemd.unit:

       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).

So your new dnsmasq.service might look like this, assuming you need the vagrant share at /vagrant:

Description=DNS caching server.
ExecStart=/usr/sbin/dnsmasq -k

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2015-08-05 03:55:55 -0500

Seen: 1,896 times

Last updated: Aug 06 '15