树莓派Raspbian系统更换更新源
Raspbian简介
Raspbian 是专门用于 ARM 卡片式计算机 Raspberry Pi® “树莓派”的操作系统, 其基于 Debian 开发,针对 Raspberry Pi 硬件优化。
Raspbian 并非由树莓派的开发与维护机构 The Raspberry Pi Foundation “树莓派基金会” 官方支持。其维护者是一群 Raspberry Pi 硬件和 Debian 项目的爱好者。
系统架构与版本
架构:
- arm64
- armhf
版本:
- wheezy
- jessie
- stretch
- buster
注:Raspbian 系统由于从诞生开始就基于(为了armhf,也必须基于)当时还是 testing 版本的 7.0/wheezy,所以 Raspbian 不倾向于使用 stable/testing 表示版本。
更换更新源
-
执行以下命令查看树莓派版本
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
-
备份更新源文件
更新的源文件主要有
/etc/apt/sources.list
(软件更新源)和/etc/apt/sources.list.d/raspi.list
(系统更新源)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
-
根据自己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
-
修改完毕后,执行更新命令
sudo apt-get update
如果遇到以下问题
Hit:1 http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian bullseye InRelease Get:2 http://mirrors.tuna.tsinghua.edu.cn/raspbian/multiarch bullseye InRelease [3,912 B] Hit:3 http://mirrors.tuna.tsinghua.edu.cn/raspberrypi bullseye InRelease Err:2 http://mirrors.tuna.tsinghua.edu.cn/raspbian/multiarch bullseye InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY E77FC0EC3427 6B4B Reading package lists... Done W: GPG error: http://mirrors.tuna.tsinghua.edu.cn/raspbian/multiarch bullseye InRelease: The following signatur es couldn't be verified because the public key is not available: NO_PUBKEY E77FC0EC34276B4B E: The repository 'http://mirrors.tuna.tsinghua.edu.cn/raspbian/multiarch bullseye InRelease' is not signed. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details.
则执行以下命令,更换源之后添加公钥即可(公钥替换为错误信息中的公钥,如上面是E77FC0EC34276B4B)
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E77FC0EC34276B4B
然后再次执行
sudo apt-get update
既可