1. 执行以下命令查看树莓派版本
pi@raspberrypi:~ $ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 10.6 (buster)
Release: 10.6
Codename: buster
如上,可以查出版本为buster
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
更新的源文件主要有/etc/apt/sources.list
(软件更新源)和/etc/apt/sources.list.d/raspi.list
(系统更新源)
3. 根据自己 Raspbian 的版本来更改以下内容(下面使用的更新源为清华源)
Debian 9 (stretch)
# 编辑 `/etc/apt/sources.list` 文件,删除原文件所有内容,用以下内容取代:
deb [arch=armhf] http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main non-free contrib rpi
deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main non-free contrib rpi
# 如果需要 arm64 软件源,在 `/etc/apt/sources.list` 中加上
deb [arch=arm64] http://mirrors.tuna.tsinghua.edu.cn/raspbian/multiarch/ stretch main
# 编辑 `/etc/apt/sources.list.d/raspi.list` 文件,删除原文件所有内容,用以下内容取代:
deb http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ stretch main
Debian 10 (buster)
# 编辑 `/etc/apt/sources.list` 文件,删除原文件所有内容,用以下内容取代:
deb [arch=armhf] http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main non-free contrib rpi
deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main non-free contrib rpi
# 如果需要 arm64 软件源,在 `/etc/apt/sources.list` 中加上
deb [arch=arm64] http://mirrors.tuna.tsinghua.edu.cn/raspbian/multiarch/ buster main
# 编辑 `/etc/apt/sources.list.d/raspi.list` 文件,删除原文件所有内容,用以下内容取代:
deb http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ buster main
Debian 11(bullseye)
# 编辑 `/etc/apt/sources.list` 文件,删除原文件所有内容,用以下内容取代:
deb [arch=armhf] http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ bullseye main non-free contrib rpi
deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ bullseye main non-free contrib rpi
# 如果需要 arm64 软件源,在 `/etc/apt/sources.list` 中加上
deb [arch=arm64] http://mirrors.tuna.tsinghua.edu.cn/raspbian/multiarch/ bullseye main
# 编辑 `/etc/apt/sources.list.d/raspi.list` 文件,删除原文件所有内容,用以下内容取代:
deb http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ bullseye main
4. 修改完毕后,执行更新命令
sudo apt update
sudo apt upgrade
异常
如果apt update出现错误:
The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY xxxxxxxxxxxxxxxxxxx
使用以下命令添加KEY:
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com xxxxxxxxxxxxxxxxxxx
参考链接:
https://www.cnblogs.com/blueberry-mint/p/16060251.html
https://www.quarkbook.com/?p=636