您的位置:首页 > 其它

编译安装新内核

2013-06-22 01:02 127 查看
编译安装新内核

一: 内核下载:

内核的官网是:https://www.kernel.org
这里下载内核的版本是linux-2.6.30.10

[root@localhost ~]# wget https://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.30.10.tar.bz2[/code] 
二: 准备工作:
需要安装gcc编译工具、make编译器;并且编译内核时需使用root用户进行。

三: 操作步骤:
编译安装新内核的步骤为:

1:将下载的安装包解压到/usr/src目录

2:为内核目录创建连接。

3:配置内核 #make menuconfig
4:编译内核 #make
5:安装,包括模块安装和内核安装
6:重启系统,选用新内核

四: 实现过程:

[root@localhost ~]# tar xvf linux-2.6.30.10.tar.bz2 /usr/src/
root@localhost ~]# cd /usr/src/
[root@localhost ~]# ln -sv linux-2.6.30.10/ linux
[root@localhost ~]# cd linux
[root@localhost ~]# make menuconfig
//会打开一个基于文本的窗口,在里面可以启用或者关闭某个功能:
//        [ ]:不启用此项
//        [*]:直接编译进内核  (使用时方便,但一些不常用的功能会占用内核空间)
[M]:编译成模块            (使用时要动态装载,效率低)


此文本窗口如下,可根据自己的需求选择行的选取,如果对各个功能不是很了解,可以在网上查一下:





[root@localhost ~]# make     //这一步骤时间会稍长
[root@localhost ~]# make modules
[root@localhost ~]# make modules_install
[root@localhost ~]# make install


至此,内核编译完成,要想使用新内核,需要重启系统,并选用新内核。





补充:
1:执行完make menuconfig之后,会在执行命令的目录里生成一个隐藏文件:.config,此文件就是内核的配置信息。

[root@localhost linux]# pwd
/usr/src/linux
[root@localhost linux]# ls -a | grep .config
.config
在配置内核时,如果不是很清楚各项字段的意义,且感觉配置比较复杂,可以复制当前正在使用的内核的.config文件到/usr/src/linux目录下,然后执行make menuconfig命令,配置一下即可。

2:执行完make install之后会自动在grub.conf中新增一个内核启动选项:

[root@localhost ~]# cat /boot/grub/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,0)
#          kernel /boot/vmlinuz-version ro root=/dev/sda1
#          initrd /boot/initrd-version.img
#boot=/dev/sda
default=1
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.30.10asange)
root (hd0,0)
kernel /boot/vmlinuz-2.6.30.10asange ro root=LABEL=/ rhgb quiet
initrd /boot/initrd-2.6.30.10asange.img
title Red Hat Enterprise Linux Server (2.6.18-164.el5)
root (hd0,0)
kernel /boot/vmlinuz-2.6.18-164.el5 ro root=LABEL=/ rhgb quiet
initrd /boot/initrd-2.6.18-164.el5.img
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  安装 编译 新内核