[linux] How do you force a CIFS connection to unmount

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?

This question is related to linux samba smb cifs

The answer is


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.


There's a -f option to umount that you can try:

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.

You may also want to consider fusesmb, since the filesystem will be running in userspace you can kill it just like any other process.


Try umount -f /mnt/share. Works OK with NFS, never tried with cifs.

Also, take a look at autofs, it will mount the share only when accessed, and will unmount it afterworlds.

There is a good tutorial at www.howtoforge.net


On RHEL 6 this worked:

umount -f -a -t cifs -l 

On RHEL 6 this worked for me also:

umount -f -a -t cifs -l FOLDER_NAME


On RHEL 6 this worked:

umount -f -a -t cifs -l 

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.

soft Make the mount soft. Fail file system calls after a number of seconds.

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


On RHEL 6 this worked for me also:

umount -f -a -t cifs -l FOLDER_NAME


Try umount -f /mnt/share. Works OK with NFS, never tried with cifs.

Also, take a look at autofs, it will mount the share only when accessed, and will unmount it afterworlds.

There is a good tutorial at www.howtoforge.net


This works for me (Ubuntu 13.10 Desktop to an Ubuntu 14.04 Server) :-

 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.


A lazy unmount will do the job for you.

umount -l <mount path>

There's a -f option to umount that you can try:

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.

You may also want to consider fusesmb, since the filesystem will be running in userspace you can kill it just like any other process.


Try umount -f /mnt/share. Works OK with NFS, never tried with cifs.

Also, take a look at autofs, it will mount the share only when accessed, and will unmount it afterworlds.

There is a good tutorial at www.howtoforge.net


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.


Try umount -f /mnt/share. Works OK with NFS, never tried with cifs.

Also, take a look at autofs, it will mount the share only when accessed, and will unmount it afterworlds.

There is a good tutorial at www.howtoforge.net


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.


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.


There's a -f option to umount that you can try:

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.

You may also want to consider fusesmb, since the filesystem will be running in userspace you can kill it just like any other process.


A lazy unmount will do the job for you.

umount -l <mount path>

There's a -f option to umount that you can try:

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.

You may also want to consider fusesmb, since the filesystem will be running in userspace you can kill it just like any other process.


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.

soft Make the mount soft. Fail file system calls after a number of seconds.

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


umount -a -t cifs -l

worked like a charm for me on CentOS 6.3. It saved me a server reboot.


This works for me (Ubuntu 13.10 Desktop to an Ubuntu 14.04 Server) :-

 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.