3

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

MadHatter
  • 78,442
  • 20
  • 178
  • 229
user173639
  • 31
  • 1
  • 1
  • 2
  • You've assured us that `client` can mount `10.0.0.14:/home/unixmen` manually, yes? You can confirm that `ls -al /misc/unixmen` returns a file-not-found error, yes? My next point is I've never seen `-fstype=nfs` in an automount table before; my belief is that's implied and may not be valid to state. Could you try removing that, restarting `automount` and then doing `ls -la /misc/unixmen`? – MadHatter Jun 27 '14 at 06:59
  • Yes I deleted -fstype=ns from the entry , now its like this in the file cat /etc/auto.misc unixmen 10.0.0.14:/home/unixmen restarted autofs , but the change is pretty the same, unable to view the mounted partition . ls -l /misc returns 0 – user173639 Jun 27 '14 at 07:04
  • And what did you get when, after restarting `automount`, you did the `ls`? Also, can you confirm the two previous points in my comment? – MadHatter Jun 27 '14 at 07:04
  • I didn't ask for `ls -l`, I asked for `ls -al`, and (sorry to ask) can you confirm that you're doing it on `/misc/unixmen`, not just `/misc`? Your question makes that unclear. I presume that showed only `.` and `..`, but it would be useful to have it confirmed - and better still to **see** it (cut-and-paste both command and output into your answer). Still seeking confirmation on my first two points as well. – MadHatter Jun 27 '14 at 07:07
  • 1
    I do not see unixmen directory at all, tried many times ls -al /misc/ total 4 drwxr-xr-x. 2 root root 0 Jun 27 18:33 . dr-xr-xr-x. 25 root root 4096 Jun 27 00:31 .. [root@ganeshh ~]# ls -al /misc/ total 4 drwxr-xr-x. 2 root root 0 Jun 27 18:33 . dr-xr-xr-x. 25 root root 4096 Jun 27 00:31 .. – user173639 Jun 27 '14 at 07:16
  • I don't mean to sound tetchy, but the detail is important in this stuff. Firstly, please **cut and paste output into your question**. It helps preserve the formatting and makes it easier to read. Secondly, thank you for including the `a` flag. It reveals useful information; the zero size of `.` is an indicator that `automount` is running and possesses the directory. Thirdly, I didn't ask if you'd seen the unximen directory, I asked what you got when you did `ls -al /misc/unixmen`. – MadHatter Jun 27 '14 at 07:20
  • Oh mine ls -al /misc/unixmen total 8472 drwxr-xr-x. 2 nobody nobody 4096 Jun 25 16:23 . drwxr-xr-x. 3 root root 0 Jun 27 18:52 .. -rw-r--r--. 1 nobody nobody 137868 Jun 24 12:00 zabbix-2.2.0-1.el6.i386.rpm I did see it now, so I was not testing it properly? – user173639 Jun 27 '14 at 07:23
  • There is a rational explanation for all this - it was always working, but you were expecting the wrong thing. I'll write up a full answer in a few minutes. Glad it's working now, but **please, please, learn to edit updates into your questions** instead of adding data in comments. It's nearly unreadable, and won't generally help you get high-quality answers. – MadHatter Jun 27 '14 at 07:27
  • Got you point, will wait for your post – user173639 Jun 27 '14 at 07:28
  • I apologise if you already know this, but local etiquette is that when you're happy with an answer to your question, you accept it by clicking the tick outline next to it. This drives the SF reputation system both for you and the author of the answer, and prevents the question floating around forever like a querulous albatross. – MadHatter Jun 27 '14 at 07:44

1 Answers1

5

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.

MadHatter
  • 78,442
  • 20
  • 178
  • 229
  • Lakeland Fells - cool naming convention. – user9517 Jun 27 '14 at 07:49
  • why, thank you! At this site, we started from the top down (scafell - one-word peaks only) and are working down towards 1000'. See also http://serverfault.com/questions/479945/choosing-between-meaningful-and-meaningless-hostnames/479947#479947 . – MadHatter Jun 27 '14 at 08:00
  • 1
    MadHatter's solution is wonderful. Additionally, if your map file has the execute permission, remove the execute permission. For example, `chmod -x /etc/auto.map`. This is necessary so that automount does not execute /etc/auto.map, and instead will read /etc/auto.map. – JeremyCanfield Sep 01 '17 at 02:18