umount - device is busy

It means that some process has a working directory or an open file handle underneath the mount point. The best thing to do is to end the offending process, change its working directory or close the file handle before unmounting.

There is an alternative on Linux though. Using umount -l calls a "lazy" unmount. The filesystem will still be mounted but you won't be able to see or use it, except for processes that are already using it. When the offending program exits (through whatever means) the system will "finish" unmounting the filesystem.


You can also use fuser to kill all processes using the mounted file system.

fuser -cuk /mnt

Options:

-c     
    Same as -m option, used for POSIX compatibility.

-u, --user
    Append the user name of the process owner to each PID.

-k, --kill
    Kill  processes accessing the file. Unless changed with -SIGNAL, SIGKILL is sent. An fuser process
    never kills itself, but may kill other fuser processes. The  effective  user  ID  of  the  process
    executing fuser is set to its real user ID before attempting to kill.kill.

-m NAME, --mount NAME
    NAME specifies a file on a mounted file system or a block device that is  mounted.  All  processes
    accessing  files  on  that  file  system  are  listed.   If  a  directory file is specified, it is
    automatically changed to NAME/. to use any file system that might be mounted on that directory.

Check for yourself at explainshell.


Given your "usual solution", it means that the shell you have running in your console window has a directory in a file system on that device as its current working directory.

Linux, and Unixes in general, want very badly to keep a file system mounted if a process has a current working directory in that filesystem.

You could just use cd in the console window to get out of a directory in or under /mnt rather than killing the console window, and the shell running inside it.

Tags:

Mount