入门

Debian 换源教程(镜像源配置)

Debian 13 换源教程:deb822 新格式与传统 sources.list 写法、清华/中科大/阿里云镜像源对照、安全源配置与常见错误。

国内访问 deb.debian.org 速度不稳定,装完系统把软件源换成就近镜像,apt update 能快一个数量级。Debian 13 使用 deb822 格式(安装器默认写入 /etc/apt/sources.list.d/debian.sources),旧的每行一条式写法(/etc/apt/sources.list)也继续可用——两种写法二选一,不要混用。

常用国内镜像

镜像站地址
清华 TUNAhttps://mirrors.tuna.tsinghua.edu.cn/debian/
中科大 USTChttps://mirrors.ustc.edu.cn/debian/
阿里云https://mirrors.aliyun.com/debian/
腾讯云https://mirrors.cloud.tencent.com/debian/
网易https://mirrors.163.com/debian/

不确定选哪个时,用我们的镜像源选择器按所在地自动生成配置。

安全源不要忘

很多人只换了主仓库,漏掉 trixie-security,导致安全更新走官方慢速源甚至缺失。换源时务必同时替换下文示例中的 -security 一行。

方式一:deb822 格式(Debian 13 默认)

编辑 /etc/apt/sources.list.d/debian.sources(以清华源为例):

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

注意:Suites 里要同时包含 trixie、trixie-updates 和 trixie-security(安全更新走镜像站的 debian-security 路径,见下方传统格式示例中的独立写法——部分镜像站将安全源托管在同一域名下,直接合并即可)。

方式二:传统 sources.list 格式

编辑 /etc/apt/sources.list,替换为(以中科大为例):

deb https://mirrors.ustc.edu.cn/debian/ trixie main contrib non-free non-free-firmware
deb https://mirrors.ustc.edu.cn/debian/ trixie-updates main contrib non-free non-free-firmware
deb https://mirrors.ustc.edu.cn/debian/ trixie-security main contrib non-free non-free-firmware

如果系统里同时存在 /etc/apt/sources.list 和 /etc/apt/sources.list.d/debian.sources,把不用的那个改名备份(如加 .bak 后缀),否则同一批包会出现双份来源。

生效与验证

sudo apt update
apt policy firefox-esr | head -5

apt update 无报错、apt policy 显示的候选版本来自镜像站地址,即换源成功。 upgrades 出现 404 时优先检查 Suites 拼写和镜像站是否同步完成。

常见问题

问题原因与处理
404 Not Found镜像站尚未同步完成,或 Suites 写错(trixie 而不是 bookworm)
GPG 签名错误Signed-By 路径写错;Debian 13 的钥匙环在 /usr/share/keyrings/debian-archive-keyring.gpg
换源后 update 反而变慢与 DNS 有关,优先用 HTTPS 直连镜像站而非 HTTP 代理
需要非自由软件Components 里保留 contrib non-free non-free-firmware

下一步

On this page