linux内核配置与编译
Linux内核具有可定制的优点,具体步骤如下:
1、 清除临时文件、中间文间和配置文件
make clean
removemost generated files but keep the config
make mrproper
remove all generated files + config files
make distclean
mrproper + remove editor backup and patch files
2、 确定目标系统的软硬件配置情况,比如CPU的类型、网卡的型号,所需支持的网络协议等。
3、 使用如下命令之一配置内核
make config:基于文本模式的交互式配置。
make menuconfig:基于文本模式的菜单型配置。( 推荐使用)
make oldconfig:使用已有的配置文件(.config),但是会询问新增的配置选项。
make xconfig:图形化的配置(需安装图形化系统)。
内核配置通常在一个已有的配置文件基础上,通过修改得到新的配置文件,Linux内核提供了一系列可供参考的内核配置文件,位于Arch/$cpu/configs。
4、 编译内核
make zImage
make bzImane
区别:在X86平台,zImage只能用于小于512K的内核
编译好的内核位于arch/<cpu>/boot/目录下
5、 编译内核模块
make modules
6、 安装内核模块
make modules_install
将编译好的内核模块从内核源代码目录copy到/lib/modules下
7、 制作initramdisk
mkinitrd initrd-$version $version
例 :
mkinitrd initrd-2.6.29 2.6.29
经过上述7大步骤,linux内核已制作完成。
内核安装(X86)
1、cparch/x86/boot/bzImage /boot/vmlinuz-$version
2、cp $initrd/boot/
3、修改/etc/grub.conf 或者 /etc/lilo.conf
4、重启