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
注:紅色部分就是為啟動剛才自己做的內核而加上的
到這步時按回車,出現下面的選項:
選擇第二個啟動,即剛才做的內核。
新建一個終端:
[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。
總結
以上是生活随笔為你收集整理的linux内核配置与编译,LINUX内核的配置与编译、安装的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 5999 元!石头分子筛洗烘一体机 H1
- 下一篇: 电路原理图基本知识概述(转)