In a mixed enviroment of Windows and Linux, you may often use Samba/Windows shares. Traditionally, the use of GVFS and CIFS to access Windows shares on Linux PCs is common. Personally, I prefer CIFS as it works more predictably, reliably, and faster.
The Server Message Block (SMB) Protocol is the network file sharing protocol of Microsoft Windows. The set of message packets defining a particular version of the protocol is called a dialect. The Common Internet File System (CIFS) is a dialect of SMB. Both SMB and CIFS are also available on VMS. Both SMB and CIFS are also available on other operating systems like Linux and Android via alternate implementations which are not officially supported by Microsoft.
With cifs-utils on Linux, you can easily mount a share to any folder you want using the mount
command. Also, you can configure a mount point for CIFS with the fstab
file.
The problem comes when the remote computer becomes inaccessible. e.g. when the remote computer is shutting down, or when you have your network connection interrupted, the mounted share gives you a terrible experience.
Every time you try to navigate to the mount point's parent directory with a file manager app, it freezes. When you try to use autocompletion with bash, it causes a delay if the mount point matches the name pattern.
To solve this problem, I have tried the lazy unmount option. It is the umount -l
command that must be familiar to many Linux users. However, it didn't help me.
After some experiments, I have figured out the following solution.
To force unmount a CIFS share in Linux, do the following.
- Open your favorite terminal app.
- Type the following command:
sudo umount -a -t cifs -l
, then supply your password. - If the sudo command is not available in your environment, switch to root with the
su
command, and then issue the commandumount -a -t cifs -l
This has resolved my issue. If you are using another working solution, do not hesitate to share it in the comments.
Support us
Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:
Thanks very much for this article. I have an odd problem and can’t figure out why it is occurring. I am running CentOS 7.5.1804, using autofs to manage mounts. Through autofs I include a mount of a cifs device to /mnt/ABC.
A month or so back, I had manually mounted a cifs resource ABC/Subdir to /mnt/ABC/Subdir. Now even after umount`ing all cifs devices, when I cd to /mnt/ABC/Subdir, both resources appear in the output of “df -h”. I am getting errors in my code that recursion limits are exceeded, that just started happening, and I suspect it relates to these redundant mounts.
Where is that remount of /mnt/ABC/Subdir originating if it is not configured for autofs? I do see entries for ABC and ABC/Subdir in mtab. Could that be causing it to remount the ABC/Subdir device to /mnt/ABC/Subdir? How can I eradicate this mount of ABC/Subdir so that I only get the mount of ABC dictated by autofs?
First of all, do you have any entry for that share in your fstab?
No sir. Nothing in /etc/fstab for either.
I do see artifacts for these mounts in my mtab file.