debian9 apt 镜像源问题

由于debian9在22年官方停服,所以sources.list需要改成带archive的路径,如下:

deb http://archive.debian.org/debian/ stretch main non-free contrib
deb-src http://archive.debian.org/debian/ stretch main non-free contrib
deb http://archive.debian.org/debian-security/ stretch/updates main non-free contrib
deb-src http://archive.debian.org/debian-security/ stretch/updates main non-free contrib
deb http://archive.debian.org/debian/ stretch-backports main non-free contrib
deb-src http://archive.debian.org/debian/ stretch-backports main non-free contrib


 

相应的阿里云镜像也要跟上archive的,如下:

deb http://mirrors.aliyun.com/debian-archive/debian stretch main contrib non-free
deb http://mirrors.aliyun.com/debian-archive/debian stretch-proposed-updates main non-free contrib
deb http://mirrors.aliyun.com/debian-archive/debian stretch-backports main non-free contrib
deb http://mirrors.aliyun.com/debian-archive/debian-security stretch/updates main contrib non-free
deb-src http://mirrors.aliyun.com/debian-archive/debian stretch main contrib non-free
deb-src http://mirrors.aliyun.com/debian-archive/debian stretch-proposed-updates main contrib non-free
deb-src http://mirrors.aliyun.com/debian-archive/debian stretch-backports main contrib non-free
deb-src http://mirrors.aliyun.com/debian-archive/debian-security stretch/updates main contrib non-free

一、选择Archive源

目前Debian archive官方源及国内镜像主要有以下几个,按照推荐的顺序自上而下排列。翻看了一圈国内的镜像站发现archive非商业源很少,商业源中阿里云较为稳定但目前对外限速非常严重,不推荐使用。

官方(海外):http://archive.debian.org/
腾讯云:http://mirrors.cloud.tencent.com/debian-archive/
南京大学:https://mirror.nju.edu.cn/debian-archive/
软件所:https://mirror.iscas.ac.cn/debian-archive/
网易163:http://mirrors.163.com/debian-archive/
阿里云:http://mirrors.aliyun.com/debian-archive/


二、配置镜像源

Debian的镜像源主要分为主线updatesbackports三项。既然已经是过了支持期的老旧系统,updates条目博主觉得不是必要的内容了,要更新还是建议更新到在支持期内的新系统。backports源中的内容是将新版本的某些功能移植到旧版本软件上,如果你不知道它的作用也不必添加。所以一般情况下仅配置主源就够了,再按照需求决定是否添加backports源。

参考自:Debian 9/10 EOL如何切换源?_云服务器 ECS(ECS)-阿里云帮助中心

这里的源地址还分vpc网络和经典网络,非阿里云主机,应该使用经典网络就可以

### 更换 Debian APT 包管理器使用的镜像源 为了提升软件包的下载速度,可以将 Debian 的默认镜像源替换为中国境内的镜像站点。以下是具体操作方法: #### 备份原始 `sources.list` 文件 建议先备份现有的 `/etc/apt/sources.list` 文件以防出现问题时能够快速恢复。 ```bash cp /etc/apt/sources.list /etc/apt/sources.list.backup ``` #### 编辑 `sources.list` 文件 使用喜欢的文本编辑工具打开该文件并进行修改。这里以阿里云为例展示如何更改配置: ```plaintext deb http://mirrors.aliyun.com/debian/ bullseye main non-free contrib deb-src http://mirrors.aliyun.com/debian/ bullseye main non-free contrib deb http://mirrors.aliyun.com/debian-security bullseye/updates main contrib non-free deb-src http://mirrors.aliyun.com/debian-security bullseye/updates main contrib non-free deb http://mirrors.aliyun.com/debian bullseye-updates main contrib non-free deb-src http://mirrors.aliyun.com/debian bullseye-updates main contrib non-free ``` 也可以选择其他国内镜像服务器,如华为云提供的服务[^2]。 对于希望自动化这一过程的情况,可以通过命令行直接替换 URL 地址来实现: ```bash sed -i 's@http://deb.debian.org@http://mirrors.huaweicloud.com@g' /etc/apt/sources.list ``` 完成上述任一方式的操作后,请记得更新本地索引以便应用最新的变更: ```bash apt update ``` 如果遇到任何问题或不确定的地方,随时可以从之前创建的备份中恢复原状。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值