Under Ubuntu 14.04, I have developed a program in C++ that writes to an NFSv4 volume mounted by autofs.

The program works fine when my machine has already "warmed up".

However, it crashes when it's started as a service at boot time - I wrote a script for it under /etc/init.d and enabled it via update-rc.d.

Upon examining the core dump, I see that it failed to create a file under the NFSv4 volume. In fact, I can reproduce the problem even in the terminal, if I launch the program quickly enough right after reboot.

How can I ensure that autofs and nfs are ready before my service starts?

I have already added $network and autofs to the Required-Start clause of my init script, but it looks like that's not enough. It also has nothing to do with hostname resolution because the IP address of the NFS server is specified in the autofs rule.

migrated from unix.stackexchange.com Oct 4 '16 at 7:48

This question came from our site for users of Linux, FreeBSD and other Un*x-like operating systems.

  • tryy adding $remote_fs as a required-start. – meuh Sep 30 '16 at 19:47
  • 1
    I think the problem is that autofs is starting as an upstart job where you start your service with and SysV initscript. Creating direct dependencies between the two worlds is nearly impossible and you could e.g. start all SysV scripts after autofs. Better would be to write an upstart job for your service where you can create a direct dependency. – Thomas Oct 1 '16 at 12:25
  • @meuh $remote_fs is already among Required-Start explicitly (it's also implied by autofs). – Kal Oct 1 '16 at 23:30
  • @Thomas I just double-checked and autofs is not managed by Upstart, according to service --status-all. It's a SysV init script. – Kal Oct 3 '16 at 4:14
  • 1
    Is it enabled? By default autofs is started with upstart because there is a /etc/init/autofs.conf file as well. If you start with SysV you can just add the name of your service to the Required-Start section, then disable and reenable your service. – Thomas Oct 3 '16 at 8:41

Your Answer

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

Browse other questions tagged or ask your own question.