# Debian 软件源

原文：https://mirrors.zju.edu.cn/docs/debian/
内容语言：zh（中文）
导出选项：默认选项；可在原文页面调整选项后复制全文

- 镜像地址：`https://mirrors.zju.edu.cn/debian`
- sudo：开启

> 本站收录所有共享帮助文档；文档存在不代表浙江大学镜像站当前提供该镜像。请查阅 https://mirrors.zju.edu.cn/mirrorz.json 确认当前目录与状态。
> 下列命令使用上述选项，请根据实际系统版本选择；未填写的文本选项需要在原文页面补充。

大部分 Debian 的软件源配置文件使用传统的 One-Line-Style，路径为 `/etc/apt/sources.list`；但是对于容器镜像，从 Debian 12 开始，其软件源配置文件变更为 DEB822 格式，路径为 `/etc/apt/sources.list.d/debian.sources`。一般情况下，将对应文件中 Debian 默认的源地址 `http://deb.debian.org/` 替换为镜像地址即可。

Debian 10（Buster）及以上版本默认支持 HTTPS 源。如果遇到无法拉取 HTTPS 源的情况，请先使用 HTTP 源并安装通用 CA 证书：

```bash
sudo apt install ca-certificates
```


## 使用方法

### 传统格式（`/etc/apt/sources.list`）

此处选项：
- Debian 版本 (release): `Debian 13 (trixie)`
- 启用源码源 (src): `关闭`
- 使用非自由软件源 (nf): `开启`
- 强制安全更新使用镜像 (mirror_security): `关闭`

写入 `/etc/apt/sources.list`：

```properties
# 默认注释了源码镜像以提高 apt update 速度，如有需要可自行取消注释
deb https://mirrors.zju.edu.cn/debian/ trixie main contrib non-free non-free-firmware
# deb-src https://mirrors.zju.edu.cn/debian/ trixie main contrib non-free non-free-firmware

deb https://mirrors.zju.edu.cn/debian/ trixie-updates main contrib non-free non-free-firmware
# deb-src https://mirrors.zju.edu.cn/debian/ trixie-updates main contrib non-free non-free-firmware

deb https://mirrors.zju.edu.cn/debian/ trixie-backports main contrib non-free non-free-firmware
# deb-src https://mirrors.zju.edu.cn/debian/ trixie-backports main contrib non-free non-free-firmware

# 以下安全更新软件源为官方源配置
deb https://security.debian.org/debian-security trixie-security main contrib non-free non-free-firmware
# deb-src https://security.debian.org/debian-security trixie-security main contrib non-free non-free-firmware

```

### DEB822 格式（`/etc/apt/sources.list.d/debian.sources`）

此处选项：
- Debian 版本 (release_deb822): `Debian 13 (trixie)`
- 启用源码源 (src): `关闭`
- 使用非自由软件源 (nf): `开启`
- 强制安全更新使用镜像 (mirror_security): `关闭`

写入 `/etc/apt/sources.list.d/debian.sources`：

```yaml
Types: deb
URIs: https://mirrors.zju.edu.cn/debian
Suites: trixie trixie-updates trixie-backports
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

# 默认注释了源码镜像以提高 apt update 速度，如有需要可自行取消注释
# Types: deb-src
# URIs: https://mirrors.zju.edu.cn/debian
# Suites: trixie trixie-updates trixie-backports
# Components: main contrib non-free non-free-firmware
# Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

# 以下安全更新软件源为官方源配置
Types: deb
URIs: https://security.debian.org/debian-security
Suites: trixie-security
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

# Types: deb-src
# URIs: https://security.debian.org/debian-security
# Suites: trixie-security
# Components: main contrib non-free non-free-firmware
# Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

```

为了方便快速配置，此处一并附上了 debian-security 的配置，一般来说，镜像站会同时提供 debian-security，为了更准确的信息您可以前往 [Debian Security 帮助](<https://mirrors.zju.edu.cn/docs/debian-security/>) 确认。

不过，一般来说，为了更及时地获得安全更新，不推荐使用镜像站安全更新软件源，因为镜像站往往有同步延迟。参考 [https://www.debian.org/security/faq.en.html#mirror](<https://www.debian.org/security/faq.en.html#mirror>)

> The purpose of security.debian.org is to make security updates available as quickly and easily as possible.
>
> Encouraging the use of unofficial mirrors would add extra complexity that is usually not needed and that can cause frustration if these mirrors are not kept up to date.


## OpenMediaVault

本节供 [OpenMediaVault 帮助](<https://mirrors.zju.edu.cn/docs/OpenMediaVault/>)使用。

```bash
omv-env set OMV_APT_KERNEL_BACKPORTS_REPOSITORY_URL "https://mirrors.zju.edu.cn/debian"
omv-env set OMV_APT_SECURITY_REPOSITORY_URL "https://mirrors.zju.edu.cn/debian-security"
```

关于 debian-security 可以参考上文的说明。


## Connection reset by peer

在 apt 2.1.9 及以后的版本中，apt 的 HTTP Pipelining 特性与 Nginx 服务器疑似存在一定的不兼容问题，可能导致高带宽从镜像站下载大量软件包
（例如系统升级）时出现偶发的 Connection reset by peer 错误
（详见 [Debian bug #973581](<https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=973581>)）。

目前，用户可以通过关闭 HTTP Pipelining 特性解决此问题。
如果需要关闭，可以在使用 `apt` 命令时加上 `-o Acquire::http::Pipeline-Depth=0` 参数，
或使用以下命令将相关设置加入 apt 系统配置中：

```bash
echo "Acquire::http::Pipeline-Depth \"0\";" > /etc/apt/apt.conf.d/99nopipelining
```

---

来源：[ZJUSCT/mirrorz-docs](https://github.com/ZJUSCT/mirrorz-docs/tree/de87bf043f31d45ef3a951cc6dc11ddb8c85b4f6/debian)
源提交：de87bf043f31d45ef3a951cc6dc11ddb8c85b4f6
许可：[CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/)
文档索引：https://mirrors.zju.edu.cn/llms.txt
