You plug in a USB stick, copy some files, then try to unmount it with umount /media/usb and get slapped with umount: /media/usb: target is busy. This happens more often than you'd think, especially after you've opened a file manager window browsing that drive, or a terminal is sitting in a directory on the USB. I had a client last month whose entire print queue died because they yanked a USB drive that was holding a print job. Don't be that person.
Why does this happen?
The kernel won't let you unmount a filesystem that has open files or active processes using it. That's it. Something is reading, writing, or just has a handle on that drive. Maybe it's a background thumbnailer scanning images, a text editor with a file open, or a shell session with its current working directory on the USB. The error is your safety net.
The fix: find and stop the process
The real fix is to find what's holding the mount and deal with it. Don't just yank the cable – you'll risk data corruption. Here's the step-by-step that works.
- Identify the mount point. If you're not sure, run
mount | grep usborlsblkto see where it's mounted. - Use
fuserto see who's using it. This shows you the process IDs (PIDs) with open files on that mount:
That'll print something like:fuser -v /media/usb
TheUSER PID ACCESS COMMAND user 1234 cwd bash user 5678 r-- vimcwdmeans that process is sitting in a directory on the USB. Ther--means it has a file open for reading. - Kill those processes. If it's safe, kill them with
fuser -km /media/usb. That sends SIGKILL to all processes using the mount. It's blunt but effective. For a GUI app like a file manager, you might want to close it normally first. - Try unmount again. Now run
umount /media/usb. If it still says busy, repeat fuser to see if something else snuck in.
Sometimes the culprit is a daemon like gvfsd or tracker that indexes files. If fuser shows those, you can disable them temporarily, but often just killing the process works. On my own machine, it's almost always a leftover terminal window.
What if you absolutely must unmount now?
If you're in a pinch and data integrity isn't critical, you can do a lazy unmount. This detaches the filesystem immediately but keeps it mounted in the background until all processes close their handles. It's not ideal – you might lose unsaved data – but it prevents the 'target is busy' error:
umount -l /media/usb
I've used this when a USB drive was stuck and I needed to reboot. But I don't recommend it as a habit. It's like using a crowbar when a key would do.
Still stuck? Check these.
If you've killed everything fuser shows and it still won't unmount, here's what to check:
- Swap files or loop devices. If the USB is formatted as ext4 with a swap file, or you've attached a loop device to it, unmounting might fail. Run
losetup -ato check for loop devices andswapoffif needed. - NFS or Samba exports. If you exported that filesystem over the network, clients may hold it. Check
exportfs -vand unexport if necessary. - Systemd mount units. Sometimes systemd auto-mounts drives and needs a
systemctl stopfirst. Look for units withsystemctl list-units | grep media-usband stop them. - A buggy kernel module. Rare, but if none of the above helps, try
syncthen reboot with the drive attached – it'll unmount cleanly on shutdown.
The key is to never force it unless you have to. Killing the offending process is always better than yanking the cable. Once you've done that a few times, you'll spot the culprit instantly.