autofs触发挂载简单说就是在用户在需要某些资源的时候会自动加载,这一点在资源通过网络文件系统(NFS)访问的服务器之间尤为方便。
1,先查看一下自己的机子有没有安装触发挂载工具,如果没有安装请通过搭建yum库或者其他方法安装autofs工具
[root@localhost ~]# rpm -q autofs
autofs-5.0.1-0.rc2.177.el5……已安装
2,用vim编辑/etc/auto.master,添加自动触发挂载配置
[root@localhost~]# vim /etc/auto.master
#
# $Id:auto.master,v 1.4 2005/01/04 14:36:54 raven Exp $
#
# Sampleauto.master file
# This is anautomounter map and it has the following format
# key [-mount-options-separated-by-comma ] location
# For details ofthe format look at autofs(5).
#
/misc /etc/auto.misc
/data /etc/auto.file……追加一行 /data 挂载点父目录
/etc/auto.file 挂载配置文件(自定义)
#
# NOTE: mountsdone from a hosts map will be mounted with the
# "nosuid" and "nodev"options unless the "suid" and "dev"
# options are explicitly given.
#
/net -hosts
#
# Includecentral master map if it can be found using
# nsswitchsources.
#
# Note that ifthere are entries for /net or /misc (as
# above) in theincluded master map any keys that are the
# same will notbe seen as the first read key seen takes
-- INSERT-- 10,23 Top
3,vim创建并且编辑挂载配置文件
[root@localhost~]# vim /etc/auto.file
file -fstype=ext3 :/dev/sda5 ……file 挂载点子目录(无需创建)
fstype=ext3 挂载参数
:/dev/sad5 挂载设备名
~
1,28 All
4,开启autofs服务
[root@localhost data]# service autofs restart …….重新开启服务
Stopping automount: [ OK ]
Starting automount: [ OK ]
[root@localhost data]#
5,验证配置正确性
[root@localhost ~]# cd /data/
[root@localhost data]# ls
[root@localhost data]# ……没有目录
[root@localhost data]# cd file
[root@localhost file]# ……挂载成功
[root@localhost file]# df -lT
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/sda2 ext3 20315844 2444060 16823144 13% /
/dev/sda1 ext3 101086 12200 83667 13% /boot
tmpfs tmpfs 511920 0 511920 0% /dev/shm
/dev/sda5 ext3 9621848 152688 8980384 2%/data/file
转载于:https://blog.51cto.com/1570880775/1362304