Linux 2.6 内核编译行记
(1)下载最新稳定版本的kernel,当前为2.6.15.4。
$ cd /usr/src $ wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.15.4.tar.gz $ gzip -dc linux-2.6.15.4.tar.gz | tar xvf - $ cd linux-2.6.15.4 $ more README
我们先读读README,安装任何新软件前读读README或者INSTALL是个好习惯,往往很多重要的信息都在这里。
根据README我们可知,Documentation子目录包含了更为详细的文档,Documentation/00-INDEX是其列表。安装完后,可运行make psdocs, make pdfdocs, make htmldocs把Documentation/DocBook/目录格式化成PostScript(.ps)、PDF或者HTML等形式的文档,这部分文档包含了很多内核开发和用户使用指南。
此外,它还说明了如何给内核打补丁,如何指定源码和编译输出为不同的目录,如何编译安装内核。需要注意的是不要去改动/usr/src/linux的内容, 它指向当前内核库的头文件。
(2) 配置安装选项
首先确保源码目录中没有遗留的.o文件。
make mrproper
有很多种配置方式。
"make config" 基于命令行提示
"make menuconfig" Text based color menus, radiolists & dialogs.
"make xconfig" X windows (Qt) based configuration tool.
"make gconfig" X windows (Gtk) based configuration tool.
"make oldconfig" Default all questions based on the contents of
your existing ./.config file.
"make silentoldconfig"
Like above, but avoids cluttering the screen
with questions already answered.
编译内核最麻烦的就在于选择内核模块和特征,慢慢摸索吧,可参考你当前机器的配置,比如/etc/modules.conf。
(3) 保存当前系统
$ cp -af /lib/modules /lib/modules.bak $ cp -af /boot /boot.bak $ cp -af /etc/lilo.conf /etc/lilo.conf.bak
(4) 编译内核
$ make clean $ make bzImage $ make modules $ make modules_install $ depmod -a # 建立模块之间的依赖关系
在比较老的内核中,需要make dep来生成源文件的以来关系,不过现在已经不再需要了。
(5) 配置新内核
$ cp arch/i386/boot/bzImage /boot/vmlinuz-2.6.15.4 $ cp System.map /boot/System.map-2.6.15.4 $ ln -sf /boot/vmlinuz-2.6.15.4 /boot/vmlinuz $ ln -sf /boot/System.map-2.6.15.4 /boot/System.map $ mkinitrd /boot/initrd-2.6.15.4.img 2.6.15.4
然后配置/etc/lilo.conf,参照原有配置加上新内核,并执行如下命令更新启动程序:
$ lilo -v -v -v $ sync;sync;sync $ shutdown -r now
如果你的开机程序是grub,则需要修改grub.conf文件。
本文详细介绍了Linux 2.6内核的编译过程,包括下载最新稳定版本、配置安装选项、编译内核及配置新内核等步骤,并提供了实用的技巧建议。
3888

被折叠的 条评论
为什么被折叠?



