天天看點

x86/ARM架構下的Ubuntu系統換國内源1 source.list的構成2 更換并更新源3 其他4 複制可用

Ubuntu系統本身的源使用的是Ubuntu官方的源,下載下傳速度比較慢,是以建議選擇更換成國内的源。

1 source.list的構成

下面是一個X86 主機上 ubuntu18.04 的官方源,是由一個源鏡像url、ubuntu版本代号、軟體屬性組成。最後的四個詞條就是軟體的屬性。

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.04 focal
18.04 bionic
16.04 xenial
14.04 trusty
12.04 precise

常用國内源鏡像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