Debian 12 更换国内/本地镜像

Debian 12 更换国内/本地镜像

最近在折腾飞牛 NASCasaOS 系统,这两个系统底层都是 Debian 12 系统,为了更好的软件安装/更新速度,需要更改为国内的镜像站。

以前一直用清华大学或者中科大的镜像站,但这次在查询资料的时候发现了一个校园网联合镜像站 MirrorZ ,MirrorZ 提供对校园网镜像站的索引和跳转服务,配置好了之后可以根据你的线路(电信/联通/移动)和地理位置自动切换到速度最快的校园网镜像。

MirrorZ 支持各主流 Linux 发行版,比如 Debian, Ubuntu, Arch, Fedora 等等,以下是 Debian 12 使用 MirrorZ 镜像的方法:

最新的 Debian 12 把软件源的配置调整为了 DEB822 格式。不仅配置代码风格大改,文件位置也有了变化。之前软件源的文件位置是 /etc/apt/sources.list,现在是 /etc/apt/sources.list.d/debian.sources ,修改这个文件的内容如下:

Types: deb
URIs: https://mirrors.cernet.edu.cn/debian
Suites: bookworm bookworm-updates bookworm-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.cernet.edu.cn/debian
# Suites: bookworm bookworm-updates bookworm-backports
# Components: main contrib non-free non-free-firmware
# Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

# 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换
Types: deb
URIs: https://mirrors.cernet.edu.cn/debian-security
Suites: bookworm-security
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

# Types: deb-src
# URIs: https://mirrors.cernet.edu.cn/debian-security
# Suites: bookworm-security
# Components: main contrib non-free non-free-firmware
# Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

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

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

当然啦,你也可以修改 Debian 默认的软件源配置文件 /etc/apt/sources.list ,从 Debian12 开始,对于容器镜像,其软件源配置文件变更为 DEB822 格式。Debian 12 还在默认使用传统的One-Line-Style 的软件源配置文件即 /etc/apt/sources.list ,但是像 Ubuntu 24.04 已经默认把这个文件删除了,不管是软件源还是容器镜像全部使用 DEB822 格式,所以我还是建议切换到 DEB822 ,反正我已经这么干了。

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *