This shared guide is currently available only in Chinese. Use the controls below to select the mirror endpoint and command options.
大部分 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 证书。
可以通过以下命令查看 当前系统版本:
cat /etc/os-release
例如在 Debian 13 下,文件内容包含:
...
VERSION_ID="13"
VERSION_CODENAME=trixie
...
VERSION_ID 后面的是版本号,VERSION_CODENAME 后面的是代号。代号会用于软件源配置。请在下面选择符合机器实际情况的版本,并在替换配置前确认代号一致,否则后续更新可能导致系统出现问题。
配置内容
将系统自带的软件源配置文件做个备份,再根据 Debian 版本和所需选项生成配置并替换文件内容。Debian 12 及以上版本可以使用 DEB822 格式;Debian 11 使用传统格式。
将系统自带配置文件备份后,把以下内容写入 /etc/apt/sources.list.d/debian.sources:
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
# 以下安全更新软件源为官方源配置
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
如果系统由旧版本升级而来,请同时检查并备份旧的 /etc/apt/sources.list,避免两套配置重复生效。也可以使用 apt modernize-sources 转换现有配置。
为了方便快速配置,此处一并附上了 debian-security 的配置。镜像站通常也会提供 debian-security,具体情况可以前往 Debian Security 帮助确认。
一般来说,为了更及时地获得安全更新,不推荐使用镜像站安全更新软件源,因为镜像站往往有同步延迟。请参阅 Debian Security FAQ。
OpenMediaVault
本节供 OpenMediaVault 帮助使用。
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)。
目前,用户可以通过关闭 HTTP Pipelining 特性解决此问题。如果需要关闭,可以在使用 apt 命令时加上 -o Acquire::http::Pipeline-Depth=0 参数,或使用以下命令将相关设置加入 apt 系统配置中:
echo "Acquire::http::Pipeline-Depth \"0\";" > /etc/apt/apt.conf.d/99nopipelining
Guide content comes from mirrorz-org/mirrorz-docs@50cb65f78be4 under CC BY-NC-SA 4.0. This site provides an interactive page.