Linux 如何强制卸载 CIFS 连接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/74626/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do you force a CIFS connection to unmount
提问by smoofra
I have a CIFS share mounted on a Linux machine. The CIFS server is down, or the internet connection is down, and anything that touches the CIFS mount now takes several minutes to timeout, and is unkillable while you wait. I can't even run ls in my home directory because there is a symlink pointing inside the CIFS mount and ls tries to follow it to decide what color it should be. If I try to umount it (even with -fl), the umount process hangs just like ls does. Not even sudo kill -9 can kill it. How can I force the kernel to unmount?
我在 Linux 机器上安装了 CIFS 共享。CIFS 服务器已关闭,或 Internet 连接已关闭,现在任何接触 CIFS 挂载的内容都需要几分钟才能超时,并且在您等待时无法杀死。我什至无法在我的主目录中运行 ls ,因为在 CIFS 安装内部有一个符号链接指向,并且 ls 尝试跟随它来决定它应该是什么颜色。如果我尝试卸载它(即使使用 -fl),则 umount 进程会像 ls 一样挂起。甚至 sudo kill -9 也无法杀死它。如何强制内核卸载?
采纳答案by Kemal
I use lazy unmount: umount -l
(that's a lowercase L
)
我使用懒惰卸载:(umount -l
这是一个小写L
)
Lazy unmount. Detach the filesystem from the filesystem hierarchy now, and cleanup all references to the filesystem as soon as it is not busy anymore. (Requires kernel 2.4.11 or later.)
懒惰卸载。立即从文件系统层次结构中分离文件系统,并在文件系统不再忙碌时立即清除对文件系统的所有引用。(需要内核 2.4.11 或更高版本。)
回答by Chris AtLee
There's a -f option to umount that you can try:
有一个 -f 选项可以用于 umount,您可以尝试:
umount -f /mnt/fileshare
Are you specifying the '-t cifs' option to mount? Also make sure you're not specifying the 'hard' option to mount.
您是否指定要挂载的“-t cifs”选项?还要确保您没有指定要挂载的 'hard' 选项。
You may also want to consider fusesmb, since the filesystem will be running in userspace you can kill it just like any other process.
回答by Sunny Milenov
Try umount -f /mnt/share. Works OK with NFS, never tried with cifs.
尝试 umount -f /mnt/share。使用 NFS 可以正常工作,从未尝试使用 cifs。
Also, take a look at autofs, it will mount the share only when accessed, and will unmount it afterworlds.
另外,看看 autofs,它只会在访问时挂载共享,并在后世界卸载它。
There is a good tutorial at www.howtoforge.net
www.howtoforge.net 上有一个很好的教程
回答by jnice
I had this issue for a day until I found the real resolution. Instead of trying to force unmount an smb share that is hung, mount the share with the "soft" option. If a process attempts to connect to the share that is not available it will stop trying after a certain amount of time.
我有这个问题一天,直到我找到真正的解决方案。不要试图强制卸载挂起的 smb 共享,而是使用“软”选项挂载共享。如果进程尝试连接到不可用的共享,它将在一定时间后停止尝试。
soft Make the mount soft. Fail file system calls after a number of seconds.
soft 使安装变得柔软。几秒钟后文件系统调用失败。
mount -t smbfs -o soft //username@server/share /users/username/smb/share
stat /users/username/smb/share/file
stat: /users/username/smb/share/file: stat: Operation timed out
May not be a real answer to your question but it is a solution to the problem
可能不是您问题的真正答案,但它是问题的解决方案
回答by ivanlan
umount -a -t cifs -l
umount -a -t cifs -l
worked like a charm for me on CentOS 6.3. It saved me a server reboot.
在 CentOS 6.3 上对我来说很有魅力。它为我节省了服务器重启。
回答by Phil Johnson
This works for me (Ubuntu 13.10 Desktop to an Ubuntu 14.04 Server) :-
这对我有用(Ubuntu 13.10 桌面到 Ubuntu 14.04 服务器):-
sudo umount -f /mnt/my_share
Mounted with
装着
sudo mount -t cifs -o username=me,password=mine //192.168.0.111/serv_share /mnt/my_share
where serv_share is that set up and pointed to in the smb.conf file.
其中 serv_share 是在 smb.conf 文件中设置和指向的。
回答by Benedikt K?ppel
I had a very similar problem with davfs. In the man page of umount.davfs
, I found that the -f -l -n -r -v
options are ignored by umount.davfs
. To force-unmount my davfs mount, I had to use umount -i -f -l /media/davmount
.
我对 davfs 有一个非常相似的问题。在 的手册页中umount.davfs
,我发现这些 -f -l -n -r -v
选项被umount.davfs
. 要强制卸载我的 davfs 挂载,我必须使用umount -i -f -l /media/davmount
.
回答by Andy Fraley
On RHEL 6 this worked:
在 RHEL 6 上,这有效:
umount -f -a -t cifs -l
回答by chataros
On RHEL 6 this worked for me also:
在 RHEL 6 上,这也对我有用:
umount -f -a -t cifs -l FOLDER_NAME
umount -f -a -t cifs -l FOLDER_NAME
回答by zhjb7
umount -f -t cifs -l /mnt &
Be careful of &
, let umount
run in background.
umount
will detach filesystem first, so you will find nothing abount /mnt
. If you run df
command, then it will umount /mnt
forcibly.
小心&
,让我们umount
在后台运行。
umount
将首先分离文件系统,因此您将一无所获/mnt
。如果你运行df
命令,那么它会umount /mnt
强制执行。