1内核源代码的获取
从网站http://www.kernel.org网站上下载
例如我下载的是linux-2.6.27.62.tar.bz2
2 解压内核
bzip2 -d linux-2.6.27.62.tar.bz2
tar -xvf linux-2.6.27.62.tar
3定制内核
定制内核有很多种方法:make config(最基本方法),make defconfig(默认的方法)
例如用make defconfig:
cd linux-2.6.27.62
make defconfig
这时会生成一个.config文件,刚刚解压时是没有这个文件的。
make menuconfig
开始定制内核,怎么定制后续还会有
其中,Y是该选项能够构建到内核内部
M是构建模块
4构建内核
make clean(这一步最好执行一下)
make
如果你的CPU是多核的可以加个-j选项,让多核编译
如:make -j2
如果是采用多核编译的,有时还需要执行一下make,我想这有可能是多核时,有些东西他不晓得该同哪个核编译,有些东西没编译完吧?
5安装并引导内核
make modules_install 安装模块
make install 安装内核
这时,系统会自动在你的启动菜单中加入启动新内核的菜单。如
[root@localhost linux-2.6.27.62]# cat /boot/grub/menu.lst
default=1
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux AS (2.6.27.62)
root (hd0,0)
kernel /vmlinuz-2.6.27.62 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.27.62.img
title Red Hat Enterprise Linux AS (2.6.9-67.EL)
root (hd0,0)
kernel /vmlinuz-2.6.9-67.EL ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.9-67.EL.img
我老内核是kernel /vmlinuz-2.6.9-67.EL,新内核为kernel /vmlinuz-2.6.27.62,我们可以将default=1,改为default=0(它是以0开始的),此时就会启动新内核。
重启系统,启动新内核,这下就可以使用你定制的内核了。