关于如何为树莓派启用root系统并开启ssh登录,可参考之前的文章。
- 为什么要使用国内镜像源?
树莓派官方raspbian系统默认设置软件源为
http://raspbian.raspberrypi.org/raspbian/和http://archive.raspberrypi.org/debian/,这两个网站在国内通常连接缓慢,影响使用体验。 - 如何更换国内源?
raspbian系统的apt软件源由/etc/apt/sources.list和/etc/apt/sources.list.d/raspi.list两个文件设定,只需更改两个文件内的记录即可。 - 国内源那么多,该选哪一个呢?
国内支持raspbian的软件源(不完全统计,欢迎补充):
https://mirrors.cloud.tencent.com/raspbian/raspbian/
https://mirrors.cloud.tencent.com/raspberrypi/https://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/
https://mirrors.tuna.tsinghua.edu.cn/raspberrypi/https://mirrors.sjtug.sjtu.edu.cn/raspbian/raspbian/
https://mirrors.sjtug.sjtu.edu.cn/raspberrypi/debian/https://mirrors.ustc.edu.cn/raspbian/raspbian/
https://mirrors.ustc.edu.cn/archive.raspberrypi.org/debian/
- 阿里云OPSX镜像站[缺]
https://mirrors.aliyun.com/raspbian/raspbian/
- 浙江大学开源标准化站[缺]
http://mirrors.zju.edu.cn/raspbian/raspbian/
http://mirrors.neusoft.edu.cn/raspbian/raspbian/
- 重庆大学开源软件镜像站[缺]
https://mirrors.cqu.edu.cn/raspbian/raspbian/
- 为避免误更换为无效的源,先对配置文件在同目录进行备份:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.save
sudo cp /etc/apt/sources.list.d/raspi.list /etc/apt/sources.list.d/raspi.list.save
- 如需还原应执行:
sudo cp /etc/apt/sources.list.save /etc/apt/sources.list
sudo cp /etc/apt/sources.list.d/raspi.list.save /etc/apt/sources.list.d/raspi.list
- 下面即可通过sed命令修改配置文件
sudo sed -i "s?http://raspbian.raspberrypi.org/raspbian/?https://mirrors.sjtug.sjtu.edu.cn/raspbian/raspbian/?g" /etc/apt/sources.list
sudo sed -i "s?http://archive.raspberrypi.org/debian/?https://mirrors.sjtug.sjtu.edu.cn/raspberrypi/debian/?g" /etc/apt/sources.list.d/raspi.list
sudo sed -i "s?http://raspbian.raspberrypi.org/raspbian/?https://mirrors.cloud.tencent.com/raspbian/raspbian/?g" /etc/apt/sources.list
sudo sed -i "s?http://archive.raspberrypi.org/debian/?https://mirrors.cloud.tencent.com/raspberrypi/?g" /etc/apt/sources.list.d/raspi.list
sudo sed -i "s?http://raspbian.raspberrypi.org/raspbian/?https://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/?g" /etc/apt/sources.list
sudo sed -i "s?http://archive.raspberrypi.org/debian/?https://mirrors.tuna.tsinghua.edu.cn/raspberrypi/?g" /etc/apt/sources.list.d/raspi.list
sudo sed -i "s?http://raspbian.raspberrypi.org/raspbian/?https://mirrors.ustc.edu.cn/raspbian/raspbian/?g" /etc/apt/sources.list
sudo sed -i "s?http://archive.raspberrypi.org/debian/?https://mirrors.ustc.edu.cn/archive.raspberrypi.org/debian/?g" /etc/apt/sources.list.d/raspi.list
其他为提供raspberrypi存储库的源未写成一键脚本。
- 修改完成后即可使用apt进行软件包升级
sudo apt update
sudo apt upgrade