Short answer: Device or resource busy is error EBUSY (errno 16): the kernel refuses to unmount, remove or rename something that is still in use. For umount: target is busy, find the process that holds the mount (very often your own shell sitting inside it), stop it, then unmount again. For rm or mv, the path is usually a mount point.
cd / # leave the mount point yourself first
sudo fuser -vm /mnt/data # processes using the filesystem (psmisc)
sudo lsof /mnt/data # open files on it, with program, PID and FD
findmnt -R /mnt/data # anything else mounted below it?
swapon --show # a swap file on it?
sudo umount /mnt/data # try againWhat EBUSY means
The number and the text come from the kernel headers, and every program that prints strerror() shows the same words. On our Debian 12 server:
$ grep -E 'define\s+EBUSY' /usr/include/asm-generic/errno-base.h
#define EBUSY 16 /* Device or resource busy */
$ python3 -c 'import errno, os; print(errno.EBUSY, errno.errorcode[16], os.strerror(16))'
16 EBUSY Device or resource busyerrno(3) lists EBUSY as a POSIX.1-2001 error; the system call pages say when it happens. Per umount(2) the target could not be unmounted because it is busy. Per rmdir(2) and unlink(2) the path is in use as a mount point (or, for unlink, is an NFS "silly renamed" file), and per rename(2) a directory involved is in use by the system, for example as a mount point. Node.js reports it as EBUSY: resource busy or locked (libuv's wording) with code: 'EBUSY', and Python raises a plain OSError with errno 16.
umount from util-linux does not print the errno text. It says umount: /mnt/data: target is busy., which is the same EBUSY in friendlier words.
Causes at a glance
| Cause | How to see it | Fix |
|---|---|---|
| A shell or service has its working directory inside the mount | fuser -vm | cd out, stop the service |
| A process has a file open on the filesystem | lsof /mnt/data | stop or restart it |
| Another filesystem is mounted below it | findmnt -R | unmount the inner one first, or umount -R |
| A swap file on it is active | swapon --show | swapoff |
| An image file on it is attached to a loop device | losetup -l | losetup -d |
| NFS server unreachable | umount hangs or fails | umount -f, then -l |
| rm or mv on a mount point, or on a file Docker mounted | findmnt -T PATH | unmount, or work inside it |
umount: target is busy, find the process
umount(8) names the usual reasons: open files on the filesystem, a process with its working directory there, or a swap file on it that is in use. Two tools find the processes.
fuser -vm (from the psmisc package) lists every process that uses the filesystem a path belongs to. The ACCESS column tells you how: c current directory, e program being run, f or F open file (F for writing), r root directory, m mapped file or library. In verbose mode a line with kernel instead of a PID marks the mount point itself, which is normal. To see the columns without mounting anything, we held a file open with sleep in a scratch folder on our Debian 12 server and pointed fuser at the file and the folder (without -m, so it checks only those two names):
$ (cd ~/ebusy-test/data && exec sleep 120 3>>app.log) &
$ fuser -v ~/ebusy-test/data/app.log
USER PID ACCESS COMMAND
/root/ebusy-test/data/app.log:
root 3191927 F.... sleep
$ fuser -v ~/ebusy-test/data
USER PID ACCESS COMMAND
/root/ebusy-test/data:
root 3191927 ..c.. sleepF is the file open for writing, c the working directory: exactly the two things that make a mount busy. lsof 4.95 shows the same process with its file descriptors, cwd for the directory and 3w for the open file:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
sleep 3191927 root cwd DIR 8,1 4096 2033419 /root/ebusy-test/data
sleep 3191927 root 3w REG 8,1 6 2033420 /root/ebusy-test/data/app.logGiven a mount point, lsof /mnt/data lists every open file on that filesystem, because lsof reads a path that matches a mounted-on directory as a filesystem name. If it does not (lsof(8) mentions filesystems that are not on a block device), put +f and a double dash before the path. More ways to filter the output are in the lsof command guide. Run both tools with sudo: as a normal user, fuser and lsof cannot see other users' processes.
Then free the mount in this order:
- Leave it yourself:
cd /in every shell and tmux pane that sits inside. - Stop the service that writes there, for example
sudo systemctl stop postgresql, and close editors and file managers. - Only if a process cannot be stopped normally:
sudo fuser -M -m -k -i -TERM /mnt/data.-ksends SIGKILL unless you name another signal,-iasks before each kill, and-Mis what the man page calls a seat belt: fuser acts only if the name really is a mount point, so a typo cannot kill everything on the root filesystem. Details on signals are in how to kill a process.
A filesystem mounted inside it
A mount that has another mount below it counts as busy even when no process touches it: the kernel's check in fs/pnode.c (propagate_mount_busy) returns busy as soon as the mount has children. Typical cases are a bind mount under /mnt/data, a Docker volume, or /proc and /dev bound into a chroot.
findmnt -R /mnt/data # the mount and everything below it, as a tree
sudo umount /mnt/data/inner # inner mounts first
sudo umount -R /mnt/data # or all of them, deepest firstumount -R stops at the first mount that fails, so a busy inner mount still needs the process check above.
Swap files and loop devices
Neither belongs to a process, so they are easy to miss: lsof shows no program for them, and fuser in verbose mode shows an active swap file with kernel instead of a PID.
swapon --show # active swap areas; a path under /mnt/data counts
sudo swapoff /mnt/data/swapfile # needs enough free RAM to take the swapped pages back
losetup -l # loop devices and their BACK-FILE
losetup -j /mnt/data/disk.img # which loop device uses this image
sudo losetup -d /dev/loop0 # detach it (unmount whatever is mounted from it first)Remove or comment out the swap line in /etc/fstab too if the disk is going away; the swap guide covers removing a swap file. losetup(8) adds one detail: since Linux 3.7, losetup -d on a loop device that is still in use does not return EBUSY, it marks the device for automatic removal once it is free. Until then the backing file, and with it the filesystem that holds it, is still in use, so check losetup -l again before you unmount.
NFS and other network mounts
When the server is gone, umount can hang instead of failing. umount(8) offers two options, each with a cost:
sudo umount -f /mnt/nfsforces the unmount for an unreachable NFS server. umount(2) says the filesystem aborts pending requests first, which can lose data, and the unmount still fails if processes keep references. Use the absolute path without symlinks so umount does not stat the dead share.sudo umount -l /mnt/nfs(lazy) detaches the mount from the tree at once and finishes the unmount when it stops being busy. umount(8) recommends it for hangs at shutdown caused by an unreachable share, and warns that you should expect to reboot soon after using it on a network filesystem or on a local one with submounts.
rm and mv: cannot remove, Device or resource busy
rm: cannot remove '/mnt/data': Device or resource busy and mv: cannot move ... Device or resource busy almost always mean the path is a mount point. Check before you do anything else:
findmnt -T /mnt/data # which mount holds this path; TARGET equal to the path = it is a mount point
findmnt -rn -o TARGET | grep '^/srv/old/' # mounts anywhere below a directory you want to deleterm -rf on a directory that is a mount point is the dangerous case: rm walks into the mounted filesystem, deletes everything it can on it, and only then fails on the mount point itself. Unmount first. When the mount sits somewhere below the directory you delete, rm -r --one-file-system skips directories that are on another filesystem than the argument (it does not help when the argument is the mount point itself); the rm guide has the details. With mv, rename the files inside the mount instead of the mount point, or unmount, rename the empty directory and fix the mount path in /etc/fstab; see the mv command error table.
Device or resource busy in Docker
Docker mounts each container's own copies of /etc/resolv.conf, /etc/hosts and /etc/hostname over those paths (the NetworkMounts function in the moby daemon source). Each is a mount point inside the container, so rm and mv on them fail with EBUSY, and so does sed -i: GNU sed writes a temporary file and renames it over the original, and the rename is refused. GNU sed 4.9 reports it as sed: cannot rename /etc/sedXXXXXX: Device or resource busy.
- Set the values when the container is created instead:
--dns,--add-hostand--hostnameondocker run, or the matching keys in Compose. See docker run. - For a quick test, overwrite the content instead of replacing the file:
cat new.conf > /etc/resolv.confwrites into the mounted file and works. Expect the change to be gone when the container is recreated. - A
RUN rm -rf /dataor cleanup script on a path that is a volume behaves like the host case above: the volume's files are deleted, then the mount point answers EBUSY.
The same error from mount
Mounting can fail with EBUSY too. If the device is already mounted, util-linux names the place, for example mount: /mnt/data: /dev/sdb1 already mounted on /srv/old. If it finds no such mount (the device is claimed by something else, or the mount point is busy), it prints mount: /mnt/data: /dev/sdb1 already mounted or mount point busy. and a second line that points to dmesg(1). findmnt -S /dev/sdb1 and lsblk /dev/sdb show where the device is in use. Per mount(2), mount -o remount,ro also fails with EBUSY while files on the filesystem are open for writing, and the process check above finds them. A disk that is in use and also mounted read-only by the kernel after errors is a different problem, covered in Read-only file system.
Unmounting a data disk on a VPS or dedicated server
On a server the holder is almost always a service: a database, a web server writing logs, or a backup job. Stop it with sudo systemctl stop NAME before you unmount, not after umount has failed, then check sudo fuser -vm /mnt/data once more and unmount. Detach or resize the volume at your provider only after umount returned without an error and findmnt /mnt/data prints nothing. If the disk will not come back, remove its line from /etc/fstab as well, or add nofail: a missing disk without it can stop the next boot in emergency mode. The rest of the mount workflow is in how to mount a disk on Linux, and check disk usage shows what is on the disk before it goes.
Frequently asked
What does Device or resource busy mean on Linux?
It is error EBUSY, number 16. The kernel refuses to unmount, remove or rename something that is still in use, most often a mounted filesystem with open files, a process working inside it, or a mount point you tried to delete or rename.
How do I fix umount: target is busy?
Run cd / in your own shells, then sudo fuser -vm /mnt/data or sudo lsof /mnt/data to find the processes that still use the filesystem. Stop those services or programs, check findmnt -R for mounts below it and swapon --show for a swap file on it, then run umount again.
Is umount -l safe?
It is safe for the data in the sense that nothing is cut off: the mount disappears from the tree, but processes that use it keep working and the kernel finishes the unmount when they stop. The disk is still in use until then, so do not detach, reformat or unplug it. umount(8) recommends lazy unmount mainly for unreachable network shares and expects a reboot soon after.
Why can I not edit /etc/resolv.conf inside a Docker container?
Docker mounts the container's own copies of /etc/resolv.conf, /etc/hosts and /etc/hostname over those paths, and a mount point cannot be removed or renamed. rm, mv and sed -i therefore fail with Device or resource busy. Set the values with --dns, --add-host and --hostname when you create the container, or overwrite the content with cat new.conf > /etc/resolv.conf for a quick test.