1.源码下载
源码版本为linux-2.6.34。下载路径为百度网盘:
http://pan.baidu.com/s/1pJJZpkZ;
将源码放在自己的工作目录执行tar xf linux-2.6.34.tar.bz2 解压后生成linux-2.6.34文件名。
2.编译内核
提供源码,就可以自己做裁剪配置,推荐使用图形界面配置。
基于ncurse库编写的图形界面工具:make menuconfig;
或者基于GTK的:make gconfig;
用默认的配置:make defconfig;
验证和更新配置:make oldconfig 建议在编译内核前都执行这个命令;
配置完后执行make;
同时多个编译任务:make -jn n为任务数,一般每个处理器可以衍生一个或者两个任务作业。
只看错误信息和警告的编译方法:make > /dev/null 将编译打印信息重定向到不会返回结果的黑洞中。
3.可能遇到的问题
问题1.make menuconfig报错
*** Unable to find the ncurses libraries or the *** required header files.
*** 'make menuconfig' requires the ncurses libraries. ***
*** Install ncurses (ncurses-devel) and try again. ***
make[1]: *** [scripts/kconfig/dochecklxdialog] 错误 1
make: *** [menuconfig] 错误 2
解决方法:
根据错误的提示进行如下的安装过程:
1.sudo apt-get install ncurses
如果安装失败,软件包ncurses还没有可供安装的候选者.就先安装libncurses*
2.sudo apt-get install libncurses*
问题2.make bzImage或make或make modules提示如下错误(这个错误不是每个人都会遇到的,可以用gcc--help查看你的gcc版本,如果你的版本是 4.6或者4.6之后的应该会有下面的问题,如果比4.6的早就不会出现这个问题):
gcc: 错误: elf_i386:没有那个文件或目录
make[2]: *** [arch/x86/vdso/vdso32-int80.so.dbg] 错误 1
make[1]: *** [arch/x86/vdso] 错误 2
make: *** [arch/x86] 错误 2
解决方法:
这个问题是由于 gcc 4.6 不再支持 linker-style 架构。将 arch/x86/vdso/Makefile 中, 以 VDSO_LDFLAGS_vdso.lds 开头所在行的 "-m elf_x86_64" 替换为 "-m64"。 以 VDSO_LDFLAGS_vdso32.lds 开头所在行的 "-m elf_x86" 替换为 "-m32"。需要将原有的空格去掉。