新手指南 Linux编译内核操作流程(3)

比如我的Fedora core 4.0 所采用的文件系统用的是ext3 ,所以我要把它直接编入内核;好处是不受模块丢失或者损坏而不能启动系统;而有时您把系统所采用的文件系统编译成模块,出现VFS错误,也有这方面的事,可能是您没有把ext3加入到相应的加载模块的配置文件中,所以我们为了减少麻烦,把风险降到最低,还是要直接置入内模的好;
File systems --->
<*> Ext3 journalling file system support
[*] Ext3 extended attributes
[*] Ext3 POSIX Access Control Lists
[*] Ext3 Security Labels

如果您还有其它的硬盘分区要读取,比如是reiserfs、ext2、fat、fat32、ntfs等,这样的可以编成模块来支持;

再举一例:如果您的的操作系统用的是reiserfs的文件系统,当然就要把reiserfs的直接编入内核,其它的可以编成模块来支持了;


4)对于硬盘及RAID的支持,要直接编入内核;

比如ATA、SATA、SCSI及RAID的支持直接内核支持;有时编完内核后,启动时不能识别硬盘和RAID,大多事情出在这里;Slackware中在这方面有的是模块支持,我们可以把它由模块M改成内核*来支持;如果您不明白,就按默认进行;SATA的硬盘的支持除了选中SATA的支持、IDE设备的支持以外,还要选中SCSI的支持;

5)对于咱们所没有的设备,可以在内核中不选,熟能生巧罢了;

比如我没有ISDN设备 ,所以就把ISDN去掉;
ISDN subsystem --->
< > Linux telephony support

如果您没有1394的设备 ,当然可以把1394的支持也去掉;等等。。。。。。。

如果您有USB的设备,要把USB方面好好看看;比如大家常用的移动硬盘;USB猫等,还有扫描仪等;

内核配置就说这么多吧,太多了,我也说不清楚,水平有限啊;

配置好后先要保存

Save Configuration to an Alternate File

出来一个

Enter a filename to which this configuration ,should be saved as an alternate. Leave blank to abort.
.config

按回车就行了,这样就保存住了;

然后退出 Exit ,这时也会出现保存 ;

如果你想把.config保存起来,可以再复制一份到安全一点的目录,以备后用;

五、编译内核;

[root@localhost linux-2.6.12.3]# make
[root@localhost linux-2.6.12.3]# make modules_install

这样就编译好了,并把模块也安装在了 /lib/modules目录中了,请看:
[root@localhost linux-2.6.12.3]# ls /lib/modules/
2.6.11-1.1369_FC4 2.6.12.3


六、安装内核及配置grub或lilo ;


1、复制bzImage等相关文件,并创建initrd文件;

[root@localhost linux-2.6.12.3]# cp arch/i386/boot/bzImage /boot/vmlinuz-2.6.12.3
[root@localhost linux-2.6.12.3]# cp System.map /boot/System.map-2.6.12.3
[root@localhost linux-2.6.12.3]# cd /boot
[root@localhost linux-2.6.12.3]# /sbin/mkinitrd initrd-2.6.12.3.img 2.6.12.3

我们把 编译出来的bzImage,拷入到/boot目录,拷贝成 vmlinuz-2.6.12.3;
并且用 mkinitrd 来创建imitrd-xxx.img 文件,其中xxx为内核的版本号,是通过 查看 /lib/modules来版本来对应的,我们是编译出来的是 2.6.12.3,所以就运行上面的命令创建,创建的出来的是initrd-2.6.12.3.img ;不创建这个文件,有时是启动不起来的,比如提示VFS错误等;


2、查看系统引导管理器grub或者lilo的配置文件。

如果想要让新内核能让系统引导管理器grub和lilo的菜单上能看得到,必须改 grub.conf或者lilo.conf,但我们必须保留老内核的在grub和lilo的启动菜单,毕竟我们编内核不能百分百的成功,对不对??安全第一吧;

我只说grub的,我没有lilo,也不会用。所以咱们还是GRUB吧,FC 4 系统引导管理器是 GRUB,所以我们谈谈GRUB的设置;

查看 /etc/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,7)
# kernel /boot/vmlinuz-version ro root=/dev/hda8
# initrd /boot/initrd-version.img
#boot=/dev/hda
default=0
timeout=5
#splashimage=(hd0,7)/boot/grub/splash.xpm.gz
#hiddenmenu
title Fedora Core (2.6.11-1.1369_FC4)
        root (hd0,7)
        kernel /boot/vmlinuz-2.6.11-1.1369_FC4 ro root=LABEL=/ rhgb quiet
        initrd /boot/initrd-2.6.11-1.1369_FC4.img
title WinXP
        rootnoverify (hd0,0)
        chainloader +1

我们要把老内核的启动保留下来,以防不测,我们只加入新的内核的启动;所以我加上这样一段;

title Fedora Core (2.6.12.3)
root (hd0,7)
kernel /boot/vmlinuz-2.6.12.3 ro root=LABEL=/ rhgb quiet
initrd /boot/initrd-2.6.12.3.img

咱们再来看一下改过后的配置文件;

# 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,7)
# kernel /boot/vmlinuz-version ro root=/dev/hda8
# initrd /boot/initrd-version.img
#boot=/dev/hda
default=0
timeout=5
#splashimage=(hd0,7)/boot/grub/splash.xpm.gz
#hiddenmenu
title Fedora Core (2.6.12.3)
        root (hd0,7)
        kernel /boot/vmlinuz-2.6.12.3 ro root=LABEL=/ rhgb quiet
        initrd /boot/initrd-2.6.12.3.img
title Fedora Core (2.6.11-1.1369_FC4)
        root (hd0,7)
        kernel /boot/vmlinuz-2.6.11-1.1369_FC4 ro root=LABEL=/ rhgb quiet
        initrd /boot/initrd-2.6.11-1.1369_FC4.img
title WinXP
        rootnoverify (hd0,0)
        chainloader +1

然后重新启动机器,如果出现VFS错误,可能就是我写重要的那个地方出了错误;

注意:如果重新启用内核后,原来安装的显示卡驱动,比如 NVIDIA和ATI的驱动还要重新安装

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wwpfys.html