編碼的世界 / 優質文選 / 女人

在舊版本Ubuntu系統中使用“apt-get update”出現“404 Not Found”錯誤的解決辦法


2021年7月05日
-   

每一個Ubuntu發布版本都有它的結束時間,通常,Ubuntu發布版本支持18個月,而LTS (Long Term Support)(長期支持)版本分別支持3年(服務器版)和5年(桌面版)。當一個Ubuntu發布版本到達結束期後,它的庫將不再能夠訪問,並且你也不會得到任何維護更新和安全補丁。當寫這個的時候,13.04版本已經到底了它的結束期。
如果你使用的是Ubuntu系統到達結束期了,你使用 apt-get or aptitude更新庫時會得到以下錯誤提示:
W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/raring-backports/multiverse/binary-i386/Packages 404 Not Found [IP: 91.189.91.13 80]
W: Failed to fetch http://extras.ubuntu.com/ubuntu/dists/raring/main/binary-amd64/Packages 404 Not Found
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/raring-security/universe/binary-i386/Packages 404 Not Found [IP: 91.189.88.149 80]
E: Some index files failed to download. They have been ignored, or old ones used instead

對於那些使用舊版本的Ubuntu的用戶,Canonical會維護 old-releases.ubuntu.com ,這是一個過期庫的歸檔。因此,當Canonical支持的Ubuntu過期後,你必須把源切換到 old-releases.ubuntu.com(除非你想在過期前進行升級)。
下面的方法通過切換到舊版本的源來解決“404 Not Found”錯誤。
首先,使用舊版本的源來替換當前主源:
$ sudo sed -i -r 's/([a-z]{2}.)?archive.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list
$ sudo sed -i -r 's/security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list
然後使用文本編輯器打開 /etc/apt/sources.list ,找到 extras.ubuntu.com,這個庫也不再支持13.04。所以你需要使用 “#” 號注釋掉 extras.ubuntu.com。
#deb http://extras.ubuntu.com/ubuntu raring main
#deb-src http://extras.ubuntu.com/ubuntu raring main

現在,你應該能夠在舊版本的Ubuntu系統上進行安裝或者更新了。

熱門文章