Mount NFS Share On NFS Client via bash script.


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Old 03-13-2016
Mount NFS Share On NFS Client via bash script.

I need a help of good people with effective bash script to mount nfs shared,
By the way I did the searches, since i haven't found that someone wrote a script like this in the past, I'm sure it will serve more people.

The scenario as follow:
An NFS Client with Daily CRON , running bash script that:
Reading the output of:
Code:
showmount -e server01.example.com

And if certain mount does not exist In /etc/fstab.
It will insert the mount to /etc/fstab with following nfs attribute and options,
With creation of relevant "/nfs/x" shares, under the "/nas" directory on client.
Code:
server01.example.com:/nfs/test /nas/test nfs tcp,hard,intr,noatime 0 0
server01.example.com:/nfs/data /nas/data nfs tcp,hard,intr,noatime 0 0
server01.example.com:/nfs/logs /nas/logs nfs tcp,hard,intr,noatime 0 0

Thanks all.

Last edited by vbe; 03-13-2016 at 07:27 AM.. Reason: code tags please even for so lttle...
# 2  
Old 03-13-2016
Are you aware of the /net/server01.example.com/ feature in automounter?
It is activated by /net -hosts in /etc/auto.master and starting the autofs service.
# 3  
Old 03-13-2016
Hi, Made.
I'm familiar with "/net" of the autofs terminology,
but in my case i will need to apply it via bash script.
I came across a several scripts that mount nfs shares on client ,But what is common to all, is that you required to specify the shared/exports.

And in my case the path = x
server01.example.com:/nfs/x

i.e :
Situation where someone added a new line to NFS Server /etc/exports,
And Client will handle on the mount through bash script that:
1. Read showmount -e
2.Verify that /nfs/x already exist in /nas under fstab
if not:
3. Create folder
4. Add it to fstab with under "/nas/x" with "nfs tcp,hard,intr,noatime 0 0"
5. mount share.
# 4  
Old 03-13-2016
And what speaks against a symbolic link /nas -> /net/server01.example.com? Then you don't need the bash script.
Try with /nas2 first so you can compare with your existing /nas
# 5  
Old 03-13-2016
May I question the point of having a daily job to update /etc/fstab? Even if shares were added frequently (daily), you wouldn't see them but the next day. And, what about removed shares?

If the clients are continuously up and running, create a script that actively distributes the new (or removed!) share info from the server to all the clients. If they aren't, a daily cron doesn't help anyway (but mayhap a boot script to fetch that info and update the local tables).
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Solaris 10 NFS client cannot mount a share from a Windows server Hiroshi Solaris 1 02-08-2017 06:07 PM
Cannot mount NFS share (FreeNAS) onto SCO OpenServer 5.0.6 trolley SCO 3 07-04-2014 11:09 PM
Unable to access NFS share on Solaris Server from Linux client SunilB2011 Red Hat 3 06-22-2012 02:01 AM
Can't access NFS Share on Solaris Server from a Linux Client SunilB2011 Solaris 0 06-21-2012 02:39 AM
Nfs client mount RPC Error: Program not registered. bobby320 Red Hat 4 04-04-2012 05:17 AM
Not able to mount NFS share on client side srinathk Red Hat 12 02-10-2012 07:43 PM
can not mount from aix client to linux nfs server victorcheung AIX 1 11-30-2010 05:37 AM
NFS Share & Mount problem chinmayzen Web Development 0 09-26-2010 07:09 AM
Solaris 9 as a nfs client -- centos as a nfs server. bruceharbin Solaris 1 07-23-2010 05:03 PM
Can't see home folder on one NFS mount but can in another mount on another share Narnie IP Networking 2 01-09-2010 09:49 PM
how to mount Windows NFS share on solaris uxadmin007 Solaris 2 08-03-2009 03:40 PM
can i mount nfs share on windows 2003 server tarunicon UNIX for Advanced & Expert Users 1 04-20-2009 12:59 PM
Unusual NFS mount problem on only ONE client: Red Hat WS Rel 3 neelpert1 UNIX for Advanced & Expert Users 6 02-12-2009 05:10 PM
NFS client Mount script after boot sv2xs Shell Programming and Scripting 0 06-27-2008 02:58 PM
Unable to mount NFS share during boot jlslhills AIX 0 08-09-2005 02:55 PM