當您查看 /usr/src 您將會看到一個 linux 的連接連到您所選的核心,我們會假設要安裝的核心版本是gentoo-sources-2.6.11-r3:
原始碼 3: 觀看核心原始碼目錄連接 |
# ls -l /usr/src/linux
lrwxrwxrwx 1 root root 12 Oct 13 11:04 /usr/src/linux ->
linux-2.6.11-gentoo-r3
|
如果這並沒有指向你所選擇的核心(注意 linux-2.6.11-gentoo-r3 只是一個範例),你要把他改成正確的核心:
原始碼 4: 更改核心連接目錄 |
# rm /usr/src/linux # cd /usr/src # ln -s linux-2.6.11-gentoo-r3 linux |
現在我們該設定以及編譯您的核心了。您可以使用 genkernel 完成此項步驟,並且將會以和 Installation CD 一樣的通用的方式進行編譯。我們將先解釋如何手動編譯因為這是自訂您的環境的最佳方法。
如果您想要手動編譯您的核心,請從 預設:手動設定 繼續。如果您想要使用 genkernel 請從 其他選擇:使用 genkernel 繼續。
7.c. 預設:手動設定
介紹
手動設定核心常常被 Linux 使用者認為最難完成的步驟。雖然不假 -- 但是當您手動編譯幾次核心後,您應該不會覺得它有多難 ;)
但是,唯一 的重點就是:您必須要了解您的系統才可以開始手動編譯。系統上多數的資料可以安裝 pciutils (emerge pciutils),從裏面包含的 lspci 取得。你可以在 chroot 的環境下執行 lspci,不過可能會碰到一些 lspci 丟出的錯誤訊息(像是 pcilib: cannot open /sys/bus/pci/devices)。此外,你也可以在 未 chroot 執行,兩個結果都一樣。您也可以執行 lsmod 看看安裝光碟使用那些核心模組(這是一個不錯的暗示,教您該開啟那個選項)。
現在到您的核心原始碼目錄然後執行 make menuconfig。這將會啟動一個 ncurses 的設定選單。
原始碼 5: 開始 menuconfig |
# cd /usr/src/linux # make menuconfig |
您將會看到一大串的設定部份。我們將列出一些您一定要啟用的選項(不然 Gentoo 無法完善地工作)。
必須開啟的選項
請確定您的系統開機所必需的每個驅動程式(像是 SCSI controller,...)都有 編進 核心而不是編成模組,否則您的系統將無法完成開機程序。
現在,選擇正確的處理器類別:
原始碼 6: General Support and processor family |
General setup --->
[*] Support for hot-pluggable devices
Processor type and features --->
Subarchitecture Type (PC-compatible) --->
(依照您的處理器所更換)
(Athlon/Duron/K7) Processor family
|
現在到 File Systems 然後選擇要支援的檔案系統。記得 不要 將它們編成模組(Module)。還有 /proc file system 和 Virtual memory。 不要 勾選 /dev file system。
原始碼 7: 選擇相關檔案系統 |
File systems --->
Pseudo Filesystems --->
<*> /proc file system support
<*> /dev file system support (OBSOLETE)
<*> Automatically mount at boot
<*> Virtual memory file system support (former shm fs)
(按照您系統所需要的檔案系統開啟以下選項)
<*> Reiserfs support
<*> Ext3 journalling file system support
<*> JFS filesystem support
<*> Second extended fs support
<*> XFS filesystem support
|
不要忘了啟動您磁碟的 DMA 功能:
原始碼 8: 啟動 DMA |
Device Drivers --->
ATA/IDE/MFM/RLL support --->
[*] Generic PCI bus-master DMA support
[*] Use PCI DMA by default when available
|
如果您需要透過 PPPoE 連線到網路或是數據機撥接,您將需要以下的核心選項:
原始碼 9: 選擇 PPPoE 相關驅動程式 |
Device Drivers --->
Networking support --->
<*> PPP (point-to-point protocol) support
<*> PPP support for async serial ports
<*> PPP support for sync tty ports
|
雖然 PPP over Ethernet 選項只有在 rp-pppoe 設定為核心 PPPoE 時需要,但是這兩個壓縮的選項不會造成錯誤。
如果您需要,不要忘了為您的網路卡加入核心的支援。
如果您有一個支援 HyperThreading(tm) 的 Intel CPU,或是有多個 CPU,您應該啟用 "Symmetric multi-processing support":
原始碼 10: 啟用 SMP 支援 |
Processor type and features ---> <*> Symmetric multi-processing support |
如果你使用 USB 輸入裝置(像是鍵盤或滑鼠)不要忘記開啟他:
原始碼 11: 啟動 USB 輸入裝置支援 |
Device Drivers ---> USB Support ---> <*> USB Human Interface Device (full HID) support [*] HID input layer support |
如果您是筆記型電腦的使用者,並且需要 PCMCIA 支援,記得把它編進核心。還有其下的選項,記得要啟動您系統上 PCMCIA card bridge 的支援(在同一個設定選單畫面中可找到)。
原始碼 12: 啟動 PCMCIA 支援 |
Bus options (PCI, PCMCIA, EISA, MCA, ISA) --->
PCCARD (PCMCIA/CardBus) support --->
<*> PCCard (PCMCIA/CardBus) support
(如果您需要支援較老舊的 PCMCIA 卡,勾選 16 bit。多數人會想要加入這個。)
<*> 16-bit PCMCIA support
[*] 32-bit CardBus support
(選取相關的 bridge)
--- PC-card bridges
<*> CardBus yenta-compatible bridge support (NEW)
<*> Cirrus PD6729 compatible bridge support (NEW)
<*> i82092 compatible bridge support (NEW)
<*> i82365 compatible bridge support (NEW)
<*> Databook TCIC host bridge support (NEW)
|
編譯和安裝
現在您的核心已經設定完成了,我們該來編譯然後安裝它。離開核心設定,然後執行 make dep && make bzImage modules modules_install:
原始碼 13: 編譯核心 |
# make && make modules_install
|
當核心完成編譯時,將核心映像檔複製到 /boot:從這邊我們將假設您安裝的是 gentoo-sources 的 2.6.11-r3。您可以隨意更改容易記住的檔案名稱,方便稍後的開機程式設定。
原始碼 14: 安裝核心 |
# cp arch/i386/boot/bzImage /boot/kernel-2.6.11-gentoo-r3
|
您也可以將您的核心設定檔備份到 /boot,以防萬一 :)
原始碼 15: 備份您的核心設定檔 |
# cp .config /boot/config-2.6.11-gentoo-r3
|