Mounting an NFS directory in /etc/fstab

Issues related to applications and software problems

Mounting an NFS directory in /etc/fstab

Postby DK907 » 2011/12/02 21:04:10

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

Code: Select all
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

Code: Select all
-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.]
DK907
 
Posts: 66
Joined: 2011/11/21 16:32:49

Re: Mounting an NFS directory in /etc/fstab

Postby DK907 » 2011/12/03 16:47:31

chkconfig nfs on was activated before I started this thread.
DK907
 
Posts: 66
Joined: 2011/11/21 16:32:49

Mounting an NFS directory in /etc/fstab

Postby toracat » 2011/12/03 19:05:13

Just for testing purpose, can you use the IP address in /etc/fstab and see if it still fails to mount upon booting?
User avatar
toracat
Forum Moderator
 
Posts: 6687
Joined: 2006/09/03 16:37:24
Location: California, US

Re: Mounting an NFS directory in /etc/fstab

Postby TrevorH » 2011/12/03 19:20:02

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.
User avatar
TrevorH
Forum Moderator
 
Posts: 9109
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Mounting an NFS directory in /etc/fstab

Postby pschaff » 2011/12/03 20:52:46

What happens if you omit the timeo or udp options?
pschaff
Retired Moderator
 
Posts: 18277
Joined: 2006/12/13 20:15:34
Location: Tidewater, Virginia, North America

Re: Mounting an NFS directory in /etc/fstab

Postby DK907 » 2011/12/03 21:24:00

I tried all of your suggestions and it still does not work. I edited /etc/exports and added
Code: Select all
/shares 192.168.1.0/24(rw,sync)

I edited /etc/fstab and added
Code: Select all
192.168.1.100:/shares /mnt/nfs nfs _netdev,rsize=8192,wsize=8192,intr 0 0
DK907
 
Posts: 66
Joined: 2011/11/21 16:32:49

Re: Mounting an NFS directory in /etc/fstab

Postby pschaff » 2011/12/03 21:33:13

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.
pschaff
Retired Moderator
 
Posts: 18277
Joined: 2006/12/13 20:15:34
Location: Tidewater, Virginia, North America

Re: Mounting an NFS directory in /etc/fstab

Postby DK907 » 2011/12/03 21:41:46

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.
DK907
 
Posts: 66
Joined: 2011/11/21 16:32:49

Re: Mounting an NFS directory in /etc/fstab

Postby pschaff » 2011/12/03 21:52:39

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.
pschaff
Retired Moderator
 
Posts: 18277
Joined: 2006/12/13 20:15:34
Location: Tidewater, Virginia, North America

Re: Mounting an NFS directory in /etc/fstab

Postby DK907 » 2011/12/04 00:30:25

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
Code: Select all
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.
DK907
 
Posts: 66
Joined: 2011/11/21 16:32:49

Next

Return to CentOS 6 - Software Support

Who is online

Users browsing this forum: No registered users and 2 guests