You are not logged in.

#1 2013-02-17 23:34:32

glenn69
Member
Registered: 2007-09-26
Posts: 112

How do I mount nfs conditionally?

I have a file server with nfs shares and I've been mounting those shares with fstab entry.
I recently discovered (via systemd-analyze) that my really slow boot times were a result of the file server not being available ( powered off.)
The server will not always be online, so how do I change my fstab entry to only mount when the server is available?
I do like having the ability to mount -a when I need to mount on the fly.
I've attempted to search for this info, but found myself in a mess of fstab vs. systemd automount vs autofs posts.

Thank you

Offline

#2 2013-02-17 23:40:54

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,412

Re: How do I mount nfs conditionally?

What about specifying to your database that it is a "_netdev" or using systemd automount so it wont get mounted until you actually query it. What is it you have in your fstab currently?

Offline

#3 2013-02-17 23:42:59

glenn69
Member
Registered: 2007-09-26
Posts: 112

Re: How do I mount nfs conditionally?

My current fstab reads as follows:

Fileserver:/    /media/NFS_Shares  nfs4    rsize=8192,wsize=8192,timeo=14,intr  0 0

Offline

#4 2013-02-18 18:47:45

der_joachim
Member
From: the Netherlands
Registered: 2008-12-17
Posts: 136
Website

Re: How do I mount nfs conditionally?

I use autofs. Probably not the most shiny way of handling NFS shares, but it works. More info in the wiki.


Geek, runner, motorcyclist and professional know-it-all

Offline

#5 2013-02-18 19:58:36

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,412

Re: How do I mount nfs conditionally?

Yes, autofs indeed.  I have the following additional mount options on my nfs share:

...noauto,x-systemd.automount,nofail,_netdev

I have seen reports from many that their systems function just fine without "_netdev" but it is something that I have been using since I started using nfs.  The nofail will simply do what it sounds like, if it is not present, it will not fail.  So when I do get back onto my home network with the nfs share, I simply do

$ mount /mount/point 

and it works.  I also have the users option, so that I can mount as a normal user.  I am not sure if this is automatic enough for you, but it works for my use case.

Offline

#6 2013-02-18 20:15:20

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,838

Re: How do I mount nfs conditionally?

WonderWoofy wrote:

Yes, autofs indeed.  I have the following additional mount options on my nfs share:

...noauto,x-systemd.automount,nofail,_netdev

To avoid confusion, it's worth mentioning that autofs and systemd automount are two completely different beasts.

WonderWoofy wrote:

when I do get back onto my home network with the nfs share, I simply do

$ mount /mount/point 

FYI, the presence of x-systemd.automount in your fstab means you don't have to issue the mount command - it will automount whenever you try to access it.

Offline

#7 2013-02-18 20:18:38

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,412

Re: How do I mount nfs conditionally?

I guess that would be the point of autofs wouldn't it... wow, I was doing it wrong the whole time!

Offline

#8 2013-02-19 16:48:31

der_joachim
Member
From: the Netherlands
Registered: 2008-12-17
Posts: 136
Website

Re: How do I mount nfs conditionally?

TBH, I switched to autofs because the automounting and autounmounting did not work. NFS is fickle. YMMV.


Geek, runner, motorcyclist and professional know-it-all

Offline

#9 2013-02-19 21:28:15

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,838

Re: How do I mount nfs conditionally?

Actually, autounmounting is still on the to-do list for systemd, so if you need that autofs is indeed your best choice.

Offline

Board footer

Powered by FluxBB