I'm managing an Ubuntu 16.04-based VM (running KVM/libvirt). The server hosts a few VMs that are used internally in our department.

All of the VMs use our company's Samba server for storing various bits and pieces of data.

During a power outage last night, I discovered that the machines boot much faster than the Samba server that they need, and which causes a bunch of services on the VMs to fail.

Rather than patch it on a VM-by-VM basis, I'd like to be able to just instruct my VM host to wait for the CIFS server before starting all of the VMs after reboot (basically, I'd like to make libvirt-guests.service depend on mnt-SHARENAME.mount).

I know that I could add a dependence in /lib/systemd/system/libvirt-guests.service, but I'm not sure if that's the systemd-approved method. Is there any other way to express the dependency?


You can create a dummy "run once" service that sites between them.

In my case I have a problem with xinetd and NFS (xinetd starts before NFS filesystems have mounted so some of the services don't start). I kludged this with a file /lib/systemd/system/fix-xinetd-nfs-dependency.service

Description=Make xinetd wait for NFS otherwise it can not start services



Once you've created your service (have the Before and After lines reflect your requirements) then you can systemctl enable it... and with luck this will run before your VMs have started and your samba filesystems available!

|improve this answer|||||
  • To make this work with libvirt I changed xinetd.service to libvirt-guests.service (and changed the comments and filename). – Dan Gravell Jan 26 '19 at 10:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.