用 hdiutil detach 从终端推出磁盘或 U 盘
在命令行安全卸载并推出外置硬盘、U 盘和镜像卷。
运行 hdiutil detach 并用引号包住挂载路径,即可安全推出该卷。
01命令
命令
$ hdiutil detach "/Volumes/MyUSB"02作用说明
卷名经常含空格,所以路径要用引号。若提示 "resource busy",说明还有程序占用文件,可用 lsof +D /Volumes/MyUSB 查看是哪个进程。hdiutil eject 与 detach 作用相同。它会先写入剩余数据再卸载,相当于 Finder 的推出按钮。
03风险
!注意: 未推出就拔掉 U 盘可能丢失尚未写入的数据。
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- hdiutil – Create and manipulate disk images依据: hdiutil detach unmounts and ejects a volume identified by its mount point or device node.
最后验证: 2026-09-18 · 分类: 文件与文件夹