I have setup 5 NFS mounts in /etc/fstab.

The first one "parent" mounts on local mount point /foo and the other 4 "child" in mounts points on the first one:

So let's say the second is /foo/test1. The third is in /foo/media etc...

Example:    /foo           some-nfs-options        /foo/test1     some-nfs-options          /foo/media     some-nfs-options

But when i do df -h after logging in (after reboot) it shows only the share on /foo... the others (in the sub-directories) are not mounted... So i type mount -a and everything is fine...

I check /var/log/messages and i saw that during boot when it tries to mount the "child" nfs exports which depend on folders in the "parent" one it whines about "no local mounts points found". So i assume it takes some time (we are talking 1-2 seconds more) to mount /adventure-time in /foo so during that time the folders test1 and media are not available... and therefore it fails to mount the other shares.Like it tries to mount everything at once...

Then after login when already these folders are present (because /adventure-time is already mounted in /foo) it mounts the other shares without problem (local mount points already exist)...

The question is how to make the "child" shares to be depending on the "parent" and wait for him to mount before they try?

Typing mount -a in /etc/rc.d/rc.local is only a workaround...

Is there some nfs option that i should put in fstab?

There has to be a solution for this? nfs (or the boot process) should not be that dumb... :/

  • What OS distribution is this? – ewwhite Mar 20 '16 at 12:02

You want the bg mount option in /etc/fstab: this will cause the mounts which initially fail to background themselves and retry, when they will succeed.

  • Which OS' fstab is it that supports bg option? O_o – poige Mar 20 '16 at 11:55
  • @poige: I'm not sure. The nfs(5) entry you reach from kernel.org has it, but I don't have a RHEL distribution handy to check. Solaris does, of course (it originated with SunOS 3 or 4 I should think) – tfb Mar 20 '16 at 12:13
  • @poige PS: I've just checked and Ubuntu certainly does, so I'm guessing that all Linux distros do at least. – tfb Mar 20 '16 at 14:13
  • (And I can confirm now that RHEL does, so OEL will too, as it is just RHEL outside the kernel.) – tfb Mar 21 '16 at 10:53

There has to be a solution for this? nfs (or the boot process) should not be that dumb

The boot process isn't dumb. I haven't read the man pages for mount/nfs in a while but I don't recall there being any way to make one mount dependent on another.

It seems that you already have one solution - using a script. You may want to look at the mountpoint command which can help in this type of script.

Another solution might be autofs. You would mount your main NFS filesystem using fstab as normal and then use autofs to mount the sub filesytems on demand.

  • Unfortunately autofs will not do since on the actual machine these exports are for oracle database... So they need to be mounted right away... Especially since database has autostart on... Failure to mount means failure on database = failure of the application running on the server :/ – Bojo Jelev Mar 16 '16 at 13:17
  • 1
    Failure to mention that leads to ... but anyway autofs should mount the stuff on first access - it may be worth trying. Failing that you're just going to have to go with a script. If you have dependencies on the mount points then you should consider using systemd unit files (or whatever your unspecified distro uses) and ensure that the unit runs before whatever starts oracle. – user9517 Mar 16 '16 at 13:38
  • Distro is oracle enterprise linux 6 so init scripts.... I think the solution will involve nesting nfs but i cannot find any relevant info on the matter – Bojo Jelev Mar 16 '16 at 17:55

If you're using a redhat-like distribution, be sure to enable the netfs service.

This should take care of your nested mounts. Test and see.

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.