有时当我想卸载设备时,例如
sudo umount /dev/loop0
Run Code Online (Sandbox Code Playgroud)
我会收到消息
umount: /mnt: device is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
Run Code Online (Sandbox Code Playgroud)
我通常通过关闭控制台窗口(在我的情况下为 xfce4-terminal)然后关闭umount
.
这个问题是什么意思?有没有更聪明的解决方案?
bah*_*mat 17
这意味着某些进程在挂载点下有一个工作目录或一个打开的文件句柄。最好的办法是在卸载之前结束有问题的进程,更改其工作目录或关闭文件句柄。
不过在 Linux 上有一个替代方案。使用umount -l
调用“懒惰”卸载。文件系统仍将被挂载,但您将无法看到或使用它,除了已经在使用它的进程。当有问题的程序退出(通过任何方式)时,系统将“完成”卸载文件系统。
sys*_*m1n 14
您还可以fuser
使用已安装的文件系统来终止所有进程。
fuser -cuk /mnt
Run Code Online (Sandbox Code Playgroud)
选项:
-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.
Run Code Online (Sandbox Code Playgroud)
在explainshell 上检查自己。
归档时间: |
|
查看次数: |
99588 次 |
最近记录: |