码迷,mamicode.com
首页 > 其他好文 > 详细

内核编译

时间:2014-10-13 03:22:59      阅读:307      评论:0      收藏:0      [点我收藏+]

标签:linux内核编译

编译内核的一般步骤

    1、下载内核源码 www.kernel.org

    2、解压内核文件到指定目录, /usr/src

    3、选择所需功能 make menuconfig

    4、选择完成后进行编译 make

    5、安装模块 make modules_install

    6、安装内核 make install



# 解压软件包,并移动到/usr/src下,制作一个软连接

[root@localhost ~]# tar xf linux-2.6.29.tar.bz2 -C /usr/src/

[root@localhost ~]# cd /usr/src/

[root@localhost src]# ln -s linux-2.6.29 linux

[root@localhost src]# 


# 为了选择方便,复制系统上的内核配置文件,到新版本的源码目录下

# 并重命名为.config

[root@localhost ~]# cd /usr/src/linux

[root@localhost linux]# cp /boot/config-2.6.18-308.el5 ./.config

[root@localhost linux]# 

[root@localhost linux]# make menuconfig

  HOSTCC  scripts/basic/fixdep

  HOSTCC  scripts/basic/docproc

  HOSTCC  scripts/basic/hash

  HOSTCC  scripts/kconfig/conf.o

  HOSTCC  scripts/kconfig/kxgettext.o

  HOSTCC  scripts/kconfig/lxdialog/checklist.o

  HOSTCC  scripts/kconfig/lxdialog/inputbox.o

  HOSTCC  scripts/kconfig/lxdialog/menubox.o

  HOSTCC  scripts/kconfig/lxdialog/textbox.o

  HOSTCC  scripts/kconfig/lxdialog/util.o

  HOSTCC  scripts/kconfig/lxdialog/yesno.o

  HOSTCC  scripts/kconfig/mconf.o

  SHIPPED scripts/kconfig/zconf.tab.c

  SHIPPED scripts/kconfig/lex.zconf.c

  SHIPPED scripts/kconfig/zconf.hash.c

  HOSTCC  scripts/kconfig/zconf.tab.o

  HOSTLD  scripts/kconfig/mconf

scripts/kconfig/mconf arch/x86/Kconfig

.config:685:warning: symbol value ‘m‘ invalid for IP_DCCP_CCID3

.config:686:warning: symbol value ‘m‘ invalid for IP_DCCP_TFRC_LIB

.config:1430:warning: symbol value ‘m‘ invalid for FIXED_PHY

.config:1743:warning: symbol value ‘m‘ invalid for ISDN

.config:2886:warning: symbol value ‘m‘ invalid for RTC_INTF_SYSFS

.config:2887:warning: symbol value ‘m‘ invalid for RTC_INTF_PROC

.config:2888:warning: symbol value ‘m‘ invalid for RTC_INTF_DEV

.config:2910:warning: symbol value ‘m‘ invalid for DMA_ENGINE

#

# configuration written to .config

#



*** End of Linux kernel configuration.

*** Execute ‘make‘ to build the kernel or try ‘make help‘.


[root@localhost linux]# 

bubuko.com,布布扣


# 执行make进行编译

[root@localhost linux]# make

    .......

    IHEX2FW firmware/keyspan_pda/keyspan_pda.fw

    IHEX2FW firmware/keyspan_pda/xircom_pgs.fw

    H16TOFW firmware/vicam/firmware.fw

    IHEX    firmware/cpia2/stv0672_vp4.bin

[root@localhost linux]# 



# 执行make modules_install 编译模块

[root@localhost linux]# make modules_install

    INSTALL /lib/firmware/mts_edge.fw

    MKDIR   /lib/firmware/edgeport

    INSTALL /lib/firmware/edgeport/boot.fw

    INSTALL /lib/firmware/edgeport/boot2.fw

    INSTALL /lib/firmware/edgeport/down.fw

    INSTALL /lib/firmware/edgeport/down2.fw

    INSTALL /lib/firmware/edgeport/down3.bin

    INSTALL /lib/firmware/whiteheat_loader.fw

    INSTALL /lib/firmware/whiteheat.fw

    MKDIR   /lib/firmware/keyspan_pda

    INSTALL /lib/firmware/keyspan_pda/keyspan_pda.fw

    INSTALL /lib/firmware/keyspan_pda/xircom_pgs.fw

    MKDIR   /lib/firmware/vicam

    INSTALL /lib/firmware/vicam/firmware.fw

    MKDIR   /lib/firmware/cpia2

    INSTALL /lib/firmware/cpia2/stv0672_vp4.bin

    DEPMOD  2.6.29

[root@localhost linux]# 


# 最后执行 make  install

[root@localhost linux]# make install



# 修改grub.conf 配置文件启动新的内核

[root@localhost linux]# vi /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 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

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

hiddenmenu

title Red Hat Enterprise Linux Server (2.6.29)

        root (hd0,0)

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

        initrd /initrd-2.6.29.img

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

        root (hd0,0)

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

        initrd /initrd-2.6.18-308.el5.img

[root@localhost linux]# 



# 查看系统内核版本

[root@localhost ~]# uname -r

2.6.29

[root@localhost ~]# uname -a

Linux localhost.localdomain 2.6.29 #1 SMP Sun Oct 12 22:00:26 CST 2014 i686 i686 i386 GNU/Linux

[root@localhost ~]# 



内核编译

标签:linux内核编译

原文地址:http://fangyu.blog.51cto.com/4883282/1563047

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!