使用autofs挂载CIFS共享

我有一个运行RHEL 5.5的系统,我试图使用autofs在服务器上安装一个Windows共享。 (由于networking在启动时没有准备好,我不想使用fstab 。)我可以手动安装共享,但autofs只是没有安装它们。

这里是我正在使用的文件:

/etc/auto.master结尾,我有:

 ## Mount this test share: /test /etc/auto.test --timeout=60 

/etc/auto.test ,我有:

 test -fstype=cifs,username=testuser,domain=domain.com,password=password ://server/test 

然后我重新启动autofs服务。

但是,这是行不通的。 ls -ing目录不会返回任何结果。 我已经在networking上跟踪了所有这些指南,而我也不明白,或者他们不愿意。

谢谢

应该有一个/etc/auto.smb,使用它,然后将以下行添加到/etc/auto.master:

 /cifs /etc/auto.smb --timeout=60 

现在所有的CIF股票都将显示在/ cifs下:

 ls /cifs/<server> 

将显示所有可用的股份。 您可能想要在/etc/auto.smb中添加一些选项以使用特定模式进行挂载。 我有一个auto.smb,我发现在那里,并修改完成这一点:

 #!/bin/bash # $Id: auto.smb,v 1.3 2005/04/05 13:02:09 raven Exp $ # This file must be executable to work! chmod 755! key="$1" credfile="/etc/auto.smb.$key" opts="-fstype=cifs,file_mode=0644,dir_mode=0755,uid=eng,gid=eng" smbclientopts="" for P in /bin /sbin /usr/bin /usr/sbin do if [ -x $P/smbclient ] then SMBCLIENT=$P/smbclient break fi done [ -x $SMBCLIENT ] || exit 1 if [ -e "$credfile" ] then opts=$opts",credentials=$credfile" smbclientopts="-A "$credfile else smbclientopts="-N" fi $SMBCLIENT $smbclientopts -gNL $key 2>/dev/null| awk -v key="$key" -v opts="$opts" -F'|' -- ' BEGIN { ORS=""; first=1 } /Disk/ { if (first) print opts; first=0 dir = $2 loc = $2 # Enclose mount dir and location in quotes # Double quote "$" in location as it is special gsub(/\$$/, "\\$", loc); print " \\\n\t \"/" dir "\"", "\"://" key "/" loc "\"" } END { if (!first) print "\n"; else exit 1 } ' 

这将做你想要的。 我自己用过

我只是在一个CentOS 5.6盒子上做了这个,我认为你的问题的一部分可能是你的auto.test文件。 在目前的forms中,您将创build一个/testing挂载点,然后创build一个单独的testing,例如/ test / test。 你也可能想把–ghost开关添加到你的auto.master中,如下所示:

 /test /etc/auto.test --timeout=60 --ghost 

即使没有主动挂载给定的共享,–ghost开关也会创build挂载点的存根。

看看这个CentOS wiki提示和技巧页面,介绍如何安装SMB / CIFS共享。

安装提示

  • Windows Share = \ mysmb \ share1
  • Unix Dir。 = / test / dir1

想法#1

  # /etc/auto.master /test /etc/auto.test --timeout=600 --ghost # /etc/auto.test dir1 -fstype=cifs,rw,noperm,netbiosname=${HOST},credentials=/etc/creds.txt ://mysmb/test/dir1 dir2 -fstype=cifs,rw,noperm,netbiosname=${HOST},credentials=/etc/creds.txt ://mysmb/test/dir2 

想法#2

  # /etc/auto.master /test /etc/auto.test --timeout=600 --ghost # /etc/auto.test * -fstype=cifs,rw,noperm,netbiosname=${HOST},credentials=/etc/creds.txt ://mysmb/test/& 

因为我只是花了整个上午来debugging这个相同的问题。 让我解释一下上面发生的事情。

/etc/auto.master文件

 ## Mount this test share: /test /etc/auto.test --timeout=60 

这意味着我想挂载/test和详细信息读/etc/auto.test

/etc/auto.test

 test -fstype=cifs,username=testuser,domain=domain.com,password=password ://server/test 

这意味着作为auto.master中指定内容的子文件夹,请使用以下信息进行testing。 (即安装将被正确指出为slm /test/test )。

这意味着ls /test/test会显示//server/test的内容

要完成/ test – > // server / test的原始目标,你需要以下内容:

/etc/auto.master文件

 ## Mount this test share: / /etc/auto.test --timeout=60 

一些其他的笔记。 我发现以下装载选项很有用。

rw – 挂载它读/写

noserverino – 删除有关inode号码支持的错误消息

credentials=[credential file] – 这允许您创build一个单独的文件,其中包含凭据。 它有以下格式:

 username=[windows username, domain can be included as well] password=[windows password] 

编辑 – 2013-06-17 13:28 GMT-8

评论中的slm指出,挂载到文件系统的根目录可能是危险的。 在注释lsd中提出了一种解决方法,即从文件系统的根目录创build一个符号链接到一个不同的地方,在这个地方你将会挂载不会与一些常见的东西重叠的地方。 例如,如果你想让/ test成为一个挂载,那么你实际上将东西挂载到/ net / the_test_mount,然后创build一个指向/ net / the_test_mount的符号链接/testing