解決wsl2下ubuntu 20.04 LTS apt update很慢的問題

CentOS 一直是我主要用的Linux,  現在好了,要停止維護了。這也是醉了。

今天我試一下ubuntu,結果安裝完後,軟件安裝不了,也更新失敗。

主要的原因,ubuntu用的是默認不支持國內鏡象,結果是你只能失敗到放棄了。

現在的版本的win10,已經支持wsl2, 於是我在micrsoft store安裝了ubuntu 20.04 LTS,

然後在root下面,修改source.list

$>sudo su
#>cd /etc/apt
#>ll 
這個時候,就可以看到有一個sources.list文件
#>cp sources.list sources.list.bak  
先備份一個
然後複製到c:的temp目錄
#>cp sources.list /mnt/c/temp
在windows下面,用editplus打開編輯

內容如截圖:

deb-src http://archive.ubuntu.com/ubuntu hirsute main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ hirsute main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ hirsute main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ hirsute-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ hirsute-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ hirsute universe
deb http://mirrors.aliyun.com/ubuntu/ hirsute-updates universe
deb http://mirrors.aliyun.com/ubuntu/ hirsute multiverse
deb http://mirrors.aliyun.com/ubuntu/ hirsute-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ hirsute-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ hirsute-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu hirsute partner
deb-src http://archive.canonical.com/ubuntu hirsute partner
deb http://mirrors.aliyun.com/ubuntu/ hirsute-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ hirsute-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ hirsute-security universe
deb http://mirrors.aliyun.com/ubuntu/ hirsute-security multiverse

然後再複製回去,就可以apt update了

#>cp /mnt/c/temp/sources.list /etc/apt
#>apt update
就可以了

補充說明:

大家用瀏覽器訪問:http://mirrors.aliyun.com/ubuntu/  

可到如下目錄 ,再點一下dists

就會看到很多歷史版本的鏡像

我用的是hirsute,大家可以選擇自己的發佈:)

如果我們用focal這個,如下圖修改:

替換後,就可以了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章