Linux系统如何安装AutoFs挂载服务
无论是Samba服务还是NFS服务,都要把挂载信息写入到/etc/fstab中,这样远程共享资源就会自动随服务器开机而进行挂载。 |
[root@localhost ~]# yum install autofs Loaded plugins: langpacks, product-id, subscription-manager ...... Running transaction Installing : hesiod-3.2.1-3.el7.x86_64 1/2 Installing : 1:autofs-5.0.7-40.el7.x86_64 2/2 Verifying : hesiod-3.2.1-3.el7.x86_64 1/2 Verifying : 1:autofs-5.0.7-40.el7.x86_64 2/2 Installed: autofs.x86_64 1:5.0.7-40.el7 Dependency Installed: hesiod.x86_64 0:3.2.1-3.el7 Complete!
处于生产环境中的Linux服务器,一般会同时管理许多设备的挂载操作。如果把这些设备挂载信息都写入到autofs服务的主配置文件中,无疑会让主配置文件臃肿不堪,不利于服务执行效率,也不利于日后修改里面的配置内容,因此在 autofs 服务程序的主配置文件中需要按照“挂载目录 子配置文件”的格式进行填写。挂载目录是设备挂载位置的上一级目录。
例如,光盘设备一般挂载到/media/cdrom目录中,那么挂载目录写成/media即可。对应的子配置文件则是对这个挂载目录内的挂载设备信息作进一步的说明。子配置文件需要用户自行定义,文件名字没有严格要求,但后缀必须以.misc结束。具体的配置参数如第7行的加粗字所示。
[root@localhost ~]# 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). /media /etc/iso.misc /misc /etc/auto.misc # # 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 /etc/auto.master.d/*.autofs +dir:/etc/auto.master.d # # 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
在子配置文件中,应按照“挂载目录 挂载文件类型及权限 :设备名称”的格式进行填写。例如,要把光盘设备挂载到/media/iso目录中,可将挂载目录写为iso,而-fstype为文件系统格式参数,iso9660为光盘设备格式,ro、nosuid及nodev为光盘设备具体的权限参数,/dev/cdrom则是定义要挂载的设备名称。配置完成后再顺手将autofs服务程序启动并加入到系统启动项中:
[root@localhost ~]# vim /etc/iso.misc iso -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom [root@localhost ~]# systemctl start autofs [root@localhost ~]# systemctl enable autofs ln -s '/usr/lib/systemd/system/autofs.service' '/etc/systemd/system/multi-user.target.wants/autofs.service'
接下来将发生一件非常有趣的事情。我们先查看当前的光盘设备挂载情况,确认光盘设备没有被挂载上,而且/media目录中根本就没有iso子目录。但是,我们却可以使用cd命令切换到这个iso子目录中,而且光盘设备会被立即自动挂载上。我们也就能顺利查看光盘内的内容了。
[root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/rhel-root 18G 3.0G 15G 17% / devtmpfs 905M 0 905M 0% /dev tmpfs 914M 140K 914M 1% /dev/shm tmpfs 914M 8.9M 905M 1% /run tmpfs 914M 0 914M 0% /sys/fs/cgroup /dev/sda1 497M 119M 379M 24% /boot [root@linuxprobe ~]# cd /media [root@localhost media]# ls [root@localhost media]# cd iso [root@localhost iso]# ls -l total 812 dr-xr-xr-x. 4 root root 2048 May 7 2017 addons dr-xr-xr-x. 3 root root 2048 May 7 2017 EFI -r--r--r--. 1 root root 8266 Apr 4 2017 EULA -r--r--r--. 1 root root 18092 Mar 6 2012 GPL dr-xr-xr-x. 3 root root 2048 May 7 2017 images dr-xr-xr-x. 2 root root 2048 May 7 2017 isolinux dr-xr-xr-x. 2 root root 2048 May 7 2017 LiveOS -r--r--r--. 1 root root 108 May 7 2017 media.repo dr-xr-xr-x. 2 root root 774144 May 7 2017 Packages dr-xr-xr-x. 24 root root 6144 May 7 2017 release-notes dr-xr-xr-x. 2 root root 4096 May 7 2017 repodata -r--r--r--. 1 root root 3375 Apr 1 2017 RPM-GPG-KEY-redhat-beta -r--r--r--. 1 root root 3211 Apr 1 2017 RPM-GPG-KEY-redhat-release -r--r--r--. 1 root root 1568 May 7 2017 TRANS.TBL
[root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/rhel-root 18G 3.0G 15G 17% / devtmpfs 905M 0 905M 0% /dev tmpfs 914M 140K 914M 1% /dev/shm tmpfs 914M 8.9M 905M 1% /run tmpfs 914M 0 914M 0% /sys/fs/cgroup /dev/cdrom 3.5G 3.5G 0 100% /media/iso /dev/sda1 497M 119M 379M 24% /boot
Linux系统如何安装AutoFs挂载服务相关推荐
- 在RedHat Linux系统中安装和配置snmp服务
在RedHat Linux系统中安装和配置snmp服务 检查系统是否安装snmp服务 # rpm -qa|grep snmp net-snmp-5.3.2.2-17.el5 net-snmp-perl ...
- Linux系统下安装FTP服务
Linux系统下安装FTP服务 1. 简介 2. 工作原理 3. FTP的安装与配置 1. 下载vsftp安装包 2. 检查是否已经安装了vsftp,后面会介绍怎样卸载 3. 安装vsftpd 4. ...
- 在 Linux 系统中安装Load Generator ,并在windows 调用
在 Linux 系统中安装Load Generator ,并在windows 调用 由于公司需要测试系统的最大用户承受能力,所以需要学习使用loadrunner.在安装的时候碰到了不少问题,所以写下此 ...
- linux 显卡驱动无法安装程序,linux系统下安装显卡驱动程序
<linux系统下安装显卡驱动程序>由会员分享,可在线阅读,更多相关<linux系统下安装显卡驱动程序(6页珍藏版)>请在人人文库网上搜索. 1.linux系统下安装显卡驱动程 ...
- 在linux系统里安装软件,请问在linux系统里怎样安装软件
请问在linux系统里怎样安装软件 关注:206 答案:10 信息版本:手机版 解决时间 2019-01-14 19:35 雾里闻花香 2019-01-13 20:41 朋友谁能告诉我在linux ...
- 关于内网linux系统如果安装nodejs,npm,express,mongodb,forever等
内网的linux系统要安装nodejs以及express等系列的框架,因为系统是局域网和互联网是物理隔离的,所以,没法像官网的安装教程那样直接install了,只能手动安装,这里已经我们自己的linu ...
- Redis进阶实践之二如何在Linux系统上安装安装Redis
2019独角兽企业重金招聘Python工程师标准>>> Redis进阶实践之二如何在Linux系统上安装安装Redis 一.引言 上一篇文章写了"如何安装VMware Pr ...
- linux系统下安装 Loadrunner11(个人感觉不错儿)
转载地址:http://4951507.blog.51cto.com/4941507/1099487 1.到官方网站到HP官网下载Load Generator 安装文件 Software,_Load_ ...
- 【Ubuntu】Linux系统( ubuntu )安装方案
[Ubuntu]Linux系统( ubuntu )安装方案 1.光驱安装 这种方法安装比较简便,但linux发行版升级频繁,市场上很难买到最新的版本,而且许多电脑并没有光驱.如果用这种方法安装,安装的 ...
最新文章
- ansible文档官网
- (理论篇)从基础文件IO说起虚拟内存,内存文件映射,零拷贝
- oracle adg的特点是什么,Oracle12c ADG新特性
- [C++] 井字棋游戏源码
- ubuntu10右键脚本中增加发送到命令
- MySQL5.7新特性——在线收缩undo表空间 (转载)
- Spark On MaxCompute如何访问Phonix数据
- 请各位程序员 正在创业的 正在努力赚钱的 好好看看下面的话
- PSCAD创建子界面模块(放置仿真图像)
- Visio应用视频教程(上)-游峰-专题视频课程
- 1.python程序图标制作
- Ubuntu截图快捷键
- oppo电视怎么看电视台 oppo电视看CCTV直播方法
- JetBrains下载历史版本(IDEA、PyCharm、WebStorm、PhpStorm等)
- 被李刚儿子撞死的漂亮姑娘——晓风(照片)
- 安笙机器人_【搬文】《安妻》BY李小雾(安笙 佐安,未来机甲 年下生子,HE)...
- Matlab 求z变换函数的反变换函数 iztrans()函数
- 基于MATLAB/Simulink的电力系统稳定器(PSS)和静态无功补偿器(SVC)的两机传动系统暂态稳定性仿真模型,观察PSS和SVC对系统稳定性的影响
- 如何用python画帆船_python学习笔记6——文件操作来生成船只侧面图像的描述文件...
- 专业临床护理体温单控件