brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: fuser -vm shows which process keeps a Linux disk busy when umount fails

Linux
~/tips/tip-linux-fuser-mount-busy

sudo fuser -vm /mnt/backup

Finds the processes that use a mount or a port, so you know what blocks an unmount.

“target is busy” when you try to unmount a disk, and no clue why. fuser tells you who is using it.

sudo fuser -vm /mnt/backup

-m looks at every process that uses a file on that filesystem, and -v gives a readable table with the PID, user, access type and command. Often it is a shell whose current directory is somewhere on the disk, or a container with a bind mount.

It also works for network ports, using the port/protocol form:

sudo fuser -v 8080/tcp

That shows what listens on or uses TCP port 8080. The long form is -n tcp 8080.

There is a -k option that kills the processes it finds, and -i to ask before each one. I’d always run it without -k first and read the list.

Caveats. The man page gives fuser -km /home as an example of what kills every process that touches /home, which on a normal system includes your own login. -m also matches any file on the same device, so if you give it a plain directory instead of the mount point you get more than you think; -M makes sure the name is a mount point. Without root you only see part of the picture, so use sudo.

Further reading: fuser manual

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link