前言
树莓派官方raspbian系统默认设置软件源为
http://raspbian.raspberrypi.org/raspbian/
和
http://archive.raspberrypi.org/debian/
,这两个网站在国内通常连接缓慢,影响使用体验。
如何更换国内源?
raspbian系统的apt软件源由 /etc/apt/sources.list
和 /etc/apt/sources.list.d/raspi.list
两个文件设定,只需更改两个文件内的记录即可。
国内支持raspbian的软件源
腾讯软件源
https://mirrors.cloud.tencent.com/raspbian/raspbian/
https://mirrors.cloud.tencent.com/raspberrypi/
清华大学开源软件镜像站TUNA
https://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/
https://mirrors.tuna.tsinghua.edu.cn/raspberrypi/
上海交通大学SJTUG软件源
https://mirrors.sjtug.sjtu.edu.cn/raspbian/raspbian/
https://mirrors.sjtug.sjtu.edu.cn/raspberrypi/debian/
中国科学技术大学开源软件镜像
https://mirrors.ustc.edu.cn/raspbian/raspbian/
https://mirrors.ustc.edu.cn/archive.raspberrypi.org/debian/
更换操作
为避免误更换为无效的源,先对配置文件在同目录进行备份:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.save
sudo cp /etc/apt/sources.list.d/raspi.list /etc/apt/sources.list.d/raspi.list.save
如果需要还原
sudo cp /etc/apt/sources.list.save /etc/apt/sources.list
sudo cp /etc/apt/sources.list.d/raspi.list.save /etc/apt/sources.list.d/raspi.list
腾讯软件源
sudo sed -i "s?http://raspbian.raspberrypi.org/raspbian/?https://mirrors.cloud.tencent.com/raspbian/raspbian/?g" /etc/apt/sources.list
sudo sed -i "s?http://archive.raspberrypi.org/debian/?https://mirrors.cloud.tencent.com/raspberrypi/?g" /etc/apt/sources.list.d/raspi.list
清华大学开源软件镜像站TUNA
sudo sed -i "s?http://raspbian.raspberrypi.org/raspbian/?https://mirrors.ustc.edu.cn/raspbian/raspbian/?g" /etc/apt/sources.list
sudo sed -i "s?http://archive.raspberrypi.org/debian/?https://mirrors.ustc.edu.cn/archive.raspberrypi.org/debian/?g" /etc/apt/sources.list.d/raspi.list
修改完成后即可使用apt进行软件包升级
sudo apt update
sudo apt upgrade