autofs自动挂载服务

2021/5/17 10:27:57

本文主要是介绍autofs自动挂载服务,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

AutoFs自动挂载服务是一种守护进程,只有检测到用户试图访问一个尚未挂载的文件系统时才自动的检测并挂载该文件系统,而且用户不使用自动挂载的目录一段的时间,会自动卸载。

[root@localhost ~]# yum install -y autofs    #安装AutoFs服务程序
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
file:///media/cdrom/repodata/repomd.xml: [Errno 14] curl#37 - "Couldn't open file /media/cdrom/repodata/repomd.xml"
正在尝试其它镜像。
正在解决依赖关系
--> 正在检查事务
---> 软件包 autofs.x86_64.1.5.0.7-116.el7_9 将被 安装
--> 正在处理依赖关系 libhesiod.so.0()(64bit),它被软件包 1:autofs-5.0.7-116.el7_9.x86_64 需要
--> 正在检查事务
---> 软件包 hesiod.x86_64.0.3.2.1-3.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

=======================================================================================
Package 架构 版本 源 大小
=======================================================================================
正在安装:
autofs x86_64 1:5.0.7-116.el7_9 updates 834 k
为依赖而安装:
hesiod x86_64 3.2.1-3.el7 base 30 k

事务概要
=======================================================================================
安装 1 软件包 (+1 依赖软件包)

总下载量:864 k
安装大小:5.2 M
Downloading packages:
(1/2): hesiod-3.2.1-3.el7.x86_64.rpm | 30 kB 00:00:00
(2/2): autofs-5.0.7-116.el7_9.x86_64.rpm | 834 kB 00:00:02
---------------------------------------------------------------------------------------
总计 287 kB/s | 864 kB 00:03
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : hesiod-3.2.1-3.el7.x86_64 1/2
正在安装 : 1:autofs-5.0.7-116.el7_9.x86_64 2/2
验证中 : hesiod-3.2.1-3.el7.x86_64 1/2
验证中 : 1:autofs-5.0.7-116.el7_9.x86_64 2/2

已安装:
autofs.x86_64 1:5.0.7-116.el7_9

作为依赖被安装:
hesiod.x86_64 0:3.2.1-3.el7

完毕!
[root@localhost ~]# vim /etc/auto.master   #编辑AutoFs服务的配置文件

在配置文件/misc  /etc/auto.misc 一行的前面加入   /media  /etc/iso/misc,

[root@localhost ~]# vim /etc/iso.misc   #在子配置文件中,写入挂载信息

[root@localhost ~]# systemctl start autofs  #重启autofs 服务
[root@localhost ~]# systemctl enable autofs  #将autofs服务加入开机自启动中
Created symlink from /etc/systemd/system/multi-user.target.wants/autofs.service to /usr/lib/systemd/system/autofs.service.
[root@localhost ~]# df -h     #查看光盘设备挂载情况,发现没有iso子目录,
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 1.3G 0 1.3G 0% /dev
tmpfs 1.3G 0 1.3G 0% /dev/shm
tmpfs 1.3G 11M 1.3G 1% /run
tmpfs 1.3G 0 1.3G 0% /sys/fs/cgroup
/dev/mapper/centos-root 17G 11G 6.6G 62% /
/dev/sda1 1014M 239M 776M 24% /boot
tmpfs 266M 28K 266M 1% /run/user/0
/dev/sr0 4.5G 4.5G 0 100% /run/media/root/CentOS 7 x86_64
[root@localhost ~]# cd /media     #进入目录
[root@localhost media]# ls     此时查看发现没有子目录,但是执行cd iso命令,却发现可以成功
[root@localhost media]# cd iso   #执行成功
[root@localhost iso]# ll  #查看文件详细信息,发现出现了iso子目录
总用量 694
-rw-rw-r--. 2 root root 14 4月 21 2020 CentOS_BuildTag
drwxr-xr-x. 3 root root 2048 4月 21 2020 EFI
-rw-rw-r--. 3 root root 227 8月 30 2017 EULA
-rw-rw-r--. 3 root root 18009 12月 10 2015 GPL
drwxr-xr-x. 3 root root 2048 4月 21 2020 images
drwxr-xr-x. 2 root root 2048 4月 21 2020 isolinux
drwxr-xr-x. 2 root root 2048 4月 21 2020 LiveOS
drwxr-xr-x. 2 root root 671744 4月 22 2020 Packages
drwxrwxr-x. 2 root root 4096 4月 22 2020 repodata
-rw-rw-r--. 3 root root 1690 12月 10 2015 RPM-GPG-KEY-CentOS-7
-rw-rw-r--. 3 root root 1690 12月 10 2015 RPM-GPG-KEY-CentOS-Testing-7
-r--r--r--. 1 root root 2883 4月 22 2020 TRANS.TBL
[root@localhost iso]# df -h   #查看磁盘使用情况
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 1.3G 0 1.3G 0% /dev
tmpfs 1.3G 0 1.3G 0% /dev/shm
tmpfs 1.3G 11M 1.3G 1% /run
tmpfs 1.3G 0 1.3G 0% /sys/fs/cgroup
/dev/mapper/centos-root 17G 11G 6.6G 62% /
/dev/sda1 1014M 239M 776M 24% /boot
tmpfs 266M 28K 266M 1% /run/user/0
/dev/sr0 4.5G 4.5G 0 100% /media/iso
[root@localhost iso]#

结束啦!!!

 



这篇关于autofs自动挂载服务的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程