开发板:mini2440
OS:Red Hat
可以参考的文档:
内核配置与编译:
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. 使用如下命令之一配置内核:
// 本次实验用的是X86平台下的.config 文件
make config:基于文本
X86:make menuconfig:基于文本模式的菜单型配置。(推荐使用)
//ARM:make menuconfig ARCH=ARM 嵌入式内核配置
make oldconfig:使用已有的配置文件,但是会询问新增的配置选项
make xconfig:图形化的配置(需安装图形界面)
*与M的区别:
*:有编译链接的过程,并和其他的文件生成内核镜像。
M:只有编译的过程,生成内核模块
4. 编译内核(配置时选择为*的选项)
make zImage
X86:make bzImage(大内核)
// 嵌入式内核
//ARM:make uImage ARCH=arm CROSS_COMPILE=arm-linux-
区别:在X86平台,zImage只能用于小于512K的内核
如果需要获取详细编译信息,可以使用:
make zImage V=1
make bzImage V=1
编译好的内核位于arch//boot/目录下
5.编译内核模块(配置时选择为M的选项)
make modules
6.安装内核模块
make modules_install
将编译后的内核模块从内核源码目录copy至/lib/modules相应的内核版本下面。
7. 制作init ramdisk
mkinitrd initrd-$version $version
例:mkinitrd initrd-2.6.29 2.6.29
$version 可以通过查询/lib/modules下的目录得到
// ubuntu 下用mkinitramfs命令
sudo mkinitramfs -o /boot/initrd-2.6.39 2.6.39
内核安装
1.cp arch/x86/boot/bzImage /boot/vmlinuz-$version
2. cp initrd-$version /boot/
3.修改/etc/grub.conf 或者/etc/lilo.conf
$version 为所编译的内核版本号
问题:
上网查一下什么是zImage、ramdisk
zImage----内核镜像文件
ramdisk------
FAQ:
mkinitrd failed with error No module dm-mem-cache found for kernel
mkinitrd command to install a new kernel on CentOS 5 (RHEL5) :
No module dm-mem-cache found for kernel 2.6.18-92.1.13.el5, aborting.
This is because the system tries to include the dm-mem-cache module in
the generated initial ramdisk images eventhough your system might not have dmraid.
So while creating a initial ramdisk images for kernels that do not provide the dm-mem-cache module,
you can run the folloing command.
# /sbin/mkinitrd –without-dmraid /boot/initrd-.img
You can also setup a permanent fix to exclude dm-mem-cache module by running the following commands.
# echo “DMRAID=no” > /etc/sysconfig/mkinitrd/noraid # chmod 755 /etc/sysconfig/mkinitrd/noraid
Solution
To build an initrd image, for a kernel that does not provide the dm-mem-cache module, it is possible to prevent the inclusion of the module by adding the --without-dmraid argument to the mkinitrd command line.
It is also possible to create a permanent exception for the inclusion of the dm-mem-cache module. This can be done by creating the file /etc/sysconfig/mkinitrd/noraid as follows:
# echo "DMRAID=no" > /etc/sysconfig/mkinitrd/noraid
# chmod 755 /etc/sysconfig/mkinitrd/noraid
阅读(2265) | 评论(0) | 转发(0) |