内核的配置与编译

来源:互联网 发布:上海科技大学考研 知乎 编辑:程序博客网 时间:2024/05/17 09:35

内核的配置与编译
1、清除临时文件、中间文件和配置文件。
make clean
remove most 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:文本菜单
配置后会在linux 2.6.29下新增.config的隐藏文件,保存配置的结果


M:——>.o——>uImage(内核文件)
*: ——>.o(内核模块)
空:不操作

内核配置项较多,针对相似的结构进行配置,不用一项项分别选择

,在linux/arch/arm/configs/提供相应的参考配置文件。
这里选默认2410的defconfig:
[root@www configs]# pwd
/opt/studyarm/linux-2.6.29.1/arch/arm/configs
[root@www configs]# cp s3c2410_defconfig ../../../.config
[root@www linux-2.6.29.1]# make menuconfig ARCH=arm
进行选择配置即可。

make oldconfig:使用已有的配置文件(.config),但会询问新增

的配置选项。文本交互

make xconfig:图形化配置(需装图形化系统)。

4、编译内核: (仅编译选择为“*”的项)
make zImage
make bzImage
在x86平台,zImage只能用于小于512k的内核
如需获取详细编译信息,使用:
make zImage V=1
make bzImage V=1

编译好的内核位于 arch/<cpu>/boot/目录下

5、编译内核模块: (编译选择为“M”的项)
make modules

6、安装内核模块:
make modules_install
功能:仅仅拷贝——将编译好的内核模块从内核源代码目录copy到

/lib/modules下
eg. /lib/modules/2.6.29/kernel/arch/x86/kernel/

7、制作init ramdisk
mkinitrd initrd-$version $version    //$version 可以通过查

询/lib/modules下的目录得到
eg.mkinitrd initrd-2.6.29 2.6.29 //initrd-2.6.2可以用其他名字,但

2.6.29版本对应于/lib/modules/2.6.29 不能用其他
================
内核安装(x86平台)
1、cp arch/x86/boot/bzImage  /boot/vmlinuz-$version  //vmlinuz-

$version为任意取的名字
2、cp $initrd /boot/
3、修改/etc/grub.conf或者/etc/lilo.conf
$version为所编译的内核版本号

 

 

 

原创粉丝点击