Device or resource busy
The Device or resource busy error means a file, directory, or mount point is currently in use by one or more processes. Linux prevents operations like unmounting, deleting, or modifying resources that are actively open.
What It Means
When you try to unmount a filesystem, delete a file, or modify a device, the kernel checks if any process holds a reference to it. If a process has the resource open (even in the background), Linux blocks the operation and reports the resource as busy.
Why It Happens
- You’re trying to unmount a filesystem while a terminal is open inside it.
- A file is open by a text editor, database, or server process.
- A daemon is using a device file (e.g., a webcam or sound card).
- NFS or Samba shares are mounted and a client holds an open handle.
- A loop device is attached to a disk image you’re trying to detach.
How to Fix It
1. Find which processes are using the resource
lsof /path/to/file
fuser -v /mountpointlsof lists open files. fuser shows processes using a file or directory. Both need the exact path.
2. Kill the process using the file
# Get the PID from lsof output, then:
kill -9 PID
# Or use fuser to kill directly:
fuser -k /path/to/fileUse kill -9 as a last resort — it doesn’t let the process clean up. Try kill PID first.
3. Close terminal sessions in the mount
If the mount point is your current directory in another terminal:
# In the other terminal:
cd /
# Now unmount should work
sudo umount /mountpoint4. Lazy unmount (force detach)
sudo umount -l /mountpointumount -l detaches the filesystem immediately and cleans up once all handles close. Use this when a normal unmount keeps failing but you need to proceed.
5. Detach a loop device
sudo losetup -d /dev/loop0List attached loop devices with losetup -a first to find the right one.
6. Restart the service using the resource
sudo systemctl restart nginx
sudo systemctl restart dockerIf a service holds the resource, restarting it releases the handles.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro