# cd /path/to/source_code # make mrproper # make menuconfig 这是有很多选项可以供选择,有的让您选择[*],有的让您选择[M],有的让你选择[],*表示选中直接加载进kernel,而M则表示会在后面的make modules中编译成modules,让您随时可以通过过insmod和modprobe调入内核。
编辑完后,新的配置信息会写入源码根目录下的.config文件。然后可以开始编译了。# cd /usr/src/kernels/linux-2.6 # make bzImage # make modules # make modules_install # mkinitrd /boot/initrd-2.6.26.img 2.6.26 # cp /usr/src/kernels/linux-2.6/arch/i386/boot/bzImage /boot/bzImage-2.6.26 # cp /usr/src/kernels/linux-2.6/System.map /boot/System.map-2.6.26 # ln -s /boot/System.map-2.6.26 /boot/System.map 最后修改GRUB文件, 用于启动刚刚编译好的内核,该配置文件位于:#vi /boot/grub/menu.lst # grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a /boot partition. This means that # all kernel and initrd paths are relative to /boot/, eg. # root (hd0,0) # kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00 # initrd /initrd-version.img #boot=/dev/sda default=0 timeout=5 splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu title CentOS (2.6.18-53.el5) root (hd0,0) kernel /vmlinuz-2.6.18-53.el5 ro root=/dev/VolGroup00/LogVol00 initrd /initrd-2.6.18-53.el5.img