无法卸载 dmg。持续显示“资源繁忙”

Mar*_*ark 5 dmg-image hdiutil lsof macos

“工作区”是一个加密的 dmg,我在其中保存代码。我通常不会卸载它,但我需要进行备份,但它拒绝让我卸载:

\n\n
mark@mark-macbook-air /Volumes$ lsof | grep Workspace\nmark@mark-macbook-air /Volumes$ lsof Workspace\nmark@mark-macbook-air /Volumes$ hdiutil detach /Volumes/Workspace\nhdiutil: couldn\'t unmount "disk1" - Resource busy\nmark@mark-macbook-air /Volumes$ hdiutil unmount /Volumes/Workspace\nhdiutil: unmount: "/Volumes/Workspace" failed to unmount due to error 49168.\nhdiutil: unmount failed - Resource busy\nmark@mark-macbook-air /Volumes$ ls\nMacintosh HD@ Workspace/\n
Run Code Online (Sandbox Code Playgroud)\n\n

如果我尝试通过 Finder 卸载:

\n\n
"The disk \xe2\x80\x9cWorkspace\xe2\x80\x9d couldn\xe2\x80\x99t be ejected because \xe2\x80\x9cTerminal\xe2\x80\x9d is using it.".\n
Run Code Online (Sandbox Code Playgroud)\n\n

我只打开了一个终端窗口。看来我可以关闭终端,但因为我很确定它没有使用它,所以我运行sudo lsof并看到了几个“mds”和一个“login”。MDS 是聚光灯的一部分,因此我在卷上禁用了聚光灯索引。这杀死了一些进程。我现在只剩下两个:

\n\n
mark@mark-macbook-air /Volumes$ sudo lsof /Volumes/Workspace/\nCOMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME\nlogin    653 root  cwd    DIR    1,5      850   29 /Volumes/Workspace/src/projectname\nmds     2106 root    5r   DIR    1,5      476    2 /Volumes/Workspace\n
Run Code Online (Sandbox Code Playgroud)\n\n

我的问题是为什么要login使用我的驱动器?这很糟糕吗?我应该怎么办?\\

\n\n

编辑:登录似乎已单独保留驱动器,但由于 mds,我仍然无法卸载。

\n

小智 5

您可以使用以下命令强制卸载它:

hdiutil unmount /Volumes/Workspace -force
Run Code Online (Sandbox Code Playgroud)

如果需要,使用 detach 命令可以帮助卸载并弹出磁盘。

如果上面的命令报出如下错误信息:

hdiutil: detach failed - No such file or director
Run Code Online (Sandbox Code Playgroud)

说明路径不正确,可以用/Volumes/Workspace/*其他路径代替。


zel*_*nix 1

killForce Quit过程是安全的mds,如果您禁用了聚光灯索引,则它不应再次启动。