Mat*_*der 5 linux automounting samba autofs
我按照此页面上的指南通过 autofs 获取 samba 共享:
http://www.howtoforge.com/accessing_windows_or_samba_shares_using_autofs
服务器和配置
我的 Samba 服务器(远程)位于名为“mattserver”(这是它的 Windows 服务器名称)的服务器上。它有四个共享,称为“备份”、“哑光”、“打印”和“网络”。Samba 客户端(本地)被命名为“bird”。
我的设置与上述教程中的示例非常相似,除了一些不同之处:
/cifs /etc/auto.cifs --ghost而不是/cifs /etc/auto.cifs --timeout=60在/etc/auto.masteruid=1000,gid=1000而不是uid=user,gid=users在/etc/auto.cifs这是我的/etc/auto.master:
matt@bird:~ $ cat /etc/auto.master
/cifs /etc/auto.cifs --ghost
Run Code Online (Sandbox Code Playgroud)
这是我的/etc/auto.cifs:
matt@bird:~ $ cat /etc/auto.cifs
#!/bin/bash
key="$1"
credfile="/etc/auto.smb.$key"
mountopts="-fstype=cifs,file_mode=0644,dir_mode=0755,uid=1000,gid=1000"
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
mountopts=$mountopts",credentials=$credfile"
smbclientopts="-A "$credfile
else
smbclientopts="-N"
fi
$SMBCLIENT $smbclientopts -gL $key 2>/dev/null \
| awk -v key="$key" -v opts="$mountopts" -F'|' -- '
BEGIN { ORS=""; first=1 }
/Disk/ { if (first) { print opts; first=0 };
gsub(/ /, "\\ ", $2);
sub(/\$/, "\\$", $2);
print " \\\n\t /" $2, "://" key "/" $2 }
END { if (!first) print "\n"; else exit 1 }
'
Run Code Online (Sandbox Code Playgroud)
所以这就是我/etc/auto.cifs直接打电话时得到的:
matt@bird:~ $ sudo bash /etc/auto.cifs mattserver
-fstype=cifs,file_mode=0644,dir_mode=0755,uid=1000,gid=1000,credentials=/etc/auto.smb.mattserver \
/print\$ ://mattserver/print\$ \
/matt ://mattserver/matt \
/web ://mattserver/web \
/backup ://mattserver/backup
Run Code Online (Sandbox Code Playgroud)
到目前为止,很好,我认为。
测试
当我尝试访问该/cifs目录时,我应该得到一个名为 的目录mattserver,对吗?我确实把--ghost选项放在那里。我什么也没得到:
matt@bird:~ $ ls -l /cifs
total 0
Run Code Online (Sandbox Code Playgroud)
当我访问服务器目录时,我得到一个共享列表,但它搞砸了:
matt@bird:~ $ ls -l /cifs/mattserver
ls: cannot access /cifs/mattserver/web: No such file or directory
ls: cannot access /cifs/mattserver/print$: No such file or directory
ls: cannot access /cifs/mattserver/matt: No such file or directory
ls: cannot access /cifs/mattserver/backup: No such file or directory
total 0
d????????? ? ? ? ? ? backup
d????????? ? ? ? ? ? matt
d????????? ? ? ? ? ? print$
d????????? ? ? ? ? ? web
Run Code Online (Sandbox Code Playgroud)
当我尝试访问实际共享时,我什么也没得到:
matt@bird:~ $ ls -l /cifs/mattserver/web
ls: cannot access /cifs/mattserver/web: No such file or directory
Run Code Online (Sandbox Code Playgroud)
作为测试,我在/etc/hostsfor 中添加了一行mattserver。
仍然没有重影:
matt@bird:~ $ ls -l /cifs
total 0
Run Code Online (Sandbox Code Playgroud)
当我再次尝试访问服务器目录时,我不再获得共享列表:
matt@bird:~ $ ls -l /cifs/mattserver
ls: cannot access /cifs/mattserver: No such file or directory
Run Code Online (Sandbox Code Playgroud)
但是当我访问实际共享时,我获得了完全访问权限:
matt@bird:~ $ ls -l /cifs/mattserver/web
[correct listing of files -- removed]
Run Code Online (Sandbox Code Playgroud)
我应该能够依赖广播,我不需要在 /etc/hosts 中有任何东西(对吧?)。广播正在工作:
matt@bird:~ $ nmblookup mattserver
querying mattserver on 192.168.0.255
192.168.0.2 mattserver<00>
Run Code Online (Sandbox Code Playgroud)
问题
ls -l /cifs,我一无所获。ls -l /cifs/mattserver,我得到一个搞砸了的列表(见上文)。/etc/hosts. 我不想依赖/etc/hosts.我在这里有哪些选择?