CentOS Icon CentOS Logo
CentOS Text
   
  
www.centos.org Forum Index
   CentOS 6 - Software Support
  Mounting an NFS directory in /etc/fstab

 

 Bottom   Previous Topic   Next Topic
  •  Rate Thread
      Rate this Thread
      Excellent
      Good
      Average
      Bad
      Terrible
Poster Thread Rated:  1 Votes
  •  TrevorH
      TrevorH
Re: Mounting an NFS directory in /etc/fstab
#16
Moderator
Joined: 2009/9/24
From Brighton, UK
Posts: 6365
Yes, the renaming of the startup scripts is only necessary when you use the same system as nfs client and server at the same time. In normal use it wouldn't be required. Virtualisation is the real solution to your problem.
_________________
Linux/VoIP Systems Administrator
Posted on: 2011/12/5 0:32
Create PDF from Post Print
Top
  •  DK907
      DK907
Re: Mounting an NFS directory in /etc/fstab
#15
Regular Board Member
Joined: 2011/11/21
From
Posts: 66
Quote:

pschaff wrote:
Using the same system as the server and client for NFS is quite unusual, and one might argue of doubtful value in the real world. I doubt it is a situation that would come up on the RHCSA exam, nor one that would be considered by Red Hat when determining the order in which to start services.

So if I shared a directory using NFS in /etc/exports and I used a different computer as a client then it would not be necessary to rename the startup scripts on the client?. In the RHCSA exam it will be possible to use virtualization to simulate a real client/server network on a single computer so I should start practicing on a computer that is capable of virtualization to get more realistic experience before I take the test.
Posted on: 2011/12/4 21:45
Create PDF from Post Print
Top
  •  jlehtone
      jlehtone
Re: Mounting an NFS directory in /etc/fstab
#14
Professional Board Member
Joined: 2007/12/11
From Finland
Posts: 1329
I think that the logic for startup order is clear.

Mounting foreign filesystems is probably initialization of important
resources to the use of the system. That can be important and
needed early on. There are even diskless clients that definitely
depend on mounting first.

NFS server on the other hand is a mere service that a fully
operational system provides to the other machines on the network.
Posted on: 2011/12/4 20:51
Create PDF from Post Print
Top
  •  pschaff
      pschaff
Re: Mounting an NFS directory in /etc/fstab
#13
Moderator
Joined: 2006/12/13
From Tidewater, Virginia, North America
Posts: 18773
Using the same system as the server and client for NFS is quite unusual, and one might argue of doubtful value in the real world. I doubt it is a situation that would come up on the RHCSA exam, nor one that would be considered by Red Hat when determining the order in which to start services.
_________________
Phil

Recommended reading: FAQ & Readme first ; Search hint: google "your topic site:centos.org"; Smart Questions
Posted on: 2011/12/4 19:47
Create PDF from Post Print
Top
  •  DK907
      DK907
Re: Mounting an NFS directory in /etc/fstab
#12
Regular Board Member
Joined: 2011/11/21
From
Posts: 66
Quote:

TrevorH wrote:
I do remember doing this a few years ago and I had to amend the order of some of the start-up scripts. Looking at my CentOS 5 box which is the only one I use as an NFS server, in /etc/rc3.d I see that I have S25netfs and S60nfs which means that it will attempt to mount the NFS file systems before it has started the NFS daemons. The solution was to rename the start up script so that netfs ran after nfs.

In CentOS 6, /etc/rc3.d and /etc/rc5.d both contain S24nfslock, S25netfs and S30nfs. Why would Red Hat put these startup scripts in the wrong order?. This is such an obvious problem that I cannot believe it was done by accident. I experimented with this by renaming S25netfs to S32netfs and I commented the mount.nfs4 commands that I had put in /etc/rc.d/rc.local and I uncommented the mount the nfs entries in /etc/fstab. It worked. I am glad that I learned about this problem now so I will know how to fix it when I take the RHCSA exam.
Posted on: 2011/12/4 19:11
Create PDF from Post Print
Top
  •  TrevorH
      TrevorH
Re: Mounting an NFS directory in /etc/fstab
#11
Moderator
Joined: 2009/9/24
From Brighton, UK
Posts: 6365
I do remember doing this a few years ago and I had to amend the order of some of the start-up scripts. Looking at my CentOS 5 box which is the only one I use as an NFS server, in /etc/rc3.d I see that I have S25netfs and S60nfs which means that it will attempt to mount the NFS file systems before it has started the NFS daemons. The solution was to rename the start up script so that netfs ran after nfs.
_________________
Linux/VoIP Systems Administrator
Posted on: 2011/12/4 0:38
Create PDF from Post Print
Top
  •  DK907
      DK907
Re: Mounting an NFS directory in /etc/fstab
#10
Regular Board Member
Joined: 2011/11/21
From
Posts: 66
Quote:

pschaff wrote:
Not a very realistic environment but I guess one has to make do with available resources. You could add the mount command in /etc/rc.d/rc.local that runs at the end of the boot.

Thank you, that worked. I added
mount.nfs david.example.com:/shares /mnt/nfs

to /etc/rc.d/rc.local and it worked.
I am curious to know if it is theoretically possible to use NFS to mount a directory that is on the local host at boot using /etc/fstab. It is not important because it is the results that count.
Posted on: 2011/12/4 0:30
Create PDF from Post Print
Top
  •  pschaff
      pschaff
Re: Mounting an NFS directory in /etc/fstab
#9
Moderator
Joined: 2006/12/13
From Tidewater, Virginia, North America
Posts: 18773
Not a very realistic environment but I guess one has to make do with available resources. You could add the mount command in /etc/rc.d/rc.local that runs at the end of the boot.
_________________
Phil

Recommended reading: FAQ & Readme first ; Search hint: google "your topic site:centos.org"; Smart Questions
Posted on: 2011/12/3 21:52
Create PDF from Post Print
Top
  •  DK907
      DK907
Re: Mounting an NFS directory in /etc/fstab
#8
Regular Board Member
Joined: 2011/11/21
From
Posts: 66
Quote:

pschaff wrote:
Are you saying that solved the problem? If so, you have a DNS issue.

The /etc/exports file is used on the NFS server and not on the client.


No, I said it still does not work. I am just practicing for the RHCSA exam so my computer is both the server and the client. Entering mount -a works, so I do not understand why these directories are not mounting at boot. I do not think DNS was ever the problem because I resolved my IP address to david.example.com in /etc/hosts and I can ping david.example.com.
Posted on: 2011/12/3 21:41
Create PDF from Post Print
Top
  •  pschaff
      pschaff
Re: Mounting an NFS directory in /etc/fstab
#7
Moderator
Joined: 2006/12/13
From Tidewater, Virginia, North America
Posts: 18773
Are you saying that solved the problem? If so, you have a DNS issue.

The /etc/exports file is used on the NFS server and not on the client.
_________________
Phil

Recommended reading: FAQ & Readme first ; Search hint: google "your topic site:centos.org"; Smart Questions
Posted on: 2011/12/3 21:33
Create PDF from Post Print
Top
  •  DK907
      DK907
Re: Mounting an NFS directory in /etc/fstab
#6
Regular Board Member
Joined: 2011/11/21
From
Posts: 66
I tried all of your suggestions and it still does not work. I edited /etc/exports and added
/shares 192.168.1.0/24(rw,sync)

I edited /etc/fstab and added
192.168.1.100:/shares /mnt/nfs nfs _netdev,rsize=8192,wsize=8192,intr 0 0 
Posted on: 2011/12/3 21:24
Create PDF from Post Print
Top
  •  pschaff
      pschaff
Re: Mounting an NFS directory in /etc/fstab
#5
Moderator
Joined: 2006/12/13
From Tidewater, Virginia, North America
Posts: 18773
What happens if you omit the timeo or udp options?
_________________
Phil

Recommended reading: FAQ & Readme first ; Search hint: google "your topic site:centos.org"; Smart Questions
Posted on: 2011/12/3 20:52
Create PDF from Post Print
Top
  •  TrevorH
      TrevorH
Re: Mounting an NFS directory in /etc/fstab
#4
Moderator
Joined: 2009/9/24
From Brighton, UK
Posts: 6365
Include the "_netdev" option in the list of options. This tells the init scripts that the file system to be mounted resides on a network device and needs the network to be available before it can be mounted.
_________________
Linux/VoIP Systems Administrator
Posted on: 2011/12/3 19:20
Create PDF from Post Print
Top
  •  toracat
      toracat
Re: Mounting an NFS directory in /etc/fstab
#3
Moderator
Joined: 2006/9/3
From California, US
Posts: 6921
Just for testing purpose, can you use the IP address in /etc/fstab and see if it still fails to mount upon booting?
_________________
Useful links: Search Forums, Forum FAQ
Posted on: 2011/12/3 19:05
Create PDF from Post Print
Top
  •  DK907
      DK907
Re: Mounting an NFS directory in /etc/fstab
#2
Regular Board Member
Joined: 2011/11/21
From
Posts: 66
chkconfig nfs on was activated before I started this thread.
Posted on: 2011/12/3 16:47
Create PDF from Post Print
Top
  •  DK907
      DK907
Mounting an NFS directory in /etc/fstab
#1
Regular Board Member
Joined: 2011/11/21
From
Posts: 66
I am studying for the RHCSA exam and I am trying to mount an NFS directory at boot.

I resolved my ip address to david.example.com in /etc/hosts and I entered /shares *.example.com(rw,sync) in /etc/exports and entered exportfs -a. I entered

david.example.com:/shares /mnt/nfs nfs rsize=8192,wsize=8192,timeo=14,intr,udp 0 0 

in /etc/fstab.

When I restart it takes longer than normal to boot up and when I check the boot messages it says mount.nfs connection timed out. When I enter mount -a it does mount /shares on /mnt/nfs.

I tried editing /etc/sysconfig/iptables and I added

-A INPUT -m state --state NEW -m tcp -p tcp --dport 2049 -j ACCEPT 
-A INPUT -m state --state NEW -m tcp -p tcp --dport 111 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 111 -j ACCEPT

I did service iptables restart and it restarted without any problems but when I restart I still have the same problem.

Does anyone have any suggestions?.

[Moderator edited to insert code tags to aid legibility.]
Posted on: 2011/12/2 21:04
Create PDF from Post Print
Top
 Top   Previous Topic   Next Topic

 


 You cannot start a new topic.
 You can view topic.
 You cannot reply to posts.
 You cannot edit your posts.
 You cannot delete your posts.
 You cannot add new polls.
 You cannot vote in polls.
 You cannot attach files to posts.
 You cannot post without approval.




"Linux" is a registered trademark of Linus Torvalds. | All other trademarks are property of their respective owners. | All other content is Copyright @ 2004-2009 by the CentOS Project or "each individual contributor (forums, comments, etc.) unless otherwise assigned".| Theme based on a theme by 7dana.com