Skip to content

树莓派换源

约 454 字大约 2 分钟

Raspberry Pi树莓派

2025-03-02

1. 查看系统架构

首先使用uname -a确定你使用的系统的架构。

2. 查看系统版本

查看你的Raspbian对应的Debian版本版本stretchbusterbullseyebookworm,每个版本的源又分为32位和64位,需要根据自己树莓派的实际情况进行换源操作。 在树莓派终端输入:

lsb_release -a #查看系统版本类型
getconf LONG_BIT #查看树莓派系统多少位 32/64
cat /etc/os-release #查看系统版本

2. 更换软件更新源

sudo nano /etc/apt/sources.list

armv7l(32位系统)

deb https://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ bullseye main non-free contrib rpi
# deb-src https://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ bullseye main non-free contrib rpi

# deb [arch=arm64] https://mirrors.tuna.tsinghua.edu.cn/raspbian/multiarch/ bullseye main

注意

其中bullseye改为自己系统对应的版本。 https://mirrors.tuna.tsinghua.edu.cn/help/raspbian/

aarch64(64位系统)

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://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
# deb-src https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware

注意

其中bookworm改为自己系统对应的版本。 https://mirrors.tuna.tsinghua.edu.cn/help/debian/

3. 更换系统更新源(一般不更换)

对于两个架构,编辑/etc/apt/sources.list.d/raspi.list文件

sudo nano /etc/apt/sources.list.d/raspi.list
deb https://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ bookworm main

注意

其中bookworm改为自己系统对应的版本。 https://mirrors.tuna.tsinghua.edu.cn/help/raspberrypi/

4. 更新源

更新最新的软件包列表

sudo apt-get update

根据更新后的软件包列表,将系统上已安装的软件包升级到最新版

sudo apt-get upgrade