Attempting to unmount an external USB drive, detach an NFS network share, or remove a directory in Linux using umount /mnt/drive or rm -rf /folder only to be blocked by the error message “umount: /mnt/drive: target is busy. (In some cases useful info about processes that use the device is found by lsof(8) or fuser(1))” or “rm: cannot remove ‘directory’: Device or resource busy” (system errno EBUSY) halts storage administration. In Linux, the VFS (Virtual Filesystem Switch) enforces strict locking semantics: a filesystem or resource node cannot be unmounted or deleted while any running process holds an open file descriptor, an active working directory handle (CWD), or an active swap space allocation. This guide explains how to identify blocking processes using fuser and lsof, release open descriptors safely, and perform lazy unmounts without risking data corruption.
What Causes the ‘Device or Resource Busy’ Error in Linux?
The Linux kernel prevents storage unmounting whenever active process handles are bound to the mount point:
- Active Working Directory (CWD) Lock: An open terminal window or shell session has its current directory located inside the mount tree (e.g.,
cd /mnt/drive). - Open File Descriptors: Background system services, text editors (such as nano or vim), or media servers currently holding open read/write handles on files within the volume.
- Active NFS, Samba, or SSHFS Shares: Remote network clients actively streaming data or querying exported filesystem nodes.
- Active Swap or Loopback Devices: A swapfile located on the target partition is active and mapped into kernel virtual memory.
- Stale Mount Bindings: Nested bind mounts or systemd automount units querying the target path concurrently.
Method 1: Identify and Terminate Locking Processes with fuser
The fuser tool identifies every process ID (PID) holding an active handle on a directory or block device.
- Open your Linux terminal.
- Query which processes are holding locks on the mount point:
sudo fuser -v -m /mnt/drive - Examine the output. PIDs will be listed alongside access flags:
c: Process current working directory (CWD).e: Executable running from the directory.f: Open file descriptor for reading or writing.
- To kill all locking processes gracefully with
SIGTERM:sudo fuser -k -m /mnt/drive - If processes fail to terminate, force closure with
SIGKILL:sudo fuser -k -9 -m /mnt/drive - Attempt to unmount the filesystem cleanly:
sudo umount /mnt/drive
Method 2: Trace Open File Descriptors Using lsof
The lsof utility lists specific open filenames, user accounts, and process commands holding file handles.
- List all open files and active processes on the target mount point:
sudo lsof +D /mnt/drive - The console will display the
COMMAND,PID,USER, and exactNAMEof the locked file. - Save any work in open applications (such as closing document editors or database daemons) and terminate the specific PID:
sudo kill -15 <PID> - Verify that your own shell session is not positioned inside the mount folder:
cd ~ - Execute
sudo umount /mnt/drive.
Method 3: Perform a Lazy Unmount (umount -l)
When remote network shares (NFS/CIFS) hang or background processes cannot be killed immediately, a lazy unmount detaches the filesystem hierarchy cleanly.
- Execute the lazy unmount command:
sudo umount -l /mnt/drive - How it works: The
-l(lazy) flag immediately detaches the filesystem from the directory tree, making it invisible to new processes, while the kernel waits for existing read/write transactions to close before releasing physical memory references. - For remote network mounts that have disconnected upstream, execute a forced lazy unmount:
sudo umount -f -l /mnt/drive
Method 4: Deactivate Active Swap Space and Loopback Mounts
If the partition contains a paging file, Linux prevents unmounting until swap is disabled.
- Check if any swap files reside on the target partition:
swapon --show - If an active swapfile is located on
/mnt/drive, deactivate it:sudo swapoff /mnt/drive/swapfile - Unmount the partition:
sudo umount /mnt/drive