# 在 Debian 中启用 ZFS 支持

## 安装

如果你想将 ZFS 用作根文件系统，请参阅[基于 ZFS 的根文件系统](https://openzfs.github.io/openzfs-docs/Getting%20Started/Debian/index.html#root-on-zfs)。

在 [contrib 仓库](https://packages.debian.org/source/zfs-linux) 中提供了对 ZFS 的支持。[backports 仓库](https://backports.debian.org/Instructions/) 通常提供了更新版本的 ZFS。你可以按如下方式使用。

添加 backports 仓库：

```sh
vi /etc/apt/sources.list.d/trixie-backports.list
```

```ini
deb http://deb.debian.org/debian trixie-backports main contrib non-free-firmware
deb-src http://deb.debian.org/debian trixie-backports main contrib non-free-firmware
```

```sh
vi /etc/apt/preferences.d/90_zfs
```

```ini
Package: src:zfs-linux
Pin: release n=trixie-backports
Pin-Priority: 990
```

安装软件包：

```sh
apt update
apt install dpkg-dev linux-headers-generic linux-image-generic
apt install zfs-dkms zfsutils-linux
```

> **注意**：
>
> 如果你处于配置不良的环境中（例如某些虚拟机或容器控制台），当 apt 在首次安装时会尝试弹出提示信息，可能无法识别实际控制台不可用，从而表现为无限期停滞。为避免这种情况发生，你可以在命令 `apt install` 前加上 `DEBIAN_FRONTEND=noninteractive`，形如：
>
> ```sh
> DEBIAN_FRONTEND=noninteractive apt install zfs-dkms zfsutils-linux
> ```


---

# Agent Instructions: 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:

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

The question should be specific, self-contained, and written in natural language.
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.
