Uma*_*ang 6 10.04 shutdown samba network-manager cifs
大约一个月前,我在 fstab 中添加了一个 Windows 网络驱动器(使用 WiFi 访问):
//Server/Location/foo/bar /media/myNetworkDrive/ cifs auto,iocharset=utf8,uid=umang,credentials=/root/.cifscredentials,file_mode=0775,dir_mode=0775 0 0
Run Code Online (Sandbox Code Playgroud)
它运行得非常好,只是系统关闭需要大约一分钟。我已经尝试了帮助 wiki、团队 wiki和此博客上发布的解决方案。其中一个工作了几次关机,但随后系统又回到了需要一分钟才能再次关机的状态。
编辑:我想一个工作这个问题各地工作。目前,我有一个脚本可以卸载(超级用户权限所需的密码)然后关闭计算机,但我希望能够以通常的方式关闭并使其快速关闭。
这是一个众所周知的错误: https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/211631 ?comments=all
值得庆幸的是,这是一个罕见的、但仍然令人尴尬的、高影响力、两年多前的错误,对 Ubuntu 的光彩产生了负面影响。
它应该只影响 WIFI 连接,但我在你的问题中没有看到任何相关细节。如果您通过有线连接遇到这种情况,那么这里可能有其他原因。
在网络管理器修复之前(它会过快地关闭 wifi 连接 - 在触发任何初始化脚本之前),我能找到的唯一可行的解决方法是使用 AutoFS。
转述自http://www.howtoforge.com/accessing_windows_or_samba_shares_using_autofs
sudo apt-get install autofs
Run Code Online (Sandbox Code Playgroud)
使用以下文件内容创建 /etc/auto.cifs :
#!/bin/bash
# $Id$
# This file must be executable to work! chmod 755!
key="$1"
# Note: create a cred file for each windows/Samba-Server in your network
# which requires password authentification. The file should contain
# exactly two lines:
# username=user
# password=*****
# Please don't use blank spaces to separate the equal sign from the
# user account name or password.
credfile="/etc/auto.smb.$key"
# Note: Use cifs instead of smbfs:
mountopts="-fstype=cifs,file_mode=0644,dir_mode=0755,uid=user,gid=users"
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)
(编辑 mountops 行以反映您的真实用户名)
使其可执行sudo chmod 755 /etc/auto.cifs
然后将此行添加到 /etc/auto.master 的底部:
/smb /etc/auto.cifs --timeout=60 --ghost
Run Code Online (Sandbox Code Playgroud)
最后,使用此行重新启动 autofs(当然,重新启动也可以):
sudo service autofs restart
Run Code Online (Sandbox Code Playgroud)
然后您应该能够将 nautilus 打开到 /smb/server/share (或ls -l /smb/Server/Share)
关闭、暂停、休眠都应该是无缝的。
如果您使用密码连接到共享,则必须在 /etc/ 中为连接到的每个服务器添加另一个文件,并指定用户名和密码。执行“man autofs”以获取更多详细信息,但要点如下:
对于要连接的每个受密码保护的共享,您都需要一个凭据文件。在您的情况下,您的服务器称为“服务器”,因此使用gksudo gedit /etc/auto.smb.Server. 然后将其放入该文件中:
username=myusername
password=mypassword
Run Code Online (Sandbox Code Playgroud)
(显然根据需要编辑字段)。
然后您需要确保该文件只能由 root 读取sudo chmod 600 /etc/auto.smb.Server。
然后按上述方式重新启动 autofs 并尝试浏览 /smb/Server - 您应该会看到共享列表。
如果您使用 IP 地址进行连接,则需要对 /etc/auto.smb.192.168.1.10 或其他内容重复此过程。
您应该使用该指南,该指南向您展示如何制作卸载关闭脚本并确保它仍然处于打开状态。从理论上讲,升级或更新可能会使其失去原有的地位。检查您的脚本是否存在/etc/rc0.d,并且其名称S01smb_umount是否相似,以便它作为首要任务运行。
否则,您最终可能会正常卸载 samba 驱动器(等待,等待),然后运行脚本。这将无济于事。