# umount /mnt/backup
umount: unmount of /mnt/backup failed: Device busy
Every junior reaches for umount -f here. Don’t. Something has that filesystem open, and forcing the unmount just moves the problem into whatever that something was doing at the time. Ask the kernel who it is.
fstat, restricted to a filesystem
fstat -f /mnt/backup
-f takes a file or mount point and restricts the listing to files open on that filesystem. Output is one line per open file:
USER CMD PID FD MOUNT INUM MODE SZ|DV R/W
root rsync 4127 3 /mnt/backup 118 -rw-r--r-- 91234 r
rod sh 3990 wd /mnt/backup 2 drwxr-xr-x 512 r
Read the FD column, because it tells you how they are holding it:
- A number is an ordinary open descriptor. Your rsync, your database, your log writer.
wdis the working directory. This is the classic: somebody left a shellcd’d into the mount and went to lunch. Nothing is “open”, and it still blocks the unmount.textis the executable image. A binary running off that filesystem pins it.rootandjailare chroot and jail roots.mmaponly appears if you pass-m, which adds memory-mapped files. If the plain listing looks empty and the unmount still fails, run it again with-m.
Add -n if you want numeric device and inode output and not name lookups, and check fstat(1) on your release for the full column list before you parse anything.
The other two angles
fstat -p 4127
fstat -u rod
-p shows everything one process has open, which is what you want before you decide whether to kill it. -u shows everything one user has open, which is what you want when the answer is “somebody’s session”.
fuser gives you the short version:
fuser -c /mnt/backup
-c treats the argument as a mount point and prints the PIDs using that filesystem, each followed by a letter for how it is using it. Add -u for the owning user. fuser -k will signal them, and I would not run that against a mount until I had read the fstat output, because it will happily kill a database.
ZFS says the same thing, worse
# zfs unmount tank/data
cannot unmount '/tank/data': pool or dataset is busy
Same cause, vaguer message. fstat -f /tank/data works exactly the same, since you are naming the mount point. It also covers the case where a process is sitting in a snapshot directory under .zfs/snapshot, which will block a zfs destroy of that snapshot until it leaves. That bit me when I went hunting for what changed since a snapshot and left a shell parked in the snapshot I was about to delete.
When the list is empty
Then it is not a userland process. NFS clients holding a mount from the other direction, a mdconfig memory disk layered on a file in that filesystem (see memory disks for ZFS test pools), or a nested mount underneath it all produce “busy” with nothing to blame in fstat. Check mount for anything mounted below your target and unmount that first. Only after that is umount -f an honest conversation, and it is a last resort for a dead NFS server, not a shortcut for a lazy afternoon.
On Linux the equivalent is lsof or fuser -vm, which I covered in what is actually listening. On FreeBSD, fstat is in base, it has been there longer than I have had grey in my beard, and it does not need a package. More like it in the FreeBSD and OpenBSD hub.
