x86/ARM架构下的Ubuntu系统换国内源

Ubuntu系统本身的源使用的是Ubuntu官方的源,下载速度比较慢,所以建议选择更换成国内的源。

1 source.list的构成

下面是一个X86 主机上 ubuntu18.04 的官方源,是由一个源镜像urlubuntu版本代号软件属性组成。最后的四个词条就是软件的属性。

deb http://archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ bionic main main restricted universe multiverse

deb http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse

deb http://archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse

deb http://archive.ubuntu.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ bionic-security main restricted universe multiverse
  • main:完全的自由软件。
  • restricted:不完全的自由软件。
  • universe:ubuntu官方不提供支持与补丁,全靠社区支持。
  • muitiverse:非自由软件,完全不提供支持和补丁。

源镜像url中 /ubuntu/ 收录的软件源是针对 X86 架构的。
查资料发现 ubuntu-ports 收录了arm64, armhf, PowerPC, ppc64el, s390x架构的软件源。在嵌入式ARM架构下,就需要将源镜像url中 /ubuntu/ 替换成 /ubuntu-ports/。最终的 source.list 如下

deb http://archive.ubuntu.com/ubuntu-ports/ bionic main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu-ports/ bionic main main restricted universe multiverse

deb http://archive.ubuntu.com/ubuntu-ports/ bionic-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu-ports/ bionic-updates main restricted universe multiverse

deb http://archive.ubuntu.com/ubuntu-ports/ bionic-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu-ports/ bionic-backports main restricted universe multiverse

deb http://archive.ubuntu.com/ubuntu-ports/ bionic-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu-ports/ bionic-security main restricted universe multiverse

2 更换并更新源

sudo mv /etc/apt/sources.list /etc/apt/sources.list-bk
sudo vi /etc/apt/sources.list
#将第一节提到的新内容写入
sudo apt-get update

3 其他

ubuntu的长期维护版本(LTS)的版本代号对照表

版本号Codename
20.04focal
18.04bionic
16.04xenial
14.04trusty
12.04precise

常用国内源镜像url

#中科大源
https://mirrors.ustc.edu.cn/*/

#阿里云源
http://mirrors.aliyun.com/*/

#清华源
https://mirrors.tuna.tsinghua.edu.cn/*/

#网易
http://mirrors.163.com/*/

提示:上述url中的*表示占位,请根据使用的架构选择(X86选择/ubuntu/,ARM等选/ubuntu-ports/)

4 复制可用

以下源我已经Nvidia Jetson系列arm开发板上验证可用。

# 默认注释了源码仓库,如有需要可自行取消注释
deb https://mirrors.ustc.edu.cn/ubuntu-ports/ bionic main restricted universe multiverse
# deb-src https://mirrors.ustc.edu.cn/ubuntu-ports/ bionic main main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-updates main restricted universe multiverse
# deb-src https://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-backports main restricted universe multiverse
# deb-src https://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-security main restricted universe multiverse
# deb-src https://mirrors.ustc.edu.cn/ubuntu-ports/ bionic-security main restricted universe multiverse
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页