autofs的配置文件:

/etc/auto.master               自动挂载程序automounter的主映射文件
/etc/auto.misc                  挂载点映射定义
www. On IT Road .com

配置autofs

autofs 自动挂载程序使用配置文件 /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 --timeout=60
#/misc  /etc/auto.misc
#/net   /etc/auto.net

除了 /etc/auto.master 文件,autofs 还会检查 NIS 映射。
如果存在这样的映射,则该映射将按照与 auto.master 映射相同的方式进行处理。
NIS 映射将最后处理。

如auto.master 文件所示,所有挂载点映射被划分为不同的类别,例如misc、net 等。
每个文件包含一些带有详细挂载选项的映射。
例如/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
#linux          -ro,soft,intr           ftp.example.org:/pub/linux
#boot           -fstype=ext2            :/dev/hda1
#floppy         -fstype=auto            :/dev/fd0
#floppy         -fstype=ext2            :/dev/fd0
#e2floppy       -fstype=ext2            :/dev/fd0
#jaz            -fstype=ext2            :/dev/sdc1
#removable      -fstype=ext2            :/dev/hdd

服务控制

该服务由 init.d 脚本 /etc/init.d/autofs 处理。
其用法如下:

# /sbin/service autofs
Usage: /etc/init.d/autofs {start|stop|restart|reload|condrestart|status}

启动autofs服务:

# /sbin/service autofs start
Starting automount: No Mountpoints Defined                 [  OK  ]

停止autofs服务:

# /sbin/service autofs stop
Stopping automount:                                        [  OK  ]

检查autofs服务是启动还是停止:

# /sbin/service autofs status
Configured Mount Points:
-----------------------
Active Mount Points:
-------------------
#

重新启动将终止正在运行的守护进程并再次启动服务。

# service autofs restart
Stopping automount:                                        [  OK  ]
Starting automount: No Mountpoints Defined                 [  OK  ]

如果服务已启动,则重新启动它;否则什么都不做。

# service autofs condrestart

重新加载命令将针对正在运行的守护进程检查 auto.master 映射。
它将杀死那些条目已更改的守护程序,然后为新条目或者已更改条目启动守护程序。

# service autofs reload

查询服务的运行级别信息以在重新启动后检查服务启动选项:

# chkconfig --list autofs
autofs      0:off   1:off   2:on    3:on    4:on    5:on    6:off

autofs服务说明

这将执行自动挂载守护程序以进行文件系统挂载。
“自动挂载”守护进程“在客户端向该守护进程发送请求时挂载文件系统”,“在长时间没有请求时卸载它”。
Linux 中有两种类型的自动挂载程序,autofs 和 AMD。
AMD 是在用户空间中实现的,而不是内核的一部分。
但是,autofs 是由内核辅助的较新系统,它需要内核杠杆支持。

如前所述,autofs 是在内核空间中实现的,因此为了使用 autofs,内核必须编译支持。
从 2.2.xx 开始的所有内核版本都支持 autofs。
以下命令可用于检查它是否在内核中编译。

# cat /proc/filesystems | grep autofs
nodev   autofs
#

autofs 使用“maps”来定义要挂载的文件系统。
不同的自动挂载器映射彼此不兼容,例如:amd 映射与 autofs 不兼容。
当 autofs 启动时,它会参考配置文件 /etc/auto.master 来查找系统上的挂载点。
对于这些挂载点中的每一个,都会使用适当的参数启动自动挂载过程。
处理完 auto.master 配置文件后,autofs 将检查具有相同名称的 NIS 映射。

autofs 不应该用在需要更高性能的系统中,因为动态挂载会带来一些开销。

包含此服务的 RPM 包是:

autofs
Nature
Linux/UNIX 操作系统autofs服务
日期:2020-09-17 00:14:34 来源:oir作者:oir