分类: LINUX
2014-06-05 13:46:11
原文地址:VMware下CentOS 6编译内核 作者:jean_leo
Executable file formats / Emulations
只选择了kernel support for ELF binaries
Networking support
可以不管
Device Drivers
Connector- unified userspace <-> kernelspace linker
Block devices-->
Normal floppy disk support
loopback device support
network block device support
RAM block device support
SCSI device support//如果是ide硬盘,这个可以全都不选,选择ata相关的
* SCSI device support
legacy /proc/scsi/ support
scsi disk support
scsi cdrom support
scsi generic support
Probe all LUNs on each SCSI device
SCSI low-level drivers
* BusLogic SCSI support
PS: IDE硬盘,则选择(下面以我选择的为例,可能不是最精简的)
<*> ATA/ATAPI/MFM/RLL support (DEPRECATED)
<*> generic ATA/ATAPI disk support
[*] ATA disk support
<*> generic/default IDE chipset support
<*> Generic PCI IDE Chipset Support
<*> Serial ATA and Parallel ATA drivers
<*> AHCI SATA support
Fusion MPT device support
Fusion MPT ScsiHost drivers for SPI
I2C support
I2C hardware bus support
Intel PIIX4 and compatible
USB support
* USB Mass Storage support
Device Drivers
Network device support
Ethernet (10 or 100Mbit) / Ethernet driver support
* AMD PCnet32 PCI support
Virtualization
可以不管
此外需要将系统上安装好的文件系统类型全部选上(我这里将其选为built-in类型,而非模块)。
比如我的:
<*> The Extended 4 (ext4) filesystem
[*] Ext4 extended attributes
[*] Ext4 POSIX Access Control Lists
[*] Ext4 Security Labels
[*] EXT4 debugging support
[*] JBD (ext3) debugging support
[*] JBD2 (ext4) debugging support
5)编译内核,为了加快编译速度,可以添加选项-jn,其中n替换为线程数值,一般是CPU核数的两倍。
make -j8 all
6)安装内核模块。
make modules_install
PS:其实在make all和make modules_install中间还有两条命令可以操作,就是make bzImage(压缩内核)和make modules(编译模块),但是这两条命令无关紧要,可以不管。
7)将编译生成的内核文件拷贝到对应位置去,其实可以很简单就用make install命令即可,只是会自动添加一些其他东西上去,故未采用。
cp -v System.map /boot/System.map-2.6.34.14
cp -v arch/i386/boot/bzImage /boot/vmlinuz-2.6.34.14
cp -v .config /boot/config-2.6.34.14
rm -f System.map vmlinuz
ln -s vmlinuz-2.4.18 vmlinuz
ln -s System.map-2.4.18 System.map
注:
其实除了cp -v arch/i386/boot/bzImage /boot/vmlinuz-2.6.34.14是必须的之外,其余的操作可以不管。
8)为新内核创建一个ramdisk,否则系统不能引导。
mkinitrd /boot/initramfs-2.6.34.14.img 2.6.34.14
PS:后面的2.6.34.14是根据版本来填的,具体可以依据/lib/modules目录里面的目录名来填。
如果不创建ramdisk,很容易遇到一个这样的报错:
VFS:Cannot open root device "sda" or unknow-block(0,0)
Please append a correct "root=" boot option
kernel panic:VFS:Unable to mount root fs on unknown-block(0,0)
很让人头疼的,就这玩意折腾了我N个小时了。