Chinaunix首页 | 论坛 | 博客
  • 博客访问: 481868
  • 博文数量: 82
  • 博客积分: 3003
  • 博客等级: 中校
  • 技术积分: 1285
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-11 15:27
文章分类

全部博文(82)

文章存档

2011年(1)

2010年(5)

2009年(63)

2008年(13)

我的朋友

分类:

2009-10-09 23:41:25

How it works

1.Autofs function

mount是用来挂载文件系统的,可以在系统启动的时候挂载也可以在系统启动后挂载。对于本地固定设备,如硬盘可以使用mount挂载;而光盘、软盘、NFSSMB等文件系统具有动态性,即需要的时候才有必要挂载。光驱和软盘我们一般知道什么时候需要挂载,但NFSSAMBA共享等就不一定知道了,即我们一般不能及时知道NFS共享和SMB什么时候可以挂载。而autofs服务就提供这种功能,好像windows中的光驱自动打开功能,能够及时挂载动态加载的文件系统。免去我们手动挂载麻烦。要实现光驱,软盘等的动态自动挂载,需要进行相关的配置。

2.Autofs configuration

主要配置文件有两个:/etc/auto.master /etc/auto.misc其中/etc/auto.master是起控制作用的,它定义了挂载点和automount动作的文件。/etc/auto.misc中定义了automount动作,/etc/auto.misc中定义的资源只有在试图访问的时候才会去自动挂载,而在一段时间之后,如果你不再使用这些资源,autofs会自动卸载这些资源。默认时间为5分钟(300),此选项由/etc/sysconfig/autof定义,根据需要可以修改。

Environment

Red Hat Enterprise linux 5u3

Procedure

1 Configure NFS server

#setup %set a static IP

#service nerwork restart

#ifconfig %IP of server is 192.168.0.1

#vi /etc/exports %edit the file as below

/tmp *(rw,sync) %allow all clients to share the folder

#service nfs start

#showmount -e %check the nfs configuration works

2 Configure autofs files

#setup %set a static IP according to the configuration file of nfs server

%or get IP through DHCP server

#service network restart

#ifconfig %check the IP change

#vi /etc/auto.master %uncomment the other lines and add a line as below

#

# $Id: auto.master,v 1.4 2005/01/04 14:36:54 raven Exp $

#

# 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

/misc /etc/auto.misc –timeout=30 %the default invalid time is 300 seconds which is defined in

                                                                %/etc/sysconfig/autofs and change it to 30 seconds

#vi /etc/auto.misc

#

# $Id: auto.misc,v 1.2 2003/09/29 08:22:35 raven Exp $

#

# This is an automounter map and it has the following format

# key [ -mount-options-separated-by-comma ] location

# Details may be found in the autofs(5) manpage


cd -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom


# the following entries are samples to pique your imagination

...

nfs -rw,soft,intr 192.168.0.1:/tmp

Notice: You can create autofs map file by hand and locate it in the directory /etc/** 

3 Start autofs service

#service autofs start

4 Test the automount

#ls /misc -a

. ..

#ls /misc/nfs -a

#ls /misc -a %after 30 seconds ,you may find the directory unmounted


Troubles

当遇到无法自动挂载/misc/nfs

1尝试能否手动挂载

#mount -t nfs 192.168.0.1:/tmp

2.1如果无法手动挂载则说明为nfs配置或网络的问题,为进一步确认分别执行ping命令

如果ping 不通,在没有防火墙的简单网络环境下,则将与IP设置相关,查看IP配置;

ping通则应检查nfs的配置,是否允许客户端所在IP访问共享目录,并执行exportfs命令,查看配置是否生效。

2.2若能手动挂载则说明为autofs 配置文件的问题

查看配置文件/etc/auto.master/etc/auto.misc

查看定义的挂载点,是否已被其他远程目录占用,但用户没有权限查看此目录

阅读(707) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~