6 构建内核
执行下面命令来构建内核:
make-kpkg clean
fakeroot make-kpkg --initrd --append-to-version=-custom kernel_image
kernel_headers
在--append-to-version= 后面你可以写上任何字符串来区别内核版本, 但是必须以" - "符号开始而且后面不包括任何空格.
保持耐心, 内核编译需要一定时间, 主要看你的内核配置和处理器速度.
7 安装新内核
在成功构建内核后, 你在/usr/src目录能发现两个.deb软件包.
cd /usr/src
ls -l
在我的测试系统上, 他们分别名为 linux-image-2.6.18.1-custom_2.6.18.1-custom-10.00.Custom_i386.deb (包含了实际的内核) 和 linux-headers-2.6.18.1-custom_2.6.18.1-custom-10.00.Custom_i386.deb (包含了需要的文件, 用于以后需要编译额外的内核模块). 我是这样安装的:
dpkg -i linux-image-2.6.18.1-custom_2.6.18.1-custom-10.00.Custom_i386.deb
dpkg -i linux-headers-2.6.18.1-custom_2.6.18.1-custom-10.00.Custom_i386.deb
(现在你甚至能够拷贝这两个.deb文件到其它的Ubuntu系统, 通过上面的方式安装. 你将不再需要编译内核.)
然后检查 /boot/grub/menu.lst文件, 现在你将能发现新内核使用的两个引导配置块:
vi /boot/grub/menu.lst
在我测试系统上已经添加好的引导配置块是这样的:
title Ubuntu, kernel 2.6.18.1-custom
root (hd0,0)
kernel /boot/vmlinuz-2.6.18.1-custom root=/dev/sda1 ro quiet splash
initrd /boot/initrd.img-2.6.18.1-custom
savedefault
boot
title Ubuntu, kernel 2.6.18.1-custom (recovery mode)
root (hd0,0)
kernel /boot/vmlinuz-2.6.18.1-custom root=/dev/sda1 ro single
initrd /boot/initrd.img-2.6.18.1-custom
boot
现在重启系统:
shutdown -r now
如果一切进展顺利, 你的新内核正常工作. 你还可以通过运行下面命令来检查新内核是否运行:
uname -r
这将会显示如:
2.6.18.1-custom
如果系统没有起来, 重启一下, 你会看到:

按ESC进入GRUB菜单:

选择你以前的内核启动系统, 现在你能再次尝试编译新的工作内核. 不要忘记从/boot/grub/menu.1st文件中移去不需要的引导内核信息.
参考链接:
Ubuntu: http://www.ubuntu.com
The Linux Kernel Archives: http://www.kernel.org
原文链接:http://blog.zhaoke.com/7.html#more-7
上一页 1 2