Chinaunix首页 | 论坛 | 博客
  • 博客访问: 171117
  • 博文数量: 65
  • 博客积分: 1400
  • 博客等级: 上尉
  • 技术积分: 720
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-16 08:59
文章分类

全部博文(65)

文章存档

2011年(3)

2010年(3)

2009年(43)

2008年(16)

我的朋友

分类: LINUX

2009-03-13 16:48:04

虽然RedHat有提供kernelsource package(kernel-devel-xxxxx),且只要安装该套件后kernel source tree即会被放置在 /usr/src/kernels/ 目录下,但是若我们试着在该kernel source tree里面进行complie的动作则会出现以下的错误讯息:『make[1]: *** No rule to make target `init/main.o', needed by `init/built-in.o'. Stop.』。会造成这种情况的原因并不清楚,总之我们就是不能直接拿kernel-devel套件里面提供的kernel source tree来打造自己的kernel。因此我们必须要改用kernel-xxxxx.src.rpm还原出的kernel source tree来进行patchcompile的动作。
 所需要的套件:
  1. kernel-2.6.9-55.EL.src.rpm (在此以2.6.9-55.EL这个版本为例)
一、从source rpm档案中还原出kernel source tree


1.rpm -ivh kernel-2.6.9-55.EL.src.rpm
相关的档案会被放置在 /usr/src/redhat 的子目录中(SOURCE,SPECS),但在RPM Database中将不会有这个套件的安装记录,此为正常现象。

2.cd /usr/src/redhat/SPECS
rpmbuild -bp kernel-2.6.spec –target=i686

此指令会把所有RedHat提供的patch档案patchkernel source tree中,并将kernel source tree放置于 /usr/src/redhat/BUILD/kernel-2.6.9/linux-2.6.9目录中。

二、Patch Distribution Kernel

1. patch档案复制到kernel source treeroot dir
eg. cp myhappy.patch /usr/src/redhat/BUILD/kernel-2.6.9/linux-2.6.9

2. cd /usr/src/redhat/BUILD/kernel-2.6.9/linux-2.6.9
  patch -p1 < myhappy.patch

三、设定Kernel


1. cd /usr/src/redhat/BUILD/kernel-2.6.9/linux-2.6.9
  make menuconfig

3.
此时会有选单出现,请将画面移到最下方选取 "Load An Alternate Configuration File"

4.
开始设定kernel

四、编译kernel

1. cd /usr/src/redhat/BUILD/kernel-2.6.9/linux-2.6.9
2. vi MakeFile
  EXTRAVERSION = -55-custom

修改EXTRAVERSION的值以免和原本的版本搞混,例如改为-55-custom则最后产生出来的kernel iamgevmlinuz-2.6.9-55-custom

3. make clean
注意!不能用make mrproper,否则会连.config(kernel设定档)也一并清除。

4. make   此部分为修改,2.6.X的内核这样编译就可以啦
6. make modules_install
7. make install
8.
最后要记得修改 /boot/grub/grub.conf

注:
若是不想用 make install 来自动安装kernel image,也可以改用手工安装。
1.
kernel source tree中的arch/i386/boot/bzImage改名为vmlinux-2.6.9-55-custom

2. mkinitrd initrd-2.6.9-55-custom.img `2.6.9-55-custom`

3. cp /usr/src/redhat/BUILD/kernel-2.6.9/linux-2.6.9/System.map \
    /boot/System.map-2.6.9-55-custom

4.
kernelinitrd images放置到 /boot目录,并修改 /boot/grub/grub.conf

 

英语网站的资料:

rpmbuild -bp kernel-2.6.spec

If you want to build the kernel for a specific architecture such as i386, i586, i686, or x86_64, you can do it like this:
rpmbuild -bp --target=i686 kernel-2.6.spec

mkinitrd /boot/initrd-2.6.18-custom-2.6.18.2.img 2.6.18-custom-2.6.18.2

 







阅读(310) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~