Gentoo Linux 安裝(四)配置Linux內核

選擇一個合適的內核並使用emerge來安裝它。
root #emerge --ask sys-kernel/gentoo-sources
這將在/usr/src/中安裝Linux內核源碼,並有一個符號連接叫作linux將指向安裝的內核源碼:
root #ls -l /usr/src/linux
lrwxrwxrwx 1 root root 12 Oct 13 11:04 /usr/src/linux -> linux-3.16.5-gentoo

默認:手動配置
介紹
手動配置內核經常被Linux用戶認爲是最困難的步驟。事實並非如此——但是當您手動配置幾次內核之後,你就不會再覺得它有多麼難了:)
無論如何,有一件事是真實的:當手動配置內核時,瞭解(硬件)系統是至關重要的。大多數信息可以通過安裝包含lspci命令的sys-apps/pciutils來收集:
root #emerge --ask sys-apps/pciutils
 附註
在chroot中,可以安全的忽略任何lspci可能拋出的關於pcilib的警告(比如pcilib: cannot open /sys/bus/pci/devices)。
另一個系統信息來源是運行lsmod來查看安裝CD使用什麼內核模塊,它可能對啓用什麼提供了一個好的暗示。
現在進入內核源碼目錄並執行make menuconfig。這將啓動一個菜單驅動的配置屏幕。
root #cd /usr/src/linux
root #make menuconfig
Linux內核配置有很多很多的章節。我們先列出一些必須激活的選項(否則Gentoo將無法工作,或者離開附加的調整將無法正常工作)。我們同時在Gentoo維基上有一個Gentoo內核配置指南可能會在將來有幫助。
激活必要的選項
確保引導系統的每一個至關重要的驅動(比如SCSI控制器……)是編譯進內核而不是作爲一個模塊,否則系統將無法完全引導。
接下來選擇最控制的CPU類型。同時建議啓用MCE功能(如果可用)能在硬件出現問題時通知用戶。在一些架構(比如x86_64),這些錯誤不會打印到dmesg,但是會到/dev/mcelog。這需要app-admin/mcelog包。
同時選擇Maintain a devtmpfs file system to mount at /dev來讓重要的設備文件在引導過程的早期就已就緒。
KERNEL 啓用devtmpfs支持
Device Drivers ---> Generic Driver Options ---> [*] Maintain a devtmpfs filesystem to mount at /dev [ ] Automount devtmpfs at /dev, after the kernel mounted the rootfs
現在進入File Systems並選擇你使用的文件系統。不要作爲模塊來編譯根文件系統所使用的文件系統,否則Gentoo系統將不能掛載這個分區。同時選擇Virtual memory/proc file system
KERNEL 選擇所需要的文件系統
File systems --->(Select one or more of the following options as needed by your system) <*> Second extended fs support <*> Ext3 journalling file system support <*> The Extended 4 (ext4) filesystem <*> Reiserfs support <*> JFS filesystem support <*> XFS filesystem support ... Pseudo Filesystems ---> [*] /proc file system support [*] Virtual memory file system support (former shm fs)
如果使用PPPoE連接到互聯網,或者使用一個撥號調制解調器,則啓用下面的選項:
KERNEL 選擇PPPoE所需要的驅動
Device Drivers ---> Network device support ---> <*> PPP (point-to-point protocol) support <*> PPP support for async serial ports <*> PPP support for sync tty ports
這兩個壓縮選項將是無害的,但是它們一定是不需要的,包括基於以太網的PPP選項也是一樣,只有在配置內核模式PPPoE時纔會需要。
不要忘記在內核中包括網(以太網或無線)卡。
大多數系統會有多核心處理,所以激活Symmetric multi-processing support是重要的:
KERNEL 激活SMP支持
Processor type and features ---> [*] Symmetric multi-processing support
 附註
在多核心繫統中,每一個核心計作一個處理器。
如果使用USB輸入設備(比如鍵盤和鼠標),不要忘記啓用那些:
KERNEL 激活USB輸入設備的支持
Device Drivers ---> [*] HID Devices ---> <*> USB Human Interface Device (full HID) support

架構特有的內核配置
確保選擇IA32 Emulation如果要支持32位程序(multilib)。Gentoo將默認安裝一個multilib系統(混合32位/64位計算),所以除非使用一個no-multilib配置文件,這個選項是必需的。
KERNEL 選擇processor types and features
Processor type and features ---> [ ] Machine Check / overheating reporting [ ] Intel MCE Features [ ] AMD MCE Features Processor family (AMD-Opteron/Athlon64) ---> ( ) Opteron/Athlon64/Hammer/K8 ( ) Intel P4 / older Netburst based Xeon ( ) Core 2/newer Xeon ( ) Intel Atom ( ) Generic-x86-64Executable file formats / Emulations ---> [*] IA32 Emulation
如果在分區時使用GPT分區標籤,則啓用對它的支持:
KERNEL 啓用GPT支持
-*- Enable the block layer ---> ... Partition Types ---> [*] Advanced partition selection ... [*] EFI GUID Partition support
如果使用UEFI來引導系統,則在內核中啓用EFI樁支持和EFI變量:
KERNEL 啓用UEFI支持
Processor type and features ---> [*] EFI runtime service support [*] EFI stub support Firmware Drivers ---> <*> EFI Variable Support via sysfs




編譯和安裝
當配置完成,是時間來編譯和安裝內核了。退出配置並開始編譯過程:
root #make && make modules_install
 Note
It is possible to enable parallel builds using make -jX with X being an integer number of parallel tasks that the build process is allowed to launch. This is similar to the instructions about /etc/portage/make.conf earlier, with the MAKEOPTS variable.
When the kernel has finished compiling, copy the kernel image to /boot/. This is handled by the make install command:
root #make install
這將複製內核鏡像到/boot/,一起的還有System.map文件和內核配置文件。



內核模塊
配置模塊
/etc/conf.d/modules中列出需要自動加載的模塊。如果有必要,附加選項也可以添加到模塊中。
要查看所有可用模塊,運行下面的find命令。不要忘記替換“<kernel version>”爲剛剛編譯的內核版本:
root #find /lib/modules/<kernel version>/ -type f -iname '*.o' -or -iname '*.ko' | less
比如,要自動加載3c59x.ko模塊(3Com網卡家族的特定驅動),編輯/etc/conf.d/modules文件並在裏面輸入模塊名字。
root #nano -w /etc/conf.d/modules
modules="3c59x"
繼續到配置系統來安裝。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章