linux内核源码合并升级,Linux内核升级
Linux內核升級
發布時間:2007-09-19 09:31:02來源:紅聯作者:fortemedia
自己想升級一下linux的內核,原來的版本是linux-2.6.18,下載的內核源碼版本是linux-2.6.22,參考了網上的一些資料,試著升級了一下,過程如下:
備份以下這些文件可以在系統發生錯誤或崩潰時,能較快速的恢復系統原來的狀態。
1、備份內核和啟動文件
# cd /
# tar cvzf boot.tar.gz boot
2、備份系統函數頭文件
# cd /usr/include
# tar cvzf linux.tar.gz linux
3、備份模塊中的庫文件
# cd /lib/modules
# tar cvzf 2.4.7-10.tar.gz 2.4.7-10
# tar cvzf 2.4.7-10debug.tar.gz 2.4.7-10debug
4、備份linux源碼
# cd /usr/src
# tar cvzf linux-2.4.7-10.tar.gz linux-2.4.7-10
# tar cvzf linux-2.4.7-10debug.tar.gz linux-2.4.7-10debug
5、備份重要配置目錄
# cd /
# tar cvzf etc.tar.gz etc
下載linux-2.6.22.tar.bz2(可以是更新的版本)到/usr/src
tar -jxvf linux-2.6.22.tar.bz2 //解壓源代碼
cd linux-2.6.3 //進入源代碼目錄
閱讀頂層目錄下的Readme文件和Documentation下的Changes文件,確認必須的工具軟件。
例如發現module-init-tools需要更新。
升級module-init-tools軟件包
要編譯與正常運行新的內核你需要升級一些軟件包,這些信息在源碼目錄下的Documentation/Changes文件中,請根據你的實際情況選擇升級。
特別要說明的是,因為2.4.x下的modutils工具包已經不在適合新的2.6.x內核, 必需將其升級到module-init-tools工具包.,我下載module-init-tools-3.2.2.tar.bz2源碼包。
安裝module-init-tools. 它會替代depmod [/sbin/depmod]和其他工具.
tar -jxvf module-init-tools-3.0.tar.bz2
cd module-init-tools-3.0
./configure --prefix=/sbin
# make moveold
# make all install
# ./generate-modprobe.conf /etc/modprobe.conf
命令"make moveold"將把系統原來的modutils工具程序改名為"*.old"(比如,lsmod.old等等). NOTE! 這是非常重要的一步, 千萬不要省略. 如果你以前的系統是linux2.4內核,這將使得你可以繼續使用原有的linux-2.4.x系統, 因為在2.4.x系統下, 新的module-init-tools工具包實際上是倚賴原來"*.old"程序來加載內核模塊. 如果忘記了這一步也不要緊張, 可以先下載并安裝原來的modutils程序包, 然后按照上面的步驟重來一遍就可以了.新的module-init-tools工具包不再使用原來的/etc/modules.conf配置文件了, 而是使用新的配置文件/etc/modprobe.conf. 因此必需用命令"./generate-modprobe.conf /etc/modprobe.conf"來生成新的配置文件/etc/modprobe.conf.
安裝modutils-2.4.21-23.src.rpm. 你可能會看到"user rusty and group rusty not existing"的警告. 沒關系,你只需強制安裝就是了.如果你不對Redhat 9和Redhat 8做這幾步, 你將會在"make modules_install"這一步時出現問題.
rpm -i modutils-2.4.25-1.src.rpm
rpmbuild -bb /usr/src/redhat/SPECS/modutils.spec
rpm -Fi /usr/src/redhat/RPMS/i386/modutils-2.4.25-1.i386.rpm
這步的具體作用還沒有搞懂。
編譯Linux內核
cd /usr/src/linux-2.6.22
make menuconfig
輸入以上命令后出現一個菜單界面,用戶可以對需要的模塊.下面著重講幾個重要的配置:
1)文件系統
請務必要選中ext3文件系統,
File systems--->
[*] Ext3 journalling file system support
[*] Ext3 Security Labels
[*] JBD (ext3) debugging support
以上三項一定要選上,而且要內建(即標*). 這個非常重要,在配置完后一定要檢查一下.config文件有沒有"CONFIG_EXT3_FS=y"這一項. 如果不是"CONFIG_EXT3_FS=y"而是"CONFIG_EXT3_FS=m",你在運行內核時就會遇上以下錯誤: pivotroot: pivot_root(/sysroot,/sysroot/initrd) failed
2)網卡驅動
請務必把自己網卡對應的驅動編譯進內核,比較普遍的網卡是realtek 8139,以下就是這種網卡的配置,以供參考
Device Drivers--->
Networking support--->
Ethernet (10 or 100Mbit) --->
RealTek RTL-8139 C+ PCI Fast Ethernet Adapter support (EXPERIMENTAL)
RealTek RTL-8139 PCI Fast Ethernet Adapter support
3)聲卡驅動
也要選擇自己聲卡對應的驅動編譯進內核,比較普遍的聲卡是i810_audio,以下就是這種聲卡的配置,以供參考
Device Drivers --->
Sound --->
Sound card support
Advanced Linux Sound Architecture --->
Advanced Linux Sound Architecture
Sequencer support
< > Sequencer dummy client
OSS Mixer API
OSS PCM (digital audio) API[*] OSS Sequencer API
RTC Timer support
PCI devices --->
Intel i8x0/MX440, SiS 7012; Ali 5455; NForce Audio; AMD768/8111
Open Sound System --->
< > Open Sound System (DEPRECATED)
以上三項配置關系到新內核能否正常運行,請備加注意.其他的配置如果不是很了解,大可以按默認的選擇.
也可以執行make oldconfig,對kernel2.6新增的不熟悉的選項作不選或為缺省。
make bzImage
make modules
make modules_install
pwd
/usr/src/linux-2.6.22
mv arch/i386/boot/bzImage /boot/vmlinuz-2.6.22
mv System.map /boot/System.map-2.6.22
cd /boot
mv System.map oldSystem.map
ln -s System.map-2.6.22 System.map
修改grub配置文件
下面的配置可作參考
# 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,6)
# kernel /vmlinuz-version ro root=/dev/hda10
# initrd /initrd-version.img
#boot=/dev/hda
default=1
timeout=5
splashimage=(hd0,6)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Linux (2.6.22)
root (hd0,6)
kernel /vmlinuz-2.6.22 ro root=/dev/hd0
initrd /initrd-2.6.22.img
title Fedora Core (2.6.18-1.2798.fc6)
root (hd0,6)
kernel /vmlinuz-2.6.18-1.2798.fc6 ro root=LABEL=/1 rhgb quiet
initrd /initrd-2.6.18-1.2798.fc6.img
title Windows XP
rootnoverify (hd0,0)
chainloader +1
總結
以上是生活随笔為你收集整理的linux内核源码合并升级,Linux内核升级的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 学会清除上网记录,防范于千里之外
- 下一篇: 凸轮结构c语言编程,凸轮设计_c语言编程