选择一个合适的内核并使用
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用户认为是最困难的步骤。事实并非如此——但是当您手动配置几次内核之后,你就不会再觉得它有多么难了:)
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"