Debian12更换国内镜像源

Debian12更换国内镜像源

前言

在 Debian 12 中,默认的 APT 源是 Debian 官方的服务器,但有时候由于网络问题或访问速度限制,选择国内或其他更适合的镜像源会大大提高系统更新和软件安装的效率。更改 APT 源能够帮助你更快地下载和安装软件包,特别是在一些区域或网络环境下,使用默认源可能会非常慢或不稳定。

在更换源之前,最好确保当前的系统已经完成了必要的软件更新,并且你有备份重要的配置文件或数据,以防万一。如果你正在使用一个较新的版本的 Debian(如 Debian 12),更换源后可能会涉及到一定的兼容性检查,但通常可以顺利过渡。

教程

备份源文件:更改 APT 源之前,首先备份现有的源列表文件 sources.list,以防万一出错可以恢复。

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

我们需要打开源文件:/etc/apt/sources.list ,你可以使用nano编辑或者ssh软件自带的文件管理功能修改文件。

将里面debdep-src全部注释,注意这个注释是在每行前面加#号,大概如下:

# deb http://mirrors.ustc.edu.cn/debian/ bookworm main non-free-firmware
# deb-src http://mirrors.ustc.edu.cn/debian/ bookworm main non-free-firmware

# deb http://security.debian.org/debian-security bookworm-security main non-free-firmware
# deb-src http://security.debian.org/debian-security bookworm-security main non-free-firmware

# bookworm-updates, to get updates before a point release is made;
# see https://www.debian.org/doc/manuals/debian-reference/ch02.en.html#_updates_and_backports
# deb http://mirrors.ustc.edu.cn/debian/ bookworm-updates main non-free-firmware
# deb-src http://mirrors.ustc.edu.cn/debian/ bookworm-updates main non-free-firmware

然后我们插入需要更换的源,我比较喜欢中科大的源,这里贴一下:

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

粘贴到sources.list文件内后保存,然后调用命令:sudo apt update 重新拉一下索引文件。

然后就可以使用sudo apt-get upgrade更新依赖了。

其他源

腾讯源

deb https://mirrors.tencent.com/debian/ bookworm main non-free non-free-firmware contrib
deb-src https://mirrors.tencent.com/debian/ bookworm main non-free non-free-firmware contrib
deb https://mirrors.tencent.com/debian-security/ bookworm-security main
deb-src https://mirrors.tencent.com/debian-security/ bookworm-security main
deb https://mirrors.tencent.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb-src https://mirrors.tencent.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb https://mirrors.tencent.com/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src https://mirrors.tencent.com/debian/ bookworm-backports main non-free non-free-firmware contrib

阿里源

deb https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib
deb https://mirrors.aliyun.com/debian-security/ bookworm-security main
deb-src https://mirrors.aliyun.com/debian-security/ bookworm-security main
deb https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib

网易源

deb https://mirrors.163.com/debian/ bookworm main non-free non-free-firmware contrib
deb-src https://mirrors.163.com/debian/ bookworm main non-free non-free-firmware contrib
deb https://mirrors.163.com/debian-security/ bookworm-security main
deb-src https://mirrors.163.com/debian-security/ bookworm-security main
deb https://mirrors.163.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb-src https://mirrors.163.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb https://mirrors.163.com/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src https://mirrors.163.com/debian/ bookworm-backports main non-free non-free-firmware contrib

注意事项

    • 选择镜像源时要确保源的稳定性和安全性。

    • 如果是从官方源切换到国内源,可能会有些延迟,建议选择你所在地区的镜像源。

    • 更改源时,确保 debdeb-src 部分配置正确,避免出现源不匹配的情况。

© 版权声明
THE END
喜欢就支持一下吧
点赞5 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容