[SOLVED] Cannot get NFS 4 automount to work

General support questions
Post Reply
gerardratcliffe
Posts: 4
Joined: 2013/11/13 08:12:33

[SOLVED] Cannot get NFS 4 automount to work

Post by gerardratcliffe » 2013/11/16 09:48:27

I can not get NFS automount to work between a virtual machine and its host.

Both the host and the virtual machine are running Centos 6.3

The Host name is "GerardsPC" IP addr is 192.168.254.1
The Virtual machine name is "virt2" IP addr 192.168.122.222

I want to setup NFS automount to automatically mount a folder and files
on the host onto a folder on the virtual machine.

I have managed to get a manual NFS to work between the Host and virtual machine
by configuring the export file on the Virtual mach and doing a mount on the host.

However the NFS Automount function refuses to work

The configuration of the Host is as follows:

[root@GerardsPC /]# service nfs status
rpc.svcgssd is stopped
rpc.mountd (pid 7499) is running...
nfsd (pid 7564 7563 7562 7561 7560 7559 7558 7557) is running...
rpc.rquotad (pid 7495) is running...
[root@GerardsPC /]# service autofs status
automount (pid 2239) is running...
[root@GerardsPC /]#
[root@GerardsPC /]#
[root@GerardsPC /]# cat /etc/exports
# /tmp *(ro)
/home/virtnfs 192.168.122.0/24(rw,sync,no_root_squash,no_all_squash)
/nfshost/ 192.168.122.0/24(rw,sync,no_root_squash,no_all_squash)
[root@GerardsPC /]#
[root@GerardsPC /]# ll /nfshost/
total 0
-rw-r--r--. 1 root root 0 Nov 9 22:19 hostfile1
[root@GerardsPC /]#
[root@GerardsPC /]# mount
/dev/mapper/vg_gerardspc-lv_root on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda2 on /boot type ext4 (rw)
/dev/mapper/vg_gerardspc-lv_home on /home type ext4 (rw,acl)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
nfsd on /proc/fs/nfsd type nfsd (rw)
[root@GerardsPC /]#

The Virtual Machine (Client) setup is as follows:

[root@virt2 ~]# service nfs status
rpc.svcgssd is stopped
rpc.mountd (pid 1889) is running...
nfsd (pid 1952 1951 1950 1949 1948 1947 1946 1945) is running...
rpc.rquotad (pid 1885) is running...
[root@virt2 ~]# service autofs status
automount (pid 1841) is running...
[root@virt2 ~]#
[root@virt2 ~]#
[root@virt2 ~]# cat /etc/auto.master | grep -v ^#
/misc /etc/auto.misc
/net -hosts
+auto.master
/hostnfs /etc/auto.host
/virt1nfs /etc/auto.virt1
[root@virt2 ~]#
[root@virt2 ~]#
[root@virt2 ~]# cat /etc/auto.host
hostfiles -rw,soft,intr GerardsPC:/nfshost/

[root@virt2 ~]# ll /hostnfs/hostfiles/
ls: cannot access /hostnfs/hostfiles/: No such file or directory
[root@virt2 ~]#

If anybody can see any obvious mistakes please let me know, or any
suggetions for things to check.

Regards

User avatar
toracat
Site Admin
Posts: 7518
Joined: 2006/09/03 16:37:24
Location: California, US
Contact:

Re: Cannot get NFS 4 automount to work

Post by toracat » 2013/11/16 14:16:52

Try adding '-fstype=nfs' to the line in /etc/auto.host .
CentOS Forum FAQ

Whoever
Posts: 1361
Joined: 2013/09/06 03:12:10

Re: Cannot get NFS 4 automount to work

Post by Whoever » 2013/11/16 17:31:02

What do the following commands show when run on the virtual machine:

Code: Select all

ls /net/GerardsPC
showmount -e GerardsPC
Also, do the directories /net and /hostnfs exist on the virtual machine?

Does the iptables setup on the host allow NFS?
I have managed to get a manual NFS to work between the Host and virtual machine
by configuring the export file on the Virtual mach and doing a mount on the host.
But how about the reverse, since that is what you are trying to do with Automount?

gerardratcliffe
Posts: 4
Joined: 2013/11/13 08:12:33

Re: Cannot get NFS 4 automount to work

Post by gerardratcliffe » 2013/11/17 08:15:58

Thanks for the replies and the suggestions

Here are the answers to the questions asked

[root@virt2 ~]# service nfs status
rpc.svcgssd is stopped
rpc.mountd (pid 1893) is running...
nfsd (pid 1956 1955 1954 1953 1952 1951 1950 1949) is running...
rpc.rquotad (pid 1889) is running...
[root@virt2 ~]# service autofs status
automount (pid 1845) is running...
[root@virt2 ~]# cat /etc/auto.master | grep -v ^#
/misc /etc/auto.misc
/net -hosts
+auto.master
/hostnfs /etc/auto.host
/virt1nfs /etc/auto.virt1
[root@virt2 ~]#
[root@virt2 ~]#
[root@virt2 ~]# cat /etc/auto.host
hostfiles -rw,soft,intr GerardsPC:/nfshost/

[root@virt2 ~]# vi /etc/auto.host
[root@virt2 ~]#
[root@virt2 ~]# cat /etc/auto.host
hostfiles -fstype=nfs -rw,soft,intr GerardsPC:/nfshost/

[root@virt2 ~]# service autofs restart
Stopping automount: [ OK ]
Starting automount: [ OK ]
[root@virt2 ~]# ls /hostnfs/hostfiles/
ls: cannot access /hostnfs/hostfiles/: No such file or directory

I'm sure I have tried putting in the fstype before.
I have also turned off Selinux and the firewall on both host and virtual mach, all to no avail

[root@virt2 ~]#
[root@virt2 ~]#
[root@virt2 ~]# ls /net/GerardsPC
ls: cannot access /net/GerardsPC: No such file or directory
[root@virt2 ~]#
[root@virt2 ~]# showmount -e GerardsPC
clnt_create: RPC: Port mapper failure - Unable to receive: errno 113 (No route to host)
[root@virt2 ~]#
[root@virt2 ~]#
[root@virt2 ~]# ll / | grep net
drwxr-xr-x. 2 root root 0 Nov 17 20:23 net
[root@virt2 ~]# ll / | grep hostnfs
drwxr-xr-x. 2 root root 0 Nov 17 20:23 hostnfs
[root@virt2 ~]#
[root@virt2 ~]#
[root@virt2 ~]# ll /
total 104
dr-xr-xr-x. 2 root root 4096 Nov 4 21:49 bin
dr-xr-xr-x. 5 root root 1024 Aug 12 09:43 boot
drwxr-xr-x. 20 root root 3760 Nov 17 20:11 dev
drwxr-xr-x. 98 root root 12288 Nov 17 20:22 etc
drwxr-xr-x. 4 root root 4096 Nov 6 20:55 home
drwxr-xr-x. 2 root root 0 Nov 17 20:23 hostnfs
dr-xr-xr-x. 10 root root 4096 Aug 12 09:36 lib
dr-xr-xr-x. 9 root root 12288 Nov 4 21:49 lib64
drwx------. 2 root root 16384 Aug 12 09:21 lost+found
drwxr-xr-x. 2 root root 4096 Sep 23 2011 media
drwxr-xr-x. 2 root root 0 Nov 17 20:23 misc
drwxr-xr-x. 2 root root 4096 Sep 23 2011 mnt
drwxr-xr-x. 2 root root 0 Nov 17 20:23 net
drwxr-xr-x. 2 root root 4096 Nov 11 20:20 nfs-mnt
drwxr-xr-x. 3 root root 4096 Aug 12 09:40 opt
dr-xr-xr-x. 180 root root 0 Nov 17 20:10 proc
dr-xr-x---. 8 root root 4096 Nov 17 20:20 root
dr-xr-xr-x. 2 root root 12288 Nov 4 21:49 sbin
drwxr-xr-x. 7 root root 0 Nov 17 20:10 selinux
drwxr-xr-x. 2 root root 4096 Sep 23 2011 srv
drwxr-xr-x. 13 root root 0 Nov 17 20:10 sys
drwxr-xr-x. 2 root root 1024 Nov 6 20:59 test2
drwxr-xr-x. 2 root root 1024 Nov 6 20:59 test3
drwxrwxrwt. 16 root root 4096 Nov 17 20:25 tmp
drwxr-xr-x. 13 root root 4096 Aug 12 09:29 usr
drwxr-xr-x. 21 root root 4096 Aug 21 09:32 var
drwxr-xr-x. 2 root root 0 Nov 17 20:23 virt1nfs
[root@virt2 ~]#

[root@GerardsPC /]#
[root@GerardsPC /]# cat /etc/exports
# /tmp *(ro)
/home/virtnfs 192.168.122.0/24(rw,sync,no_root_squash,no_all_squash)
/nfshost/ 192.168.122.0/24(rw,sync,no_root_squash,no_all_squash)
[root@GerardsPC /]#
[root@GerardsPC /]# ll /nfshost/
total 0
-rw-r--r--. 1 root root 0 Nov 9 22:19 hostfile1
[root@GerardsPC /]# ll /home/virtnfs/
total 0
-rw-r--r--. 1 root root 0 Nov 6 21:28 clientfile1
-rw-r--r--. 1 root root 0 Nov 6 21:28 hostfile1
-rw-r--r--. 1 root root 0 Nov 6 21:30 virt2file
-rw-r--r--. 1 root root 0 Nov 9 21:13 virt2file2
[root@GerardsPC /]#
[root@GerardsPC /]# showmount -e virt2
clnt_create: RPC: Port mapper failure - Unable to receive: errno 113 (No route to host)
[root@GerardsPC /]#

[root@virt2 ~]# mount -t nfs GerardsPC:/home/virtnfs/ /nfs-mnt
[root@virt2 ~]#
[root@virt2 ~]# ll /nfs-mnt/
total 0
-rw-r--r--. 1 root root 0 Nov 6 21:28 clientfile1
-rw-r--r--. 1 root root 0 Nov 6 21:28 hostfile1
-rw-r--r--. 1 root root 0 Nov 6 21:30 virt2file
-rw-r--r--. 1 root root 0 Nov 9 21:13 virt2file2
[root@virt2 ~]#

Whoever
Posts: 1361
Joined: 2013/09/06 03:12:10

Re: Cannot get NFS 4 automount to work

Post by Whoever » 2013/11/17 16:49:48

gerardratcliffe wrote: Here are the answers to the questions asked

[root@virt2 ~]# showmount -e GerardsPC
clnt_create: RPC: Port mapper failure - Unable to receive: errno 113 (No route to host)
[root@virt2 ~]#
The issue is unrelated to the automounter. Did you check the firewall (iptables) setup on the host?

gerardratcliffe
Posts: 4
Joined: 2013/11/13 08:12:33

Re: Cannot get NFS 4 automount to work

Post by gerardratcliffe » 2013/11/18 09:00:05

I have finally got the automounter to work. :D

I had a look at the iptables file as suggested. But this didn't do a lot of good because I didn't know what I was looking at.

However google to the rescue. I found a tutorial on setting up NFS and it had a whole lot firewall rules to put into iptable
These changes where made on the host

here's the list

-A INPUT -m state --state NEW -m udp -p udp --dport 2049 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 2049 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 111 -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 32769 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 32803 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 892 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 892 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 875 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 875 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 662 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 662 -j ACCEPT

There were also suggested changes to the /etc/sysconfig/nfs file, as follows

[root@GerardsPC ~]# cat /etc/sysconfig/nfs | grep -v ^#
RQUOTAD_PORT=875
LOCKD_TCPPORT=32803
LOCKD_UDPPORT=32769
MOUNTD_PORT=892
STATD_PORT=662
STATD_OUTGOING_PORT=2020

restarted nfs and autofs services on the host and on the virtual machine did

[root@virt2 ~]# ll /hostnfs/hostfiles
total 0
-rw-r--r--. 1 root root 0 Nov 9 22:19 hostfile1
-rw-r--r--. 1 root root 0 Nov 18 20:39 hostfile2

The same files in the host

[root@GerardsPC nfshost]# pwd
/nfshost
[root@GerardsPC nfshost]# ll
total 0
-rw-r--r--. 1 root root 0 Nov 9 22:19 hostfile1
-rw-r--r--. 1 root root 0 Nov 18 20:39 hostfile2
[root@GerardsPC nfshost]#

I wasn't sure what had turned this service on so started commenting out the data I had entered in iptables and nfs files.

Narrowed it down to filewall rule

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

By commenting this line out and restarting the iptables service on the host and autofs service on the virtual mach I could make automount
fail.

I thought that I had proved the firewall was not the problem by turning the iptables service off. This was obviously a mistake :-( :oops:

The showmount command still does not work on either Host or virtual mach

[root@GerardsPC ~]# showmount -e virt2
clnt_create: RPC: Port mapper failure - Unable to receive: errno 113 (No route to host)
[root@GerardsPC ~]#


Once again thanks for all the help. I hope that someone will find this useful in the future.

certdepot
Posts: 11
Joined: 2013/11/18 13:26:44

Re: [SOLVED] Cannot get NFS 4 automount to work

Post by certdepot » 2013/11/18 14:44:14

Hi,

According to the RedHat documentation (https://access.redhat.com/site/document ... onfig.html), showmount doesn't work with NFSv4 any more.

In addition to the RedHat documentation previously mentioned, I have created a website about RHCSA & RHCE certifications called http://www.certdepot.net
As several of the RHCSA/RHCE objectives deal with NFS configuration, you will find there step by step NFS & autofs configuration instructions (http://www.certdepot.net/nfs-provide-network-shares/).

Regards.
Last edited by certdepot on 2013/11/19 13:47:05, edited 1 time in total.

gerardratcliffe
Posts: 4
Joined: 2013/11/13 08:12:33

Re: [SOLVED] Cannot get NFS 4 automount to work

Post by gerardratcliffe » 2013/11/19 09:03:21

Thanks for the links to the CertDepot web site. This will be useful as I am planing on doing the RHCSA exam

Post Reply