Gentoo 安装步骤介绍(6)
时间:2006-01-01 来源:nig.daemon
6. 安裝 Gentoo基礎系統
內容:- 變換根目錄
- 設定 Portage
6.a. 變換根目錄
自由選擇:選擇鏡像站
為了要快速下載原始碼,建議你選擇一個快速的鏡像站。Portage 會搜尋 make.conf 中的 GENTOO_MIRRORS 變數所列的鏡像站。你可以瀏覽我們的 鏡像站列表 來尋找最接近你的鏡像站(這通常是最快的),不過我們提供了一個不錯的工具,叫作 mirrorselect,提供一個不錯的介面選擇鏡像站。
原始碼 1: 使用 mirrorselect 設定 GENTOO_MIRRORS 變數 |
# mirrorselect -i -o >> /mnt/gentoo/etc/make.conf
|
警告: 不要選擇任何 IPv6 鏡像站。目前我們的 stage 不支援 IPv6。 |
另一個重要的設定是 make.conf 中的 SYNC 設定。這個變數包含當你在更新 Portage tree 時所使用的 rsync 伺服器(Portage tree 包含了 ebuild,裏面有所有 Portage 下載及安裝軟體所需的資訊)。雖然你可以手動輸入 SYNC 伺服器, mirrorselect 可以幫你輕鬆完成:
原始碼 2: 使用 mirrorselect 選擇 rsync 伺服器 |
# mirrorselect -i -r -o >> /mnt/gentoo/etc/make.conf
|
執行 mirrorselect 後最好再三確認 /mnt/gentoo/etc/make.conf 中的設定!
複製 DNS 設定
還有一件事在我們進入新的系統環境之前要記得做,就是複製 /etc/resolv.conf 中的 DNS 設定。您需要做這件是確保網路在進入新的環境後仍然可以工作。 /etc/resolv.conf 包含網路需要的名稱伺服器。
原始碼 3: 複製 DNS 設定 |
(我們將需要使用到 "-L" 的參數來確保我們不會複製到連接類型的檔案 ) # cp -L /etc/resolv.conf /mnt/gentoo/etc/resolv.conf |
掛載 proc 檔案系統
將 /proc 檔案系統掛載到 /mnt/gentoo/proc 讓安裝過程中即使是在 chrooted 的環境也可以取得新提供的資訊。
原始碼 4: 掛載 /proc |
# mount -t proc none /mnt/gentoo/proc
|
進入新的系統環境
現在所有的分割區都已經初步設定好了而且基本的系統也安裝完畢,現在是用 變換根目錄進入新的系統環境的時候了。這代表我們從目前的安裝環境 (安裝光碟或是其他的安裝媒體)進入您安裝的系統(就是已經安裝的分割區)。
變換根目錄動作在三步驟內完成。首先我們會用 chroot 讓根目錄從 / (目前安裝的媒體)變換到 /mnt/gentoo (或您安裝的分割區)。然後用 env-update 建立新的環境,這將會建立基本的系統變數。最後,我們用 source 把這些變數載入到記憶體。
原始碼 5: 進入新的環境 |
# chroot /mnt/gentoo /bin/bash # env-update * Caching service dependencies... # source /etc/profile |
恭喜!您現在在新的 Gentoo Linux 環境當中了。不過離安裝完畢還有一段時間,這就是為什麼安裝指南還有下面這些部份 :-)
6.b. 設定 Portage
更新 Portage tree
你現在要更新 Portage tree 到最新,用 emerge --sync 來更新。
原始碼 6: 更新 Portage tree |
# emerge --sync (如果你的終端機很慢,例如一些 framebuffer 或是 serial console,你可以 加入 --quiet 來加快速度:) # emerge --sync --quiet |
如果你被防火牆阻擋 rsync 連線,你可以使用 emerge-webrsync 下載及安裝 portage 快照。
如果您看到新的 Portage 已經可以下載而且您必須要更新的警告時,您應該要略過它, Portage 在之後安裝時會被更新。
選擇正確的 Profile
首先,先是一小部分的定義。
profile 是任何 Gentoo 系統在建立時參考的地方。不只是設定 CHOST,CFLAGS 及其他重要變數的預設值, 塔也把系統鎖定在特定的套件版本。這些都是由 Gentoo 開發者維護的。
在以前,這種 profile 很少會被使用者接觸到。但是 x86,hppa 及 alpha 使用者有兩個 profile 可以選擇,一個是適用 2.4 核心,另一個是 2.6 核心。這種做法是為了對2.6 核心有更好的整合性。ppc 及 ppc64 架構有數種 profile 可以用。我們稍後會介紹這些。
你可以用下面的指令來看你現在是用哪個 profile:
原始碼 7: 查看系統 profile |
# ls -FGg /etc/make.profile lrwxrwxrwx 1 48 Apr 8 18:51 /etc/make.profile -> ../usr/portage/profiles/default-linux/x86/2005.1/
|
如果你是用上面提到三種架構之一,預設提供給你的 profile 是使用 Linux 2.6 基礎的系統。預設建議你這麼做,但是你也可以選擇使用別種 profile。
一些使用者會想要安裝較舊的 Linux 2.4 profile。如果你有一個如此做的好理由,你首先要確認是否有額外的 profile 可以用。在 x86 系統,可以使用下面的指令來查詢:
原始碼 8: 查看是否有額外的 profile |
# ls -d /usr/portage/profiles/default-linux/x86/2005.1/2.4 /usr/portage/profiles/default-linux/x86/2005.1/2.4
|
上面的例子顯示有額外的 2.4 profile (也就是說,他沒有抱怨找不到檔案或目錄)。建議你使用預設值就好,和如果你想要換過去的話,你可依下面的步驟操作:
原始碼 9: 換到 2.4 profile |
(確定你使用正確的架構,底下的例子是適用 x86 的) # ln -snf /usr/portage/profiles/default-linux/x86/2005.1/2.4 /etc/make.profile (顯示 2.4 profile 中的檔案) # ls -FGg /etc/make.profile/ total 12 -rw-r--r-- 1 939 Dec 10 14:06 packages -rw-r--r-- 1 347 Dec 3 2004 parent -rw-r--r-- 1 573 Dec 3 2004 virtuals |
ppc 架構在 2005.1 板有這些新的 profile。
原始碼 10: PPC Profiles |
(一般 PPC profile, 適用所有 PPC 機器) # ln -snf /usr/portage/profiles/default-linux/ppc/2005.1/ppc /etc/make.profile (G3 profile) # ln -snf /usr/portage/profiles/default-linux/ppc/2005.1/ppc/G3 /etc/make.profile (G3 Pegasos profile) # ln -snf /usr/portage/profiles/default-linux/ppc/2005.1/ppc/G3/Pegasos/ /etc/make.profile (G4 (Altivec) profile) # ln -snf /usr/portage/profiles/default-linux/ppc/2005.1/ppc/G4 /etc/make.profile (G4 Pegasos profile) # ln -snf /usr/portage/profiles/default-linux/ppc/2005.1/ppc/G4/Pegasos/ /etc/make.profile |
ppc64 架構在 2005.1 板有這些新的 profile。
原始碼 11: PPC64 Profiles |
(一般的 64bit userland PPC64 profile, 適用所有 PPC64 機器) # ln -snf /usr/portage/profiles/default-linux/ppc/2005.1/ppc64/64bit-userland /etc/make.profile (一般的 32bit userland PPC64 profile, 適用所有 PPC64 機器) # ln -snf /usr/portage/profiles/default-linux/ppc/2005.1/ppc64/32bit-userland /etc/make.profile (每一種的 userland 有底下的子類別,將底下的 (userland) 取代成你在上面選的 userland) (JS20 使用的 970 profile) # ln -snf /usr/portage/profiles/default-linux/ppc/2005.1/ppc64/(userland)/970 /etc/make.profile (G5 profile) # ln -snf /usr/portage/profiles/default-linux/ppc/2005.1/ppc64/(userland)/970/pmac /etc/make.profile (POWER3 profile) # ln -snf /usr/portage/profiles/default-linux/ppc/2005.1/ppc64/(userland)/power3 /etc/make.profile (POWER4 profile) # ln -snf /usr/portage/profiles/default-linux/ppc/2005.1/ppc64/(userland)/power4 /etc/make.profile (POWER5 profile) # ln -snf /usr/portage/profiles/default-linux/ppc/2005.1/ppc64/(userland)/power5 /etc/make.profile (multilib profile 在這次發佈的版本仍然不穩定) |
設定 USE 變數
USE 是 Gentoo 提供給使用者最有威力的變數之一。許多程式可以在編譯時包含或不包含自由選擇的支援。例如,一些程式可以在編譯時包含 gtk 支援,或者是支援 qt。其它程式可以包含或不包含 SSL 支援,也有一些甚至可以使用 framebuffer (svgalib) 而不是 X11 (X-server)。
大部分的安裝套件在編譯時都盡可能地加入最多的支援,增加檔案大小以及程式啟動的時間,更別提複雜的相依性。在 Gentoo 下您可以定義哪些支援編譯時要加入。這就是 USE 的作用。
在 USE 變數中,您可以加入要在編譯時加入支援的關鍵字。例如,ssl 會在支援 ssl 的程式編譯時加入 ssl 支援。-X 則會移除 X-server 支援(注意前面的減號)。gnome gtk -kde -qt 則會支援 gnome(以及 gtk),而不包含 kde(以及 qt) 的支援,這可以讓您的系統對 GNOME 完整的調節。
預設的 USE 設定放在 make.defaults,你會在 /etc/make.profile 指向的目錄及上層目錄找到 make.defaults 檔案。預設的 USE 是所有 make.defaults 檔案中 USE 的集合。而您在 /etc/make.conf 中的設定會和預設的設定一起考慮。如果您在 USE 設定中新增一些東西,他會加入預設的設定中。如果您從 USE 中移除一些東西(在前面加上減號),他會從預設的設定移除。永遠不要改變任何在 /etc/make.profile 目錄中的東西,他會在您更新 Portage 時被覆蓋!
完整的 USE 說明可以在 Gentoo 手冊中 USE 參數 找到。完整的 USE 參數列表可以在系統中的 /usr/portage/profiles/use.desc 找到。
原始碼 12: 檢視可用的 USE 參數 |
# less /usr/portage/profiles/use.desc (你可以使用方向鍵來捲動,按下 ''''q'''' 離開) |
下面是一個 USE 的設定,在以 KDE 為基礎的系統中支援 DVD, ALSA 以及燒錄機。
原始碼 13: 開啟 /etc/make.conf |
# nano -w /etc/make.conf
|
原始碼 14: USE 設定 |
USE="-gtk -gnome qt kde dvd alsa cdr" |
自由選擇:GLIBC Locales
你可能只會需要在你的系統上使用一種或兩種 locale。在目前編譯完 glibc 後所有可用的 locale 都會被建立。你可以啟動 userlocales USE 設定並且在 /etc/locales.build 指定你需要的 locales。除非您知道您要選擇那一種 locales 才做這個動作。
原始碼 15: 為 glibc 啟動 userlocales USE 設定 |
# mkdir -p /etc/portage # echo "sys-libs/glibc userlocales" >> /etc/portage/package.use |
現在指定你想要使用的 locale:
原始碼 16: nano -w /etc/locales.build |
# nano -w /etc/locales.build
|
下面是一個locales的範例,用來同時取得English (United States)和 German (Germany)和其他的字型格式(如UTF-8)。
原始碼 17: 指定你的 locale |
en_US/ISO-8859-1 en_US.UTF-8/UTF-8 de_DE/ISO-8859-1 de_DE@euro/ISO-8859-15 |
請從 設定核心 繼續。