在debian的官方文档中,介绍了两种比较实用的编译内核方法
目的是将内核制作成deb文件,方便软件包管理系统对软件进行统一化管理

1)使用dpkg-source和fakeroot make
#获得内核源代码
apt-get source linux-2.6
#解压内核源代码,并运行diff,获得debian化的源代码包
dpkg-source -x linux-2.6_2.6.26-13.dsc
#安装编译所需的软件包
apt-get install build-essential fakeroot
#解决编译linux-2.6的依赖关系
apt-get build-dep linux-2.6
cd linux-2.6-2.6.26
#打补丁
fakeroot debian/rules debian/build debian/stamps
fakeroot make -f debian/rules.gen setup_i386_none_686
#编译内核,选择目标平台为i386
fakeroot make -f debian/rules.gen binary-arch_i386_none_686
2)使用fakeroot make-kpkg
#获得内核源代码
sudo apt-get install linux-source-2.6
#解压内核源代码
tar xjf /usr/src/linux-source-2.6.26.tar.bz2
cd linux-source-2.6.26
#内核配置
make menuconfig
make-kpkg clean
#编译内核,--revision为版本标记
fakeroot make-kpkg --initrd --revision=aries.1.0 kernel_image
注:
发生以下错误时
lguest.c:34:18: error: zlib.h: 没有那个文件或目录
安装zliblg-dev
sudo apt-get install zlib1g-dev

网络资源:
1.Building custom kernel packages
http://wiki.debian.org/HowToRebuildAnOfficialDebianKernelPackage
2.Debian Linux Kernel Handbook
http://kernel-handbook.alioth.debian.org/ch-common-tasks.html
时间:2009-06-17 13:03
来源:
作者:c-aries
原文链接