linux 配置autofs

Autofs与Mount/Umount的不同之处在于,它是一种看守程序。如果它检测到用户正试图访问一个尚未挂接的文件系统,它就会自动检测该文件系 统,如果存在,那么Autofs会自动将其挂接。另一方面,如果它检测到某个已挂接的文件系统在一段时间内没有被使用,那么Autofs会自动将其卸载。 因此一旦运行了Autofs后,用户就不再需要手动完成文件系统的挂接和卸载。

以下使用 RHEL7.0进行配置

[root@LiuZhen mnt]# service autofs start

Redirecting to /bin/systemctl start  autofs.service
Failed to issue method call: Unit autofs.service failed to load: No such file or directory.

rpm没有安装,安装autofsrpm

[root@LiuZhen mnt]# yum install autofs.x86_64
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Resolving Dependencies
--&gt Running transaction check
---&gt Package autofs.x86_64 1:5.0.7-40.el7 will be installed
--&gt Processing Dependency: libhesiod.so.0()(64bit) for package: 1:autofs-5.0.7-40.el7.x86_64
--&gt Running transaction check
---&gt Package hesiod.x86_64 0:3.2.1-3.el7 will be installed
--&gt Finished Dependency Resolution

Dependencies Resolved

=========================================================================================================================
 Package                   Arch                      Version                            Repository                  Size
=========================================================================================================================
Installing:
 autofs                    x86_64                    1:5.0.7-40.el7                     testyum                    550 k
Installing for dependencies:
 hesiod                    x86_64                    3.2.1-3.el7                        testyum                     30 k

Transaction Summary
=========================================================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 579 k
Installed size: 3.6 M
Is this ok [y/d/N]: y
Downloading packages:
-------------------------------------------------------------------------------------------------------------------------
Total                                                                                    1.1 MB/s | 579 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
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!
[root@LiuZhen mnt]#
[root@LiuZhen mnt]#
[root@LiuZhen mnt]#

启动服务
[root@LiuZhen mnt]# service autofs start
Redirecting to /bin/systemctl start  autofs.service
[root@LiuZhen mnt]#
[root@LiuZhen mnt]#

设置开机自启动
[root@LiuZhen mnt]# chkconfig autofs on
Note: Forwarding request to 'systemctl enable autofs.service'.
ln -s '/usr/lib/systemd/system/autofs.service' '/etc/systemd/system/multi-user.target.wants/autofs.service'


[root@LiuZhen cd]# grep -v ^$ /etc/auto.master | grep -v "#"
/misc    /etc/auto.misc
/net    -hosts
+dir:/etc/auto.master.d
+auto.master


查看自动挂载的光盘
[root@LiuZhen cd]# ls /misc
cd
[root@LiuZhen cd]# ls /misc/cd
addons  EULA  images    LiveOS      Packages       repodata                 RPM-GPG-KEY-redhat-release
EFI     GPL   isolinux  media.repo  release-notes  RPM-GPG-KEY-redhat-beta  TRANS.TBL


若查看自动挂载的NFS使用以下命令

配置hosts
echo 172.16.7.1 nfsserver>> /etc/hosts

查看自动挂载目录
ls /net
ls /net/ nfsserver

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/27771627/viewspace-1241361/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/27771627/viewspace-1241361/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值