> For the complete documentation index, see [llms.txt](https://book.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.bsdcn.org/man/man8/umount.8.md).

# umount.8

`umount` — 卸载文件系统

## 名称

`umount`

## 概要

`umount [-dfNnv] special ... | node ... | fsid ...`

`umount -a | -A [-F fstab] [-fnv] [-h host] [-t type]`

## 描述

`umount` 工具调用 unmount(2) 系统调用，从文件系统树中移除文件系统。文件系统可以通过其 `special` 设备或远程节点（rhost:path）、挂载点路径 `node` 或由 root 运行 `mount -v` 时报告的文件系统 ID `fsid` 来指定。

选项如下：

**`-a`** 卸载 [fstab(5)](https://github.com/FreeBSD-Ask/freebsd-man-sc/blob/main/man5/fstab.5.md) 中描述的所有文件系统。

**`-A`** 卸载所有当前已挂载的文件系统，但挂载在 **/** 或 **/dev** 上的除外。

**`-d`** 如果文件系统挂载在 [md(4)](https://github.com/FreeBSD-Ask/freebsd-man-sc/blob/main/man4/md.4.md) 设备（内存磁盘）上，在 unmount(2) 之后分离它。

**`-F`** `fstab` 指定要使用的 `fstab` 文件。

**`-f`** 强制卸载文件系统。活动的特殊设备继续工作，但所有其他文件在尝试进一步访问时返回错误。根文件系统不能被强制卸载。对于 NFS，针对无响应的服务器执行强制卸载可能需要 1 分钟或更长时间才能完成，并且在这种情况下可能会丢弃尚未写入服务器的数据。如果进程（如不带 `-f` 标志的 `umount`）挂在 NFS 挂载点上，请改用 `-N` 标志。此外，在 rpc.lockd(8) 运行时强制卸载 NFSv3 挂载是不安全的，可能导致崩溃。

**`-h`** `host` 仅卸载从指定主机挂载的文件系统。此选项隐含 `-A` 选项，并且除非用 `-t` 选项另行指定，否则仅卸载 NFS 文件系统。

**`-N`** 对 NFS 挂载点执行强制卸载，而不检查挂载路径。此选项只能与挂载点路径 `node` 一起使用，并且路径必须与挂载时完全一致地指定。当进程因等待无响应的 NFS 服务器而挂起，同时在挂载点 vnode 上持有 vnode 锁，导致带 `-f` 标志的 `umount` 无法完成时，此选项很有用。使用此选项可能导致尚未刷新到 NFS 服务器的文件更新丢失。

**`-n`** 除非使用 `-f`，否则 `umount` 不会卸载活动文件系统。但是，它会执行刷新。此标志禁用此行为，如果有任何文件打开，则阻止刷新。

**`-t`** `type` 用于指示应仅对指定类型的文件系统执行操作。可以在逗号分隔的列表中指定多种类型。文件系统类型列表可以加前缀“no”来指定*不应*执行操作的文件系统类型。例如，`umount` 命令：

```sh
umount -a -t nfs,nullfs
```

将卸载 [fstab(5)](https://github.com/FreeBSD-Ask/freebsd-man-sc/blob/main/man5/fstab.5.md) 文件中列出的所有 NFS 和 NULLFS 类型的文件系统。

**`-v`** 详细模式，每卸载一个文件系统时打印附加信息。

## 环境变量

**`PATH_FSTAB`** 如果设置了环境变量 `PATH_FSTAB`，所有操作都针对指定文件执行。如果进程环境或内存地址空间被视为“受污染”，则 `PATH_FSTAB` 将不被接受。（参见 issetugid(2) 获取更多信息。）

## 文件

**/etc/fstab** 文件系统表

## 参见

unmount(2), [fstab(5)](https://github.com/FreeBSD-Ask/freebsd-man-sc/blob/main/man5/fstab.5.md), [autounmountd(8)](/man/man8/autounmountd.8.md), mdconfig(8), [mount(8)](/man/man8/mount.8.md)

## 历史

`umount` 工具出现于 Version 1 AT\&T UNIX。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://book.bsdcn.org/man/man8/umount.8.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
