Autofs 和 Samba 无法在 RHEL 7 上安装

Autofs 和 Samba 无法在 RHEL 7 上安装

我设置了一个名为“scrolls”的 Samba 共享。列出 Samba 共享即可正常工作:

[root@rhel7-client ~]# smbclient -L 192.168.1.2
Enter root's password:


Domain=[WORKGROUP] OS=[Unix] Server=[Samba 4.1.1]

Sharename       Type      Comment
---------       ----      -------
scrolls         Disk      Ancient Scrolls
IPC$            IPC       IPC Service (Samba 4.1.1)
root            Disk      Home Directories
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 4.1.1]

Server               Comment
---------            -------

Workgroup            Master

安装 samba 共享也可以:

[root@rhel7-client /]# mount.cifs //192.168.1.2/scrolls -o credentials=/etc/creds.txt /mnt

[root@rhel7-client /]# grep scrolls /etc/mtab|tail -n1
//192.168.1.2/scrolls /mnt cifs   rw,relatime,vers=1.0,cache=strict,username=root,domain=RHEL7SERVER,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.1.2,unix,posixpaths,serverino,acl,rsize=1048576,wsize=65536,actimeo=1 0 0

卸载前一个共享后,通过 Autofs 安装 Samba 共享不起作用:

[root@rhel7-client /]# cat /etc/auto.shares
scrolls         -cifs,credentials=/etc/creds.txt                //192.168.1.2/scrolls

[root@rhel7-client scrolls]# grep shares /etc/auto.master
/mnt/shares /etc/auto.shares

[root@rhel7-client /]# grep shares /etc/mtab
/etc/auto.shares /mnt/scrolls autofs rw,relatime,fd=-1,pgrp=2548,timeout=300,minproto=5,maxproto=5,indirect 0 0
/etc/auto.shares /mnt/shares autofs rw,relatime,fd=12,pgrp=2730,timeout=300,minproto=5,maxproto=5,indirect 0 0

[root@rhel7-client /]# cd /mnt/shares/scrolls
-bash: cd: /mnt/shares/scrolls: No such file or directory

有任何想法吗?

[root@rhel7-client scrolls]# systemctl status autofs
autofs.service - Automounts filesystems on demand
   Loaded: loaded (/usr/lib/systemd/system/autofs.service; enabled)
   Active: active (running) since Wed 2015-01-07 21:30:09 UTC; 6min ago
  Process: 2728 ExecStart=/usr/sbin/automount $OPTIONS --pid-file /run/autofs.pid (code=exited, status=0/SUCCESS)
 Main PID: 2730 (automount)
   CGroup: /system.slice/autofs.service
           └─2730 /usr/sbin/automount --pid-file /run/autofs.pid

Jan 07 21:30:09 rhel7-client systemd[1]: Starting Automounts filesystems on demand...
Jan 07 21:30:09 rhel7-client systemd[1]: Started Automounts filesystems on demand.

答案1

这应该是由于您的自动挂载配置造成的:

在使用时,您必须添加SMB 共享所需://192.168.1.2/scrolls:autofs

[root@rhel7-client /]# cat /etc/auto.shares

scrolls         -cifs,credentials=/etc/creds.txt              ://192.168.1.2/scrolls

答案2

在 /etc/auto.master 中使用选项 --ghost。我没有在文档中找到它,但它在我的环境中有效。

/mnt/shares /etc/auto.shares --ghost

相关内容