> 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/di-43-zhang-freebsd-nei-he-jia-gou/di-43.2-jie-freebsd-nei-he-wen-jian-jie-gou.md).

# 43.2 FreeBSD 内核文件结构

FreeBSD 内核配置选项按体系结构分目录存放。本节以 GENERIC 文件为例说明配置指令语法。

## 内核配置选项路径

各架构的配置路径如下：

| 架构     | 路径                                                                                |
| ------ | --------------------------------------------------------------------------------- |
| amd64  | [sys/amd64/conf](https://github.com/freebsd/freebsd-src/tree/main/sys/amd64/conf) |
| arm64  | [sys/arm64/conf](https://github.com/freebsd/freebsd-src/tree/main/sys/arm64/conf) |
| RISC-V | [sys/riscv/conf](https://github.com/freebsd/freebsd-src/tree/main/sys/riscv/conf) |

## 内核配置文件说明（基于 amd64）

以下介绍 [freebsd-src/main/sys/amd64/conf](https://github.com/freebsd/freebsd-src/tree/main/sys/amd64/conf) 目录中的主要内核配置文件：

| 配置文件              | 说明                                                                                                                                                                                                                                                                                                                                                                   |
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `DEFAULTS`        | FreeBSD/amd64 的默认内核配置文件，作为 GENERIC 等配置的基础，内容不足 30 行                                                                                                                                                                                                                                                                                                                  |
| `FIRECRACKER`     | 面向 Firecracker 虚拟机环境的内核配置文件                                                                                                                                                                                                                                                                                                                                          |
| `GENERIC`         | FreeBSD/amd64 通用内核配置文件，所有 amd64 架构的系统镜像默认基于此配置构建，约 350 行，适用于大多数硬件和使用场景                                                                                                                                                                                                                                                                                               |
| `GENERIC-KASAN`   | 供调试与开发使用。用于内核地址清理器（Kernel Address Sanitizer，KASAN）。内容不足十行                                                                                                                                                                                                                                                                                                            |
| `GENERIC-KCSAN`   | 供调试与开发使用。内核并发清理器（Kernel Concurrency Sanitizer，KCSAN）。30 余行                                                                                                                                                                                                                                                                                                           |
| `GENERIC-KMSAN`   | 供调试与开发使用。用于内核内存清理器（Kernel Memory SANitizer，KMSAN），内容不足十行                                                                                                                                                                                                                                                                                                             |
| `GENERIC-MMCCAM`  | 供调试与开发使用。用于使用 MMCCAM 代替 MMC 栈。内容不足二十行                                                                                                                                                                                                                                                                                                                                |
| `GENERIC-NODEBUG` | 该文件仅在 [main](https://github.com/freebsd/freebsd-src/blob/main) 分支中存在，用于基准测试。基于 GENERIC 配置文件构建，但移除了 [WITNESS(4)](https://man.freebsd.org/cgi/man.cgi?query=witness\&sektion=4)（跟踪每个线程获取和释放的锁）和 [KASSERT(9)](https://man.freebsd.org/cgi/man.cgi?query=KASSERT\&sektion=9)（内核表达式验证宏）。CURRENT 的 GENERIC 默认启用了上述调试功能，通过引入 `std.debug` 实现，这会对系统性能产生影响，生产环境可考虑使用此配置。内容三十余行 |
| `GENERIC.hints`   | 包含若干 [device.hints(5)](https://man.freebsd.org/cgi/man.cgi?query=device.hints\&sektion=5) 参数，用于设置驱动参数。内容二十余行                                                                                                                                                                                                                                                         |
| `LINT`            | 用于内核编译完整性检查的配置文件。内容不足五行                                                                                                                                                                                                                                                                                                                                              |
| `LINT-NOINET`     | LINT 变体文件，内容不足五行，禁用了 INET(4)(IPv4)                                                                                                                                                                                                                                                                                                                                   |
| `LINT-NOINET6`    | LINT 变体文件，内容不足五行，禁用了 INET6(4)(IPv6)                                                                                                                                                                                                                                                                                                                                  |
| `LINT-NOIP`       | LINT 变体文件，内容不足三十行，禁用了 IP 协议相关功能（IPv4、IPv6、TLS 等）                                                                                                                                                                                                                                                                                                                     |
| `LINT-NOVIMAGE`   | 供调试与开发使用。LINT 变体文件，内容不足五行，禁用了 VIMAGE(9)（基于 VNET(9) 网络子系统虚拟化基础设施的内核选项）                                                                                                                                                                                                                                                                                                |
| `MINIMAL`         | FreeBSD/amd64 中常用的精简内核配置选项，包含 160 余行，适用于资源受限的环境                                                                                                                                                                                                                                                                                                                      |
| `MINIMAL-NODEBUG` | 功能等同于 GENERIC-NODEBUG，但基于 `MINIMAL` 配置构建。内容不足 15 行                                                                                                                                                                                                                                                                                                                   |

## 内核选项说明文件

除内核配置文件外，还有相应的说明文件，用于解释各种内核选项。这些说明文件分布在不同体系结构和通用配置目录下：

| 路径                                                                                            | 说明                                         |
| --------------------------------------------------------------------------------------------- | ------------------------------------------ |
| [sys/amd64/conf/NOTES](https://github.com/freebsd/freebsd-src/blob/main/sys/amd64/conf/NOTES) | amd64 机器相关的内核配置说明文件，内容不足 200 行             |
| [sys/x86/conf/NOTES](https://github.com/freebsd/freebsd-src/blob/main/sys/x86/conf/NOTES)     | x86（amd64 与 i386）共用的机器相关内核配置说明文件，包含 650 余行 |
| [sys/arm64/conf/NOTES](https://github.com/freebsd/freebsd-src/blob/main/sys/arm64/conf/NOTES) | arm64（aarch64）机器相关的内核配置说明文件，内容不足 270 行     |
| [sys/riscv/conf/NOTES](https://github.com/freebsd/freebsd-src/blob/main/sys/riscv/conf/NOTES) | riscv64（64 位 RISC-V）机器相关的内核配置说明文件，包含 100 行 |
| [sys/conf/NOTES](https://github.com/freebsd/freebsd-src/blob/main/sys/conf/NOTES)             | 机器无关的说明，包含近 2900 行                         |

目录结构：

```sh
sys/
├── amd64/
│   └── conf/
│       ├── DEFAULTS
│       ├── FIRECRACKER
│       ├── GENERIC
│       ├── GENERIC-KASAN
│       ├── GENERIC-KCSAN
│       ├── GENERIC-KMSAN
│       ├── GENERIC-MMCCAM
│       ├── GENERIC-NODEBUG
│       ├── GENERIC.hints
│       ├── LINT
│       ├── LINT-NOINET
│       ├── LINT-NOINET6
│       ├── LINT-NOIP
│       ├── LINT-NOVIMAGE
│       ├── MINIMAL
│       ├── MINIMAL-NODEBUG
│       └── NOTES
├── x86/
│   └── conf/
│       └── NOTES
├── arm64/
│   └── conf/
│       └── NOTES
├── riscv/
│   └── conf/
│       └── NOTES
└── conf/
    ├── NOTES
    └── std.debug
```

## CURRENT 中的调试功能

FreeBSD-CURRENT（main 分支）作为开发主线，旨在提供完善的调试基础设施，以支撑内核与驱动程序的开发及测试。所有 main 分支上的 FreeBSD 系统（即 CURRENT）均默认启用调试功能，此配置会对系统性能产生明显影响。

CURRENT 的默认内核 GENERIC 均启用了 `include "std.debug"` 文件所述的调试功能（arm64 在文件 [sys/arm64/conf/std.arm64](https://github.com/freebsd/freebsd-src/blob/main/sys/arm64/conf/std.arm64) 中指定，由 GENERIC 间接引用）。

`std.debug` 文件由 [sys/amd64/conf: unify MINIMAL and GENERIC debug](https://github.com/freebsd/freebsd-src/pull/1124) 引入。

`std.debug` 文件的实际文本内容位于 [sys/conf/std.debug](https://github.com/freebsd/freebsd-src/blob/main/sys/conf/std.debug)。本节撰写时，`std.debug` 文件约包含 20 行。

若需禁用调试功能以获得更高的性能，可使用 GENERIC-NODEBUG 配置，或创建自定义配置文件并移除 `std.debug` 的引用。

## 参考文献

* Firecracker\[EB/OL]. \[2026-03-26]. <https://firecracker-microvm.github.io>；amd64: Add FIRECRACKER kernel configuration\[EB/OL]. \[2026-03-26]. <https://reviews.freebsd.org/D36672>.
* amd64: Add MD bits for KASAN\[EB/OL]. \[2026-03-26]. <https://reviews.freebsd.org/D29455>.
* kasan(9)\[EB/OL]. \[2026-03-26]. <https://man.freebsd.org/cgi/man.cgi?query=kasan&sektion=9>.
* KMSAN(9)\[EB/OL]. \[2026-03-26]. <https://man.freebsd.org/cgi/man.cgi?query=kmsan&sektion=9>.
* Port the NetBSD KCSAN runtime to FreeBSD\[EB/OL]. \[2026-03-26]. <https://reviews.freebsd.org/D22315>.
* MMC stack on top of CAM framework\[EB/OL]. \[2026-03-26]. <https://reviews.freebsd.org/D4761>.
* Eliminate building LINT makefiles\[EB/OL]. \[2026-03-26]. <https://reviews.freebsd.org/D26540>.
* sys: add LINT-NOVIMAGE\[EB/OL]. \[2026-03-26]. <https://reviews.freebsd.org/D50780>.


---

# 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/di-43-zhang-freebsd-nei-he-jia-gou/di-43.2-jie-freebsd-nei-he-wen-jian-jie-gou.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.
