linux内核配置与编译,LINUX内核的配置与编译、安装

LINUX内核的配置与编译、安装

平台为VM RHEL 5.1 SERVER,所用的内核为linux-2.6.25。

可以到上下载相应的内核版本。

解压压缩包,并进入内核目录。下面是具体的步骤:

1、找到你要参考的配置文件,如:/boot/config-2.6.18-53.e15

[root@localhost linux-2.6.25]# cp /boot/config-2.6.18-53.el5 /home/suruiqin/linux-2.6.25/.config

也可使用默认的配置文件

2、配置内核

[root@localhost linux-2.6.25]#make menuconfig

3、编译内核

[root@localhost linux-2.6.25]# make bzImage

或者:make zImage

区别:在X86平台,zImage只能用于小于512K的内核

如需获取详细的编译信息,可使用:

make zImage V=1

make bzImage V=1

编译好的内核位于arch//boot/目录下

4、编译内核模块

[root@localhost linux-2.6.25]# make modules

5、安装内核模块

[root@localhost linux-2.6.25]#make modules_install

执行这个命令后,将编译好的内核模块从内核源代码目录copy至/lib/modules下

6、制作init ramdisk

注:要进入要编译的内核文件目录下

mkinitrd initrd-$version $version

例:

[root@localhost linux-2.6.25]# cd /home/suruiqin/linux-2.6.25

[root@localhost linux-2.6.25]# mkinitrd initrd-2.6.25 2.6.25

*** $version可以通过查询/lib/modules下的目录得到

7、内核安装(X86平台)

1)cp arch/x86/boot/bzImage /boot/vmlinuz-$version

如:

[root@localhost linux-2.6.25]# cp arch/x86/boot/bzImage /boot/vmlinuz-2.6.25

***$version为所编译的内核版本号

2)cp $initrd /boot/

如:

[root@localhost linux-2.6.25]# cp initrd-2.6.25 /boot

3)修改 /etc/grub.conf或 /etc/lilo.conf

如:

[root@localhost ~]# gedit /etc/grub.conf

# grub.conf generated by anaconda

#

# Note that you do not have to rerun grub after making changes to this file

# NOTICE:You have a /boot partition.This means that

#all kernel and initrd paths are relative to /boot/, eg.

#root (hd0,0)

#kernel /vmlinuz-version ro root=/dev/sda2

#initrd /initrd-version.img

#boot=/dev/sda

default=0

timeout=5

splashp_w_picpath=(hd0,0)/grub/splash.xpm.gz

hiddenmenu

title Red Hat Enterprise Linux Server (2.6.18-53.el5)

root (hd0,0)

kernel /vmlinuz-2.6.18-53.el5 ro root=LABEL=/ rhgb quiet

initrd /initrd-2.6.18-53.el5.img

title Red Hat Enterprise Linux Server (2.6.25)

root (hd0,0)

kernel /vmlinuz-2.6.25 ro root=LABEL=/ rhgb quiet

initrd /initrd-2.6.25

注:红色部分就是为启动刚才自己做的内核而加上的

到这步时按回车,出现下面的选项:

a3ce0745b064ee09d86629e125bf8f7a.png

选择第二个启动,即刚才做的内核。

de6451dd78af6010c2e9b4276a3d79da.png

新建一个终端:

[root@localhost ~]# uname -a

Linux localhost.localdomain2.6.25 #1 SMP Mon Jun 4 05:26:03 PDT 2012 i686 i686 i386 GNU/Linux

OK。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值