EBUSY
Linux / POSIXERRORNotableDevicesHIGH confidence
Device or Resource Busy
What this means
The device or resource is currently in use by another process or mount point and cannot be accessed as requested. This is commonly encountered when trying to unmount a filesystem that has open files, or reformatting a mounted partition.
Why it happens
- 1Trying to unmount a filesystem while processes have files open on it.
- 2Attempting to remove or change a swap partition while it is active.
- 3Creating a loop device that is already in use.
- 4Deleting a module that a loaded driver depends on.
How to reproduce
Unmounting a filesystem while a shell is working inside it.
trigger — this will error
trigger — this will error
$ umount /mnt/data umount: /mnt/data: target is busy
expected output
umount: /mnt/data: target is busy
Fix
Find and stop processes using the mount point
WHEN When trying to unmount a filesystem
Find and stop processes using the mount point
# List processes using the mount point sudo fuser -vm /mnt/data # Or use lsof lsof +D /mnt/data # Kill all processes using it (use with care) sudo fuser -km /mnt/data sudo umount /mnt/data
Why this works
fuser identifies which processes have files open on the mount point. Stopping them releases the hold on the filesystem.
Sources
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev