不知道你有没有想过如何使用autofs的方式自动挂载一个CIFS共享呢?
解决方案
在以下示例中,可以实现从192.168.0.1服务器上,使用文件夹“test”和“test2”来自动挂载和访问/cifs/share和/cifs/extra: 1.安装autofs工具
[root@shizhanxia.com ~]# yum install -y autofs cifs-utils
2.启动autofs服务
[root@shizhanxia.com ~]# systemctl start autofs
3.编辑/etc/auto.master文件并添加以下行:
/cifs /etc/auto.cifs --timeout=60
4.创建一个/etc/auto.cifs文件中每个挂载都包含一行。使用以下条目之一作为示例:
share -fstype=cifs,credentials=/etc/cred ://192.168.0.1/test extra -fstype=cifs,username=hello,password=test ://192.168.0.1/test2
扩展阅读:
如果正在使用凭据文件(/etc/cred),请确保该文件已使用以下格式创建。确保没有创建空白空间:
username=administrator password=testpassword domain=thisisoptional
/etc/cred 是一个文件或目录的路径,通常用于存储敏感信息的凭据文件。在许多系统中,/etc/cred 目录可能用于存放各种身份验证凭据或密钥文件,如 SSL 证书、私钥、安全令牌等。然而,具体文件或目录的用途和内容可能因不同系统或应用程序而异。请注意,这只是一种在某些情况下的常见用途,具体情况需根据实际情况而定。
5.开机启动服务 [root@shizhanxia.com ~]# systemctl enable autofs
6. 确保/cifs目录已创建。现在开始autofs服务和共享将可访问。导航到该目录并运行ls去测试:
RHEL 6:
[root@shizhanxia.com ~]# service autofs restart [root@shizhanxia.com ~]# ls -la /cifs/share/
RHEL7及更高版本:
[root@shizhanxia.com ~]# systemctl restart autofs [root@shizhanxia.com ~]# ls -la /cifs/share/
原创文章,作者:保哥,如若转载,请注明出处:https://www.shizhanxia.com/2259.html