首页·终端命令

umount

文件与目录

用法

sudo umount [mountpoint]

把已挂载的文件系统卸下;命令名里没有 n,只要还有进程在里面开着文件或把工作目录留在其中,它就会报 device is busy。

常用选项

选项含义
-lLinux: detach lazily, as soon as nothing is using it
-fForce, which is what an unreachable network share needs
-RLinux: unmount everything below a path
-aUnmount everything listed in /etc/fstab

示例

sudo umount /mnt

Detaches the filesystem.

sudo umount -l /mnt

Detaches as soon as the last user is done (Linux).

lsof +D /mnt

Finds what is holding it when it says target is busy.

移动、删除和查找。有些命令不会再问一遍,所以顺手加 -i 是在救自己。

怎么看

  • 方括号 [ ] 表示这部分可以不写。
  • 省略号 … 表示可以写多个。
  • 选项区分大小写——有些命令里 -r 和 -R 不是一回事。

常见问题

Q. umount 是做什么的?

把已挂载的文件系统卸下;命令名里没有 n,只要还有进程在里面开着文件或把工作目录留在其中,它就会报 device is busy。

Q. 怎么写?

sudo umount [mountpoint] —— 方括号表示可以省略的部分。

Q. 值得记的选项有几个?

这里列了 4 个,完整列表在 man umount。这条命令属于文件与目录。

相关命令

man 手册: man umount