一般我们都有是用Linux手动挂载方法:mount /dev/cdrom /mnt 和手动?载:umont /dev/cdrom.如果要频繁的挂载外设,那么你肯定想像Windows上一样可以随装随用。Automounter可以解决。
1、Automounter作用:自动挂载访问的移动介质,分区等。
Automounter的软件包是autofs,在安装操作系统光盘上有,一般都自动的安装了。
如果不踏实可以查看下#rpm -aq | grep autofs
没有就到光盘中去找,哪一张就看不同的操作系统了。
2、主配置文件:/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
#/net /etc/auto.net
/misc /etc/auto.misc --timeout=60
格式:挂载目录 映射文件 参数
/misc /etc/auto.misc --timeout=60
默认都是注释了,可以去掉注释符也可以拷一个或者自己手动打。注意的是如果加多个,挂载的目录名不能一样。
2、映射文件:/etc/auto.misc
# 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
格式:关键字(唯一) 挂载选项 设备
注意:
1、关键字在该文件中唯一
2、本地设备之前要用冒号。
3、有一个关键字为cd的是默认打开的。
4、具体的挂载选项要查看
5、注意主配置文件与映像文件的对应关系(红色标记)。
3、更改好上面的两个文件后,重启服务:#service autofs restart
4、访问设备的方法:挂载目录+关键字
如: ls /misc/cd
cd /misc/cd
再换张光盘再进入那个目录,会发现不用手动挂载就可以访问了。
注意:Automounter控制原理:用超时(--timeout=60)来控制挂载的关闭,以节约资源。用cd进入或ls查看来打开挂载。另外Automounter还可以自动挂载U盘,文件系统,等。