How do you force a CIFS connection to unmount
I use lazy unmount: umount -l
(that's a lowercase 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.)
How to unmount a busy device
YES!! There is a way to detach a busy device immediately - even if it is busy and cannot be unmounted forcefully. You may cleanup all later:
umount -l /PATH/OF/BUSY-DEVICE
umount -f /PATH/OF/BUSY-NFS (NETWORK-FILE-SYSTEM)
NOTE/CAUTION
- These commands can disrupt a running process, cause data loss OR corrupt open files. Programs accessing target DEVICE/NFS files may throw errors OR could not work properly after force unmount.
- Do not execute above
umount
commands when inside mounted path (Folder/Drive/Device) itself. First, you may usepwd
command to validate your current directory path (which should not be the mounted path), then usecd
command to get out of the mounted path - to unmount it later using above commands.
Unmounting SMB share folder
When the mount command runs for more than one time, multiple sessions open in the background. Running u(n)mount command, only terminates one of the sessions while the other sessions are active in the background. The active sessions can be seen by running this command:
mount | grep /mnt/smb
Running u(n)mount command again terminates active sessions one by one and resolves the issue. I used this script to run u(n)mount command as many times as needed:
if [ "$(sudo mount | grep /mnt/smb)" != "" ]; then
sudo umount -l /mnt/smb/;
smbContents=$(sudo mount | grep /mnt/smb);
fi
while [ "$smbContents" != "" ]; do
sudo umount -l /mnt/smb/;
smbContents=$(sudo mount | grep /mnt/smb);
done
Force unmount of NFS-mounted directory
You might try a lazy unmount:
umount -l
Kali on windows CIFS support
using:
sudo mount -t drvfs \\server\directory \mountpoint
WSL now supports drvfs which can connect to remote drives etc.
So no need for cifs/samba
Related Topics
How to Format My Grep Output to Show Line Numbers at the End of the Line, and Also the Hit Count
Fast Way to Get Image Dimensions (Not Filesize)
Check Whether a Certain File Type/Extension Exists in Directory
Sanitize Environment with Command or Bash Script
How to Give a Linux User Sudo Access
How to Check If a Process Is in Hang State (Linux)
How to Mount an Iso Inside a Docker Container
How to Remove Jenkins Completely from Linux
How to Swap /Dev/Sda with /Dev/Sdb
How to Check If a Service That I Don't Know the Name of Is Running on Ubuntu
Linux Cmd to Search for a Class File Among Jars Irrespective of Jar Path
I Get "Dquote>" as a Result of Executing a Program in Linux Shell
Importing a Cmake Project into Eclipse Cdt
How to Delete a User in Linux When the System Says Its Currently Used in a Process
How to Use Linux Command Sort to Sort the Text File According to 4Th Column, Numeric Order
Setting Up Permissions for Wordpress on Amazon Ec2 (Amazon Linux)