- 论坛徽章:
- 0
|
linux内核编译及grub配置
还没译过内核的朋友在这里可以看到希望。以前费了好些力才整好,你运气不错,碰上我这么一个好人。能分享经验,也是件开心的事。
有空再写.
修改于5月26晚
终于有点空闲时间,时至今日已欺骗了40多人的感情.
我假设你已经下载好了最新内核源代码,并解开。(www.kernel.org)
建议你把代码放在/usr/src/XXX,把.config文件copy到你的最新内核代码里。若你是第一次干这种事,不知道.config在哪里,请updatedb 然后locate .config。这个文件就在src下面的下面的某个目录里,隐藏的。-----------其实我写得太细了。
OK?
运行:make menuconfig ,退出保存。(也可用make oldconfig 一路回车杀到底)
make bzImage (我不希望你用 make zImage,现在内核大了,你得压缩)。
人品好点,你会很顺利。(若你发现在自己例外,没事。这可能是你前面某步出错
make mrproper把已经生成的文件打扫干净,再来!)
make modules
make moudles_install 安装编译好的模块。
接下来就是配置grub.conf了。这是我电脑里的grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You do not have a /boot partition. This means that
# all kernel and initrd paths are relative to /, eg.
# root (hd0,6)
# kernel /boot/vmlinuz-version ro root=/dev/hda7
# initrd /boot/initrd-version.img
#boot=/dev/hda
default=2
timeout=0
splashimage=(hd0,6)/boot/grub/splash.xpm.gz
hiddenmenu
title Fedora Core (2.6.20-1.2944.fc6)
root (hd0,6)
kernel /boot/vmlinuz-2.6.20-1.2944.fc6 ro root=LABEL=/ rhgb quiet
initrd /boot/initrd-2.6.20-1.2944.fc6.img
title Fedora Core (2.6.18-1.2798.fc6)
root (hd0,6)
kernel /boot/vmlinuz-2.6.18-1.2798.fc6 ro root=LABEL=/ rhgb quiet
initrd /boot/initrd-2.6.18-1.2798.fc6.img
title Fedora Core (latest kernel(2.6.21))
root (hd0,6)
kernel /boot/new-bzImage ro root=LABEL=/ rhgb quiet
initrd /boot/new-ramdisk.img
title WindowsXp
rootnoverify (hd0,0)
chainloader +1
你是不是发现有两个文件:new-bzImage和new-ramdisk.img
我告诉你它们两个是怎么来的。
new-bzImage就是你make bzImage在你源代码文件下生成的bzImage,我改了名而已。
new-ramdisk.img是命令mkinitrd bzImage 生成的一个文件,我改了名。
你还要做的是把这两个东东放在/boot/下。
一切OK。
/*************************************************************/
以上废话太多,最简单的方法。
make
make install
2.6以后内核就可以这么干了,很方便。
/************************************************************/
grub里有很东西值得学习,你可以到google里看下grub详解。
我略说些。
new-ramdisk.img是个ram根文件系统,在PC机中,内核引导过程咋能没文件系统呢。而这文件系统显然不是硬盘实际上的根文件系统。这个小巧的文件系统里有内核引导所需的程序.比如加载你编译好的硬盘支持模块,命令,inmod。
PC机中,这玩意儿只是个过渡,会被实际文件系统取代。但没硬盘的嵌入式系统中,它就自始至终都耐在那儿了。
今晚就写到这里,我转载了一篇专门介绍RAM文件系统的。
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/37776/showart_307344.html |
|