Nfs – automount – autofs mount issue on CentOS 6.5

nfsnfs4

Server CentOS 6.5 and Selinux is permissive

My NFS server share in /etc/exports

/home/unixmen/  10.0.0.0/24 (rw,sync,no_root_squash)

Client running on another CentOS 6.5 host , is able to mount normally..

When I try automount with autofs, nothing works, did lot to google search of this issue to figure out the root cause, yet unsuccessful.

I am wondering if I am doing something basic error..

Please see the autofs configs

~]$ cat /etc/auto.master
#/net -hosts
#+auto.master
/misc /etc/auto.misc

and

~]$ cat /etc/auto.misc
unixmen -fstype=nfs 10.0.0.14:/home/unixmen

I did change the log level to debug in /etc/sysconfig/autofs, post restarting the autofs
and log says

Jun 27 17:20:00 ganeshh automount[12322]: mounted indirect on /misc with timeout 300, freq 75 seconds

Not sure if this is related to mount issue

Recently now, I get this data in the log

Jun 27 18:11:49 ganeshh automount[12322]: expire_proc: exp_proc = 3063937904 path /misc
Jun 27 18:11:49 ganeshh automount[12322]: expire_cleanup: got thid 3063937904 path /misc stat 0
Jun 27 18:11:49 ganeshh automount[12322]: expire_cleanup: sigchld: exp 3063937904 finished, switching from 2 to 1
Jun 27 18:11:49 ganeshh automount[12322]: st_ready: st_ready(): state = 2 path /misc

eventually there is not mounted files in /misc directory

Best Answer

Now we've got it working (-fstype=nfs is not needed, and probably not valid, in a map) your question betrays a misunderstanding about how automount presents to the user.

Here's an automount entry in my master file

/mnt    /etc/auto.master.d/mnt

and the corresponding map

# cat /etc/auto.master.d/mnt
helvellyn       -ro,soft,intr   10.18.145.31:/var/log/httpd
bowfell         -ro,soft,intr   10.18.145.27:/var/log/httpd

Now here's some ls output on the trigger directory

# ls -al /mnt
total 4
drwxr-xr-x  2 root root    0 Jun 14 10:01 .
dr-xr-xr-x 25 root root 4096 Jun 27 03:37 ..

Note that a) the directory is empty, and that b) the size is 0 bytes. The former confused you, and the latter is unlawful: even an empty directory has size 4096 bytes. But the zero is a shorthand way of knowing that automount has correctly read your maps, and is possessing the directory. You can also check with df:

# df -k /mnt
Filesystem             1K-blocks  Used Available Use% Mounted on
/etc/auto.master.d/mnt         0     0         0    - /mnt

Now let's list the target directory, even though the parent is apparently empty:

# ls -al /mnt/helvellyn
total 761548
drwxr-xr-x 2 root root      4096 Jun 23 13:21 .
drwxr-xr-x 3 root root         0 Jun 27 07:31 ..
-rw-r--r-- 1 root root         0 Jun  1 03:18 access_log
-rw-r--r-- 1 root root   7485078 May 11 03:09 access_log-20140511
-rw-r--r-- 1 root root   7052254 May 18 03:06 access_log-20140518
-rw-r--r-- 1 root root   5357900 May 25 03:28 access_log-20140525
-rw-r--r-- 1 root root    577579 May 25 16:36 access_log-20140601
[...]

Content magically appears! Now let's list the parent again:

# ls -al /mnt
total 8
drwxr-xr-x  3 root root    0 Jun 27 07:31 .
dr-xr-xr-x 25 root root 4096 Jun 27 03:37 ..
drwxr-xr-x  2 root root 4096 Jun 23 13:21 helvellyn

Automount really does do demand-driven mounting (and unmounting). Since /mnt/helvellyn won't be mounted until you try to access it, you cannot see it until the first access triggers the mount.

I hope you will forgive me for adding that if you take one other lesson from this answer, it should be that detail is vitally important in UNIX sysadmin. If an instruction asks you to do do X, it may well be important to do exactly X, and not something that you think is entirely equivalent to X. That little zero-size directory should give you some indication of how little information is sometimes presented to you to know that certain things, particular older UNIX-things, are working correctly. If, through imprecision, you skate past those tiny signs, UNIX won't give you anything else to go on, and confusion may result.