注意

  • 本文使用的硬件是树莓派5
  • 要换两个源:Raspbian 软件仓库和Raspberrypi 软件仓库

1. Raspbian 软件仓库换源

查看系统架构等信息

uname -m
lsb_release -a

输出

xct@pi:~ $ uname -m
aarch64
xct@pi:~ $ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 12 (bookworm)
Release:        12
Codename:       bookworm

执行

sudo nano /etc/apt/sources.list

删除/etc/apt/sources.list中的原有内容,把下面内容粘贴进去

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware

# deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware

# deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware

# 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换
# deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware

之后:ctrl + o 回车保存 ctrl + x退出

2. Raspberrypi 软件仓库换源

执行

sudo nano /etc/apt/sources.list.d/raspi.list

删除/etc/apt/sources.list中的原有内容,把下面内容粘贴进去

deb https://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ bookworm main

3. 测试

执行

sudo apt update
sudo apt upgrade

观察到树莓派从修改后的镜像源(清华源)下载软件包,说明成功了。

参考

https://mirrors.tuna.tsinghua.edu.cn/help/raspbian/

https://mirrors.tuna.tsinghua.edu.cn/help/debian/

https://mirrors.tuna.tsinghua.edu.cn/help/raspberrypi/

更多推荐