autofs一般与ldap、nfs协作实现远程home目录。
编辑主配置文件:
vim /etc/auto.master
/mnt /etc/auto.nfs
新建auto.nfs配置文件:
vim /etc/auto.nfs
nfs 192.168.17.253:/mnt/share
/mnt下没有nfs目录:
[root@rhel6-client ~]# ls -al /mnt
total 4
drwxr-xr-x. 2 root root 0 Feb 26 12:35 .
dr-xr-xr-x. 27 root root 4096 Feb 26 12:35 ..
重启autofs服务:
[root@rhel6-client ~]# service autofs stop
Stopping automount: [ OK ]
[root@rhel6-client ~]# service autofs start
Starting automount: [ OK ]
[root@rhel6-client ~]# ls -al /mnt
total 4
drwxr-xr-x. 2 root root 0 Feb 26 12:45 .
dr-xr-xr-x. 27 root root 4096 Feb 26 12:35 ..
访问/mnt/nfs时,该目录自动挂载:
[root@rhel6-client ~]# ls -al /mnt/nfs
total 8
drwxr-xr-x. 2 nobody nobody 4096 Feb 25 19:58 .
drwxr-xr-x. 3 root root 0 Feb 26 12:45 ..
-rw-r--r--. 1 nobody nobody 6 Feb 25 19:58 share.txt
[root@rhel6-client ~]#
REF: http://linux.vbird.org/linux_server/0330nfs.php#nfsclient_autofs