Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a machine that mounts another machine's NFS share.

However the client machine boots up faster than the server, so it gets an error when trying to mount the NFS share from the server. I had a power outage over the weekend and this can be annoying when I am remote.

I would like to ensure that the NFS share is always mounted, so that if the client detects that the share isn't there it will attempt to remount it. I think this might involve autofs and/or upstart to ensure the share stays mounted, but I don't know how to do this.

I am mounting it via the following method in /etc/fstab:

jillybean.local:/share /share nfs rsize=32768,rw,soft,intr
share|improve this question

2 Answers 2

up vote 1 down vote accepted

There are multiple things you could do:

  • add the retry=n (with n being an integer representing minutes) to your mount options in /etc/fstab for the cases NFS is not (yet) available at boot time
  • make use of autofs, as you suggested (lots of How-Tos returned by this Google search)
  • create some simple daemon process which exits when the NFS share is not available, and mounts it when invoked with the start parameter -- so you can set it up as upstart event with respawn (i.e. automatically restart when aborted other than by service xyz stop). Combine this with above retry=n)
  • setup a cron job checking for some (existing) directory on the NFS share -- and run the mount command when it is not found (again, combine it with retry=n)
share|improve this answer

Consider to create a bash script with the following:

if ! grep -qs '/share' /proc/mounts; then
    mount jillybean.local:/share /share

Give it exe permissions. Then put the script in crontab, croning it to your needs. For example, if you know your machines power on 7 o'clock, you could consider to execute the script every minute from 7 to 8:

0-15 7-8 * * * /path/tho/your/script.sh
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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