Mounting an NFS directory in /etc/fstab
Mounting an NFS directory in /etc/fstab
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]
david.example.com:/shares /mnt/nfs nfs rsize=8192,wsize=8192,timeo=14,intr,udp 0 0
[/code]
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]
-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
[/code]
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 [i]code[/i] tags to aid legibility.]
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]
david.example.com:/shares /mnt/nfs nfs rsize=8192,wsize=8192,timeo=14,intr,udp 0 0
[/code]
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]
-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
[/code]
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 [i]code[/i] tags to aid legibility.]
Re: Mounting an NFS directory in /etc/fstab
chkconfig nfs on was activated before I started this thread.
Mounting an NFS directory in /etc/fstab
Just for testing purpose, can you use the IP address in /etc/fstab and see if it still fails to mount upon booting?
Re: Mounting an NFS directory in /etc/fstab
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.
-
- Retired Moderator
- Posts: 18276
- Joined: 2006/12/13 20:15:34
- Location: Tidewater, Virginia, North America
- Contact:
Re: Mounting an NFS directory in /etc/fstab
What happens if you omit the [b]timeo[/b] or [b]udp[/b] options?
Re: Mounting an NFS directory in /etc/fstab
I tried all of your suggestions and it still does not work. I edited /etc/exports and added
[code]
/shares 192.168.1.0/24(rw,sync)
[/code]
I edited /etc/fstab and added
[code]
192.168.1.100:/shares /mnt/nfs nfs _netdev,rsize=8192,wsize=8192,intr 0 0
[/code]
[code]
/shares 192.168.1.0/24(rw,sync)
[/code]
I edited /etc/fstab and added
[code]
192.168.1.100:/shares /mnt/nfs nfs _netdev,rsize=8192,wsize=8192,intr 0 0
[/code]
-
- Retired Moderator
- Posts: 18276
- Joined: 2006/12/13 20:15:34
- Location: Tidewater, Virginia, North America
- Contact:
Re: Mounting an NFS directory in /etc/fstab
Are you saying that solved the problem? If so, you have a DNS issue.
The /etc/exports file is used on the NFS [b]server[/b] and not on the [b]client[/b].
The /etc/exports file is used on the NFS [b]server[/b] and not on the [b]client[/b].
Re: Mounting an NFS directory in /etc/fstab
[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 [b]server[/b] and not on the [b]client[/b].[/quote]
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.
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 [b]server[/b] and not on the [b]client[/b].[/quote]
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.
-
- Retired Moderator
- Posts: 18276
- Joined: 2006/12/13 20:15:34
- Location: Tidewater, Virginia, North America
- Contact:
Re: Mounting an NFS directory in /etc/fstab
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.
Re: Mounting an NFS directory in /etc/fstab
[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.[/quote]
Thank you, that worked. I added
[code]
mount.nfs david.example.com:/shares /mnt/nfs
[/code]
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.
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.[/quote]
Thank you, that worked. I added
[code]
mount.nfs david.example.com:/shares /mnt/nfs
[/code]
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.