首页 > 其他 > 详细

autofs自动挂载

时间:2018-05-14 17:31:27      阅读:203      评论:0      收藏:0      [点我收藏+]
一般我们将需要挂载的信息写入到/etc/fstab中,这样远程共享资源时就会自动随着服务器开机而进行挂载了,这样虽然很方便,但是如果挂载的远程资源太多时,则会给宽带和服务器的资源带来较大的负载。假若资源挂载后长期不使用,也会造成服务器硬件资源的浪费。

今天我们来学习下自动挂载,当检测到用户访问一个尚未挂载的文件系统时将自动进行动态挂载,从而节约了网络资源和服务器的硬件资源。

例题:通过autofs自动挂载光驱文件

1. 安装autofs软件包

yum install autofs -y

2. 编辑主配置文件,格式为“挂载目录 子配置文件”

vim /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
/mnt    /etc/auto.cdrom     #新增加的挂载条目
#
# 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 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

3. 修改子配置文件,格式为“挂载目录 挂载文件类型及权限 :设备名称”

vim /etc/auto.cdrom

#挂载目录:cdrom 文件类型:iso9660 ,权限:只读,

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

4. 重启服务

service autofs restart

5. 测试(提醒:自动挂载的有效期为300秒)

技术分享图片

autofs自动挂载

原文:http://blog.51cto.com/10316297/2116195

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!