使用sshfs等方式挂载的目录出现问题时,使用umount卸载经常提示device is busy,如果仔细阅读错误提示就可以找到命令lsof和fuser命令。
其实原因就是有进程占用当前目录,导致不允许卸载,只要找到占用进程问题就解决了:
例,/mnt/test卸载:
$ sudo fuser -m /mnt/test
此时会列表进程信息:
Cannot stat file /proc/52441/fd/132: Permission denied Cannot stat file /proc/52441/fd/135: Permission denied Cannot stat file /proc/52441/fd/136: Permission denied Cannot stat file /proc/52441/fd/139: Permission denied Cannot stat file /proc/52441/fd/149: Permission denied Cannot stat file /proc/52441/fd/151: Permission denied Cannot stat file /proc/52441/fd/164: Permission denied Cannot stat file /proc/52441/fd/169: Permission denied Cannot stat file /proc/52441/fd/173: Permission denied Cannot stat file /proc/52441/fd/186: Permission denied Cannot stat file /proc/52441/fd/188: Permission denied Cannot stat file /proc/52441/fd/196: Permission denied ...
其中52441即为进程ID了,可以通过查看/proc/52441/cmdline确认进程对应程序
其它就可以根据实际情况处理进程了,之后再执行 sudo umount /mnt/test即可卸载。