> 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/zfs/an-zhuang-zhi-yin/fedora/index.md).

# 在 Fedora 中启用 ZFS 支持

## 安装

> **注意**
>
> 以下内容适用于在已有的 Fedora 系统上安装 ZFS。如需将 ZFS 用作根文件系统，请参阅《[构建以 ZFS 为根文件系统的 Fedora](https://book.bsdcn.org/zfs/an-zhuang-zhi-yin/fedora/fedora-root-on-zfs.md)》。

1. 如果已安装来自官方 Fedora 仓库的 `zfs-fuse`，请先卸载它。该软件包不再维护，任何情况下都不应使用：

   ```sh
   rpm -e --nodeps zfs-fuse
   ```
2. 添加 ZFS 仓库：

   ```sh
   dnf install -y https://zfsonlinux.org/fedora/zfs-release-3-0$(rpm --eval "%{dist}").noarch.rpm
   ```

   可在 [此处](https://github.com/zfsonlinux/zfsonlinux.github.com/tree/master/fedora) 查看旧版 zfs-release RPM 的列表。
3. 安装内核头文件：

   ```sh
   dnf install -y kernel-devel-$(uname -r | awk -F'-' '{print $1}')
   ```

   必须先安装软件包 `kernel-devel`，然后才能安装软件包 `zfs`。
4. 安装 ZFS 软件包：

   ```sh
   dnf install -y zfs
   ```
5. 加载内核模块：

   ```sh
   modprobe zfs
   ```

   如果无法加载内核模块，说明当前内核版本可能尚不被 OpenZFS 支持。一种做法是使用第三方提供的 COPR LTS 内核，风险自负：

   ```sh
   # 这是第三方仓库！
   # 你已经被警告过了。
   #
   # 可从以下地址选择内核：
   # https://copr.fedorainfracloud.org/coprs/kwizart/

   dnf copr enable -y kwizart/kernel-longterm-VERSION
   dnf install -y kernel-longterm kernel-longterm-devel
   ```

   重启至新的 LTS 内核，然后加载内核模块：

   ```sh
   modprobe zfs
   ```
6. 默认情况下，检测到存储池时 ZFS 内核模块会自动加载。若希望在启动时始终加载模块，可创建如下配置：

   ```sh
   echo zfs > /etc/modules-load.d/zfs.conf
   ```
7. 默认情况下，ZFS 可能会因内核软件包更新而被移除。若希望锁定内核版本、只使用 ZFS 支持的内核以防其被卸载，可执行：

   ```sh
   echo 'zfs' > /etc/dnf/protected.d/zfs.conf
   ```

   待处理的非内核更新仍可应用：

   ```sh
   dnf update --exclude=kernel*
   ```

## 最新仓库（Fedora 41+）

*zfs-latest* 仓库包含最新发布的、正在积极开发的 OpenZFS 版本。该仓库会包含最新功能，并被认为足够稳定，但相比 *zfs-legacy*，实际使用测试较少。该仓库相当于 Fedora 的默认 *zfs* 仓库。来自最新仓库的软件包可按如下方式安装。

对于 Fedora 41 及更新版本，运行：

```sh
sudo dnf config-manager setopt zfs*.enabled=0
sudo dnf config-manager setopt zfs-latest.enabled=1
sudo dnf install zfs
```

## 传统仓库（Fedora 41+）

*zfs-legacy* 仓库包含先前发布的、仍在积极更新的 OpenZFS 版本。通常，该仓库提供的软件包与基于 RHEL 和 CentOS 的发行版的主 *zfs* 仓库相同。来自传统仓库的软件包可按如下方式安装。

对于 Fedora 41 及更新版本，运行：

```sh
sudo dnf config-manager setopt zfs*.enabled=0
sudo dnf config-manager setopt zfs-legacy.enabled=1
sudo dnf install zfs
```

## 版本特定仓库（Fedora 41+）

版本特定仓库面向希望运行 ZFS 特定分支（例如 `2.3.x`）的用户。来自版本特定仓库的软件包可按如下方式安装。

对于 Fedora 41 及更新版本，启用 ZFS 分支 x.y 的版本特定仓库，运行：

```sh
sudo dnf config-manager setopt zfs*.enabled=0
sudo dnf config-manager setopt zfs-x.y.enabled=1
sudo dnf install zfs
```

## 测试仓库（已弃用）

*zfs-testing* 仓库已弃用，推荐使用 *zfs-latest*。


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://book.bsdcn.org/zfs/an-zhuang-zhi-yin/fedora/index.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
