树莓派4B(buster)的源更换为北外(清华)国内源
1. 登陆到树莓派
ssh pi@your_raspi_IP
2. 备份源文件
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo cp /etc/apt/sources.list.d/raspi.list /etc/apt/sources.list.d/raspi.list.bak
3. 修改软件更新源
将官方源改为国内镜像源, 清华源和北外源都比较快。下面将改为北外源:
3.1 打开 /etc/apt/sources.list 文件
sudo vi /etc/apt/sources.list
3.2 修改内容,将网址改为北外的镜像 mirrors.bfsu.edu.cn/raspbian/raspbian/:
#deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi
deb https://mirrors.bfsu.edu.cn/raspbian/raspbian/ buster main contrib non-free rpi
deb-src https://mirrors.bfsu.edu.cn/raspbian/raspbian/ buster main contrib non-free rpi
4. 修改系统更新源
4.1 打开 /etc/apt/sources.list.d/raspi.list 文件
sudo vi /etc/apt/sources.list.d/raspi.list
4.2 修改内容,将原镜像用#号注释掉,将网址改为北外的镜像 mirrors.bfsu.edu.cn/raspbian/raspbian/ :
#deb http://archive.raspberrypi.org/debian/ buster main
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://archive.raspberrypi.org/debian/ buster main
deb https://mirrors.bfsu.edu.cn/raspberrypi/ buster main ui
5. 同步更新源及更新软件包
sudo apt-get update
sudo apt-get upgrade
总结
一定要注意版本,目前最新版树莓派是buster;北外的系统源和软件包的目录不同,最好进镜像站看一下。