2009年4月30日 星期四

Ubuntu 學習筆記:使用 apt-p2p 來更新系統

APT 是一套 Debian 所發展出來的套件管理系統,Ubuntu Linux 也使用它來處理程式跟系統上的安裝、更新的工作。平常我們在 Ubuntu 上執行更新管理員或 Synaptic 套件管理程式,背後就是透過 APT 在努力工作。

apt-p2p 能透過 p2p 的原理,從其他 apt-p2p 的使用者(peers)那邊取得需要的套件,有效減輕 Ubuntu 更新伺服器的負擔,理論上也會更快。如果沒有其他人有你需要的套件,apt-p2p 會自動回到原本的套件來源處下載。

因為學校的網路近來連接國外的速度頗慢,導致每次 Ubuntu 系統更新都要花上個幾十分鐘、甚至幾小時,因此今天來嘗試看看使用 apt-p2p 更新

參考原文:Using apt-p2p For Faster Upgrades From Intrepid to Jaunty | blog.chenhow.net

1. 首先先安裝 apt-p2p

sudo apt-get install apt-p2p

2. 接著先備份軟體來源設定檔(source.list)

sudo cp /etc/apt/sources.list /etc/apt/sources.list-apt-p2p-backup

3. 編輯 souece.list 檔案,將每行的「http://」替換為「http://localhost:9977/」

sudo gedit /etc/apt/sources.list

deb http://localhost:9977/archive.ubuntu.com/ubuntu/ jaunty main universe restricted multiverse
deb http://localhost:9977/security.ubuntu.com/ubuntu/ jaunty-security universe main multiverse restricted
deb http://localhost:9977/ftp.twaren.net/ubuntu jaunty main universe restricted multiverse
……以下省略、依此類推……

4. 更新套件資訊

sudo apt-get update

此時已大功告成。好奇的話,可以使用瀏覽器開啟 http://localhost:9977/ 頁面,看看 apt-p2p 的運作狀況。我的使用經驗是,有超過 98% 的流量會透過 apt-p2p 從其他 peers 那邊抓,只剩一點點會回到各個 Repository 那邊去下載。

0 意見: