Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4607
  • 博文数量: 1
  • 博客积分: 1516
  • 博客等级: 上尉
  • 技术积分: 20
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-08 17:43
文章分类
文章存档

2011年(1)

我的朋友
最近访客

分类: LINUX

2011-09-26 14:44:09

抬头看钟已经0点45分了,早上12点45起床,在可以写出这篇文章之前,自己努力了12个小时,总算有了让自己满意的结果。看到登录界面的那一刻,人突然变得很累,但感觉很好,今天似乎让我对Linux有了更多的认识。我想说的是自己编译Linux内核的经历。

  我的台式机用的是Debian 6,用 # uname -r 查看原本使用的kernel版本是2.6.32-5-686,现在我想做的是使用版本2.6.39的kernel来代替2.6.32-5-686。首先是 去下载linux-2.6.39.tar.bz2 到 /home/wzj/Download/ 文件夹中,然后解压到 /usr/src 中 # tar -xvjz linux-2.6.39.tar.bz2 -C /usr/src 于是在 /usr/src/下面就会出现一个linux-2.6.39文件夹

  接下来做的是配置内核(Configure kernel)。网上说是使用 # make menuconfig 这条命令,只是好像在我的机器上用不了,出现了

make[2]: *** [scripts/lxdialog/checklist.o]
make[1]: *** [menuconfig] Error 2
make: *** [menuconfig] Error 2

的 错误,google一下,发现在我的debian 机器上 ncurses-dev 这个软件包没有被安装,于是 # aptitude install ncurses-dev 接下来 # make menuconfig就可以正常使用了。配置完 kernel 之后的文件被保存为.config文件。

  然后就是 # make 这一下花去了我将近3个小时时间,要知道其中大部分时间都是花在编译驱动程序上。不过很好,编译到中途,自己也放松一下,出去游了1个小时泳,做了一个咖喱鸡,就好了。

  接下来是编译模块 # make modules

  接着是安装模块 # make modules_install

  最后是安装内核 # make install

  这时候在我的 /boot文件夹下出现了三个文件 config-2.6.39 System.map-2.6.39 vmlinuz-2.6.39

  关于这几个文件我也只能给出几个链接,要说明它们实在是太长了,

  1.System.map

 

  2.vmlinuz

  3.bzImage

 

  下面这些话很有意思

 (1)What Happens If I Don't Have A Healthy System.map?

Suppose you have multiple kernels on the same machine. You need a separate System.map file for each kernel. If you run a kernel with no (or an incorrect) System.map, you'll periodically see annoying warnings like:

  System.map does not match actual kernel

  everytime you use ps. Also, your klogd or ksymoops output will not be reliable in case of a kernel oops.

  (2)vmlinuz is the name of the executable. vmlinuz is a compressed Linux kernel, and it is bootable.

  (3) As the Linux kernel matured, the size of the kernels generated by users grew beyond the limits imposed by some architectures, where the space available to store the compressed kernel code is limited.

  The bzImage (big zImage) format was developed to overcome this limitation by cleverly splitting the kernel over discontiguous regions.

  总之想要了解这些文件的关系必需要自己亲眼看到它们在眼前产生才会有去了解它们的想法吧。

  在接下来的过程中,网上说用 # mkinitrd -o initrd.img-2.6.39 2.6.39 来创建initrd.img-2.6.39文件,但我发现根本没有,我的命令行中没有 mkinitrd这个命令。在一遍一遍的纠结中在下面这篇贴子中找到了答案

使用 mkinitramfs -o /boot/initrd.img-2.6.39 2.6.39就解决问题了。下面这个link会提供一些背景知识

  好了最后就是grub了,因为我是 grub 1.98版本,所以没有 menu.lst这个文件,但是最后发现我要做的其实只有一个命令, # update-grub就自动重新创建了 /boot/grub/grub.cfg这个文件了。

  好了,写到这里就结束了,最后 # shutdown -r now 重启计算机,选择那个2.6.39,所有东西也就水到渠成了。

  其实自己对于Linux的boot process 还远远不够,慢慢来吧,一步一步
阅读(309) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:没有了

给主人留下些什么吧!~~