[原創]Fedora5編譯升級核心版本(更新完畢)

仙果發表於2009-08-06
作者:仙果
宣告:本文系原創,轉載請註明出處
開始:
      因工作需要,需要升級linux核心版本,系統為Fedora5 ,核心版本為2.6.15,需要升級為2.6.20,這個過程大概花了一個星期的時間,從一點不瞭解linxu核心,到升級成功,也經歷了不少困難,都是從google上搜尋得來的。以下是整個過程
      一。安裝linux虛擬機器
      linux虛擬機器版本為Fedora5 ,核心版本為2.6.15,從網路上下載得來,大小為3.02 GB ,下載地址好像找不到了,大家去可以google搜尋,就是下載需要花費點時間
    安裝過程沒什麼需要注意的地方,大家按照正常安裝過程即可安裝完畢,下圖是安裝過程中的介面:

[原創]Fedora5編譯升級核心版本(更新完畢)

正在安裝中ing
以下圖片是是安裝完成並顯示核心版本
[原創]Fedora5編譯升級核心版本(更新完畢)

二。下載核心原始碼
       下載地址為:http://archives.fedoraproject.org/pub/archive/fedora/linux/core/updates/5/SRPMS/
有很多選項,找到2.6.20,
kernel-2.6.20-1.2320.fc5.src.rpm                   21-Jun-2007 18:48   45M  RPM Package
大小為45M,貌似還有點大
三。安裝。。。重要
[shabi004@localhost ~]$ su root
口令:
[root@localhost shabi004]# cd Desktop/
[root@localhost Desktop]# ls
kernel-2.6.20-1.2320.fc5.src.rpm
[root@localhost Desktop]# rpm -ivh kernel-2.6.20-1.2320.fc5.src.rpm


出現提示:
warning: group brewbuilder does not exist - using root

不用理會,繼續即可。
[root@localhost Desktop]# cd ..
[root@localhost shabi004]# cd ..
[root@localhost home]# cd ..
[root@localhost /]# cd usr/src/redhat/
[root@localhost redhat]# ls
BUILD  RPMS  SOURCES  SPECS  SRPMS
[root@localhost redhat]# cd SPECS
[root@localhost SPECS]# ls
kernel-2.6.spec
[root@localhost SPECS]# rpmbuild -bp --target i686 kernel-2.6.spec

這個過程大概會持續10分鐘的樣子,依照計算機配置而定,檢視的話會發現有一些警告,不用理會,繼續即可

[root@localhost SPECS]# cd ..
[root@localhost redhat]# cd BUILD/
[root@localhost BUILD]# ls
kernel-2.6.20
[root@localhost BUILD]# cd kernel-2.6.20/
[root@localhost kernel-2.6.20]# ls
Config.mk  linux-2.6.20.i686  vanilla  xen
[root@localhost kernel-2.6.20]# cd linux-2.6.20.i686/
[root@localhost linux-2.6.20.i686]# ls
arch     CREDITS        fs       Kbuild       Makefile  REPORTING-BUGS  usr
block    crypto         include  kernel       mm        scripts
configs  Documentation  init     lib          net       security
COPYING  drivers        ipc      MAINTAINERS  README    sound
[root@localhost linux-2.6.20.i686]#


接下來就是最重要的,配置核心,命令是
make menuconfig

會彈出一個GUI選框,你可以選擇核心支援模組,比如CPU,網路卡,檔案系統型別,驅動等等許多內容,具體設定依照硬體環境進行設定,我會把一些有用的資料以附件的形式發在文後。
如圖所示:
[原創]Fedora5編譯升級核心版本(更新完畢)
出現:
  │ │        Load an Alternate Configuration File                         │ │
  │ │        Save an Alternate Configuration File  


在這個地方進行儲存,儲存配置好的核心模組等等
接下來,會出現
.config介面,ENTER 回車,按OK即可
exit 退出 核心配置介面

[root@localhost linux-2.6.20.i686]# make menuconfig
  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
  HOSTLD  scripts/kconfig/mconf
scripts/kconfig/mconf arch/i386/Kconfig


*** End of Linux kernel configuration.
*** Execute 'make' to build the kernel or try 'make help'.

開始下一步,需要使用到的命令是

make dep
make
make bzImage
make modules
make modules_install
make install

其中:
第一個命令make dep實際上讀取配置過程生成的配置檔案,來建立對應於配置的依賴關係樹,從而決定哪些需要編譯而那些不需要;make zImage和make bzImage則實現完全編譯核心,二者生成的核心都是使用gzip壓縮的,只要使用一個就夠了,它們的區別在於使用make bzImage可以生成大一點的核心。建議大家使用make bzImage命令。

  後面三個命令只有在你進行配置的過程中,在回答Enable loadable module support (CONFIG_MODULES)時選了"Yes"才是必要的,make modules和make modules_install分別生成相應的模組和把模組拷貝到需要的目錄中

使用make這個命令的時候,花費的 時間比較長,需要耐心等待,中間會產生一些警告資訊,不用理會即可
執行到
[root@localhost linux-2.6.20.i686]# make install
sh /usr/src/redhat/BUILD/kernel-2.6.20/linux-2.6.20.i686/arch/i386/boot/install.sh 2.6.20-prep arch/i386/boot/bzImage System.map "/boot"


這裡好像核心已經升級完畢了,由於Fedora5是有Grub引導的,需要確認下
使用命令如下:
[root@localhost shabi004]# cd ..
[root@localhost home]# cd ..
[root@localhost /]# cd boot
[root@localhost boot]# ls
config-2.6.15-1.2054_FC5      System.map-2.6.15-1.2054_FC5
grub                          System.map-2.6.20-prep
initrd-2.6.15-1.2054_FC5.img  vmlinuz
initrd-2.6.20-prep.img        vmlinuz-2.6.15-1.2054_FC5
lost+found                    vmlinuz-2.6.20-prep
System.map
[root@localhost boot]# cd grub
[root@localhost grub]# ls
device.map     grub.conf         minix_stage1_5     stage2
e2fs_stage1_5  iso9660_stage1_5  reiserfs_stage1_5  ufs2_stage1_5
fat_stage1_5   jfs_stage1_5      splash.xpm.gz      vstafs_stage1_5
ffs_stage1_5   menu.lst          stage1             xfs_stage1_5
[root@localhost grub]# vi grup.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/VolGroup00/LogVol00
#          initrd /initrd-version.img
#boot=/dev/sda
default=1
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Fedora Core (2.6.20-prep)
        root (hd0,0)
        kernel /vmlinuz-2.6.20-prep ro root=/dev/VolGroup00/LogVol00 rhgb quiet
        initrd /initrd-2.6.20-prep.img
title Fedora Core (2.6.15-1.2054_FC5)
        root (hd0,0)
        kernel /vmlinuz-2.6.15-1.2054_FC5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
        initrd /initrd-2.6.15-1.2054_FC5.img
~
"grub.conf" 21L, 770C


關於其中的解釋,由於自己的水平有限,也解釋不清楚,還請大家去google下就可以得到完整答案。這裡我只說自己懂得:
title Fedora Core (2.6.20-prep): 核心啟動版本
root (hd0,0):hd*表示第幾個硬碟,比如本例就是第一塊硬碟,後面的*表示所第一個分割槽,本例為第一塊一硬碟,第一個分割槽。

現在重啟系統,在重啟時按任意鍵進入grub引導介面
如圖:
[原創]Fedora5編譯升級核心版本(更新完畢)

選擇對應的2.6.20進入系統
[shabi004@localhost Desktop]$ uname -a
Linux localhost 2.6.20-prep #1 Thu Aug 6 17:39:48 CST 2009 i686 i686 i386 GNU/Linux


到此:此次升級核心算是完成了。

四:總結:完成核心升級的過程算是經過千辛萬苦,自己也是小白中的菜鳥,在牛人看來無非就是幾行命令,對自己來說就是很難了,總結下整個過程,學到了很多東西,最起碼得到的是不在對linux系統存在有恐懼感,下一步自己的目標就是除錯,自己一定能夠成功!

附:在這個過程中自己在網上查詢了一些資料,以附件的方式發上來,以備像我這樣的菜鳥來查閱!
上傳的附件:

相關文章