LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Autofs doesn't work (https://www.linuxquestions.org/questions/linux-newbie-8/autofs-doesnt-work-4175427686/)

rahilmaknojia 09-17-2012 01:52 PM

Autofs doesn't work
 
I have setup autofs to mount nfs automatically every I want to use it.

Here are the basic configurations I made in files:


[root@server2 /]# cat /etc/auto.master | grep -v ^#
/misc /etc/auto.misc
/shares /etc/auto.shares
/net -hosts
+auto.master

[root@server2 /]# cat /etc/auto.shares | grep -v ^#
nfs -fstype=nfs 192.168.122.1:/nfs

[root@server2 /]# cat /etc/sysconfig/autofs | grep -v ^#
TIMEOUT=300
BROWSE_MODE="no"
MOUNT_NFS_DEFAULT_PROTOCOL=4
USE_MISC_DEVICE="yes"


[root@server2 /]# ll /shares/
total 0
[root@server2 /]# ll /shares/
total 0
[root@server2 /]# ll /shares/
total 0
[root@server2 /]# ll /shares/
total 0
[root@server2 /]# ll /shares/
total 0

I did reboot the system, but it doesnt automatically mount on /shares directory, but if I manually mount nfs, it works!

[root@server2 /]# mount -t nfs 192.168.122.1:/nfs /shares/
[root@server2 /]# ll /shares/
total 0
-rw-r--r--. 1 root root 0 Sep 17 2012 selinux.txt

Any idea whats wrong with autofs?

lleb 09-17-2012 02:43 PM

i am still semi new to autofs, but from what i have seen it will not auto mount on boot, that is what fstab is for. when you goto view the directory (mount points) autofs will mount the shares and you will have access to them.

rahilmaknojia 09-17-2012 02:46 PM

Quote:

Originally Posted by lleb (Post 4782577)
i am still semi new to autofs, but from what i have seen it will not auto mount on boot, that is what fstab is for. when you goto view the directory (mount points) autofs will mount the shares and you will have access to them.

Indeed you are right, but after accessing the shares directory, it doesn't automatically mount. :(

lleb 09-17-2012 03:05 PM

ahh, now that would be a problem. i had to play with it on the cifs mounts i put in. let met post what i have for my cifs:

Code:

cat /etc/auto.master
#
# Sample auto.master file
# This is an automounter map and it has the following format
# key [ -mount-options-separated-by-comma ] location
# For details of the format look at autofs(5).
#
/misc        /etc/auto.misc
#
# NOTE: mounts done from a hosts map will be mounted with the
#        "nosuid" and "nodev" options unless the "suid" and "dev"
#        options are explicitly given.
#
/net        -hosts
#
# Include /etc/auto.master.d/*.autofs
#
+dir:/etc/auto.master.d
#
# Include central master map if it can be found using
# nsswitch sources.
#
# Note that if there are entries for /net or /misc (as
# above) in the included master map any keys that are the
# same will not be seen as the first read key seen takes
# precedence.
#
+auto.master
/mnt/newguyz        /etc/auto.newguyz        --timeout=600        --ghost
/mnt/techs        /etc/auto.techs                --timeout=600        --ghost


$ cat /etc/auto.newguyz
newguyz        -fstype=cifs,rw,noperm,username=XXXXXX,password=XXXXXXX        ://10.10.0.73/NewGuyz



$ cat /etc/auto.techs
techs -fstype=cifs,rw,noperm,username=XXXXXXXX,password=XXXXXXXXXXXXX        ://10.10.0.73/Techs

see if that helps any.

rahilmaknojia 09-17-2012 04:09 PM

It didn't help much with

[root@server2 /]# cat /etc/auto.master | grep -v ^#
/misc /etc/auto.misc
/shares /etc/auto.shares --timeout=600 --ghost
/net -hosts
+auto.master

rahilmaknojia 09-17-2012 09:06 PM

Doesn't anyone know how to fix the issue?

chrism01 09-17-2012 09:13 PM

autofs can use lazy mounting ( -hosts) ; this means it only actually mounts the share when you access the content eg cd into it.
https://access.redhat.com/knowledge/...ig-autofs.html

rahilmaknojia 09-17-2012 09:35 PM

Quote:

Originally Posted by chrism01 (Post 4782851)
autofs can use lazy mounting ( -hosts) ; this means it only actually mounts the share when you access the content eg cd into it.
https://access.redhat.com/knowledge/...ig-autofs.html

Right, but when I ls into the directory I provided mount_point in auto.master file, it doesn't mount when I cd or ls into the directory I created for auto mount.

Here is the different linux box I tried on:

[root@rhel6 ~]# cat /etc/auto.master | grep -v ^#
/misc /etc/auto.misc
/net -hosts
+auto.master
/shares /etc/auto.shares

[root@rhel6 ~]# cat /etc/auto.shares | grep -v ^#
nfs -fstype=nfs 172.16.1.23:/nfs

[root@rhel6 ~]# cat /etc/sysconfig/autofs | grep -v ^#
TIMEOUT=300
BROWSE_MODE="no"
MOUNT_NFS_DEFAULT_PROTOCOL=4
USE_MISC_DEVICE="yes"

FIREWALL>>>>>>>>>>>>>>

[root@rhel6 ~]# cat /etc/sysconfig/iptables | grep -v ^#
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 21 -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 137 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5900:5905 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

I hope this gives you more details.

rahilmaknojia 09-18-2012 01:17 AM

Okay here is the deal and I tell you whats going on after playing wit different system all day.

I have CentOS6.3 box running with two KVM known as server2 and tester1. I have one more box, but that has RHEL6.1. So when I use autofs in RHEL box, it works! Only trouble I had was that I wasn't doing cd nfs inside shares folder. When I did "cd nfs" it automatically mounted nfs drive in rhel box.

Now, on KVM's. SO as I said KVM's are running on Centos6.3 box. NFS server is running on main box (CentOS6.3) and I am trying to run autofs on server2, but I cannot get it to mount. Both are on same network with 192.168.122.0/24. Both can ping each other, but when I configure autofs and try to use the mount_point, but doesn't work.

Here is what happens:

[root@server2 /]# cd share/
[root@server2 share]# cd nfs
-bash: cd: nfs: No such file or directory
[root@server2 share]#

rahilmaknojia 09-18-2012 01:25 PM

Here is the log from messages

Sep 17 04:02:55 server2 automount[1800]: lookup_read_master: lookup(nisplus): couldn't locate nis+ table auto.master
Sep 17 04:03:11 server2 automount[1800]: key "-" not found in map source(s).
Sep 17 04:05:22 server2 automount[1800]: umount_autofs_indirect: ask umount returned busy /share
Sep 17 04:05:26 server2 automount[1865]: lookup_read_master: lookup(nisplus): couldn't locate nis+ table auto.master
Sep 17 04:05:31 server2 automount[1865]: key "-" not found in map source(s).


All times are GMT -5. The time now is 11:36 PM.