我使用的是64位的redhat 5.4 版本是2.6.18系統一 準備工作(下載核心升級工具及核心源碼)
1.下載linux-3.9.6源碼。地址是:http://www.linux-mips.org/pub/linux/mips/kernel/v3.x/
2.下載module-init-tools。(我使用的是module-init-tools-3.10.tar.bz2,:https://www.kernel.org/pub/linux/utils/kernel/module-init-tools/)
3.lvm2-2.02.46-8.el5.x86_64.rpm;
mkinitrd-5.1.19.6-54.x86_64.rpm;
device-mapper-1.02.32-1.el5.x86_64.rpm(這三個可以在你光碟片的server檔案下面找到)
二 配置工作
1.將下載好的核心原始碼和工具都放到/usr/src檔案夾下。
2.拷貝完畢,開始解壓新核心,具體操作請依次執行以下命令;
# cd /usr/src(進入/usr/src目錄,如果已經在/usr/src目錄,可不執行該命令)
# rm –rf linux(刪除linux檔案夾,如果核心以前從未編譯過,則沒有這個檔案夾,可不執行該命令)
# tar jvxf linux-3.9.6.tar.bz2(解壓新核心)
# ln -s linux-3.9.6linux(重建linux檔案夾)
3.安裝module-init-tools工具,在/usr/src目錄下,依次執行下列命令;
# tar jvxf module-init-tools-3.10.tar.bz2(解壓module-init-tools)
# cd module-init-tools-3.10(由/usr/src目錄進入module-init-tools目錄)
#./configure--prefix=/
# make moveold
# make allinstall
#./generate-modprobe.conf/etc/modprobe.conf
4.安裝另外三個升級工具,回到/usr/src目錄下,依次執行下列命令;
# rpm -ivh--nodeps mkinitrd-4.1.18-2.i386.rpm
# rpm -ivh--nodeps lvm2-2.00.25-1.01.i386.rpm
# rpm -ivh--nodeps device-mapper-1.00.19-2.i386.rpm
如果不更新以上幾個升級包,後面編譯核心時會提示以下錯誤;
mkinitrd failed
make[1]; *** [install] Error 1
make; *** [install] Error 2
5. 配置核心選項
# cdlinux-2.6.18(進入/usr/src/linux-2.6.18目錄)
# makemrproper(確保原始碼目錄下沒有不正確的.o檔案)
#make menuconfig(配置核心選項,這裡我使用的是以前的設定檔,命令是 :
cp/boot/config-2.6.18-164.el5 ./.config,然後輸入命令makemenuconfig選擇load檔案:.config)
此時會出現一個圖形介面,列出了所有的核心配置選項,有的選項下還有子選項,可以用方向鍵選擇,用Y鍵確定,大多數選項預設就行,以下幾個選項必須選擇(這裡必須認真選擇不然會出錯。編譯也就不能成功)
(1) Loadable Module support中選上"Moduleunloading"和"Automatic kernel module loading"
(2) Device Drivers--->Block Devices中選上"Loopbackdevice support";
DeviceDrivers--->Multi-device support(RAID and LVM)中選上"devicemapper support";
DeviceDrivers--->Graphics support中選上"Support for frame buffer devices";
Device Drivers--->USBsupport中選上"USB Mass Storage support"(先將該項依賴項設為y,如果是在實環境中,想要更多USB支援,就全選上);
DeviceDrivers--->Network device support--->Ethernet(10 or
100Mbit)中選上"AMDPCnet32 PCI support"(這裡在3.9.6的版本裡面選項是
Ethernet driver support---> AMD PCnet32 PCI support)
Device Drivers--> SCSI device support --> SCSCI low-level drivers --> [M] Serial ATA(SATA) support --> [M] Intel PIIX/ICH SATA support(這個沒找到,沒選)
如果你在vmware下編譯核心,硬碟用的是scsi的,以下三個選項必選:
DeviceDrivers---><*>SCSI device support
DeviceDrivers---><*>SCSI device support---><*>SCSI disk support
DeviceDrivers---><*>SCSI device support--->SCSI low-leveldrivers---><*>BusLogic SCSI support
Device Drivers --->;Fusion MPT device support --->;;Fusion MPT (base + ScsiHost) drivers; Fusion MPT misc device (ioctl) driver(這個要不要,不確定)
(3)File system--->
Second extended fs support
Ext2 extended attributes
Ext2 POSIX Access Control Lists
Ext2 Security Labels
Ext3 journalling file system support
Ext3 extended attributes
Ext3 POSIX Access Control Lists
Ext3 Security Labels
JBD (ext3) debugging support
File system--->DOS/FAT/NT Filesystems中選上"NTFSfile system support"
注意:
ext2和ext3檔案系統配置很重要,也是必需的,如果對Ext3、Ext2檔案的支援直接編譯進核心,在你reboot時機器就會當掉,出現如下錯誤資訊:
kernel panic no init found ,trypassing init = option to kernel
或者是:
VFS Cannot open root device"hdxy" or unknow-block(0,0)
Please append a correct"root=" boot option
kernel panic VFS Unable to mount rootfs on unknown-block(0,0)
或者是:
mount error 19 mounting ext3
pivotroot;pivot_root(/sysroot,/sysroot/initrd) failed 2
umount /initrd/proc fail 2
Freeing unused kernel memory 244kfreed
Kernel panic – not syncing No initfound. Try passing init = option to kernel
三 編譯工作
zcat ../initrd-2.6.30.4.img |cpio -i 11537blocks
1.在/usr/src/linux-2.6.18目錄下,執行以下命令:
# make dep(建立編譯時間所需的從屬檔案,如果核心從未編譯過,此步可跳過)
# make clean(清除核心編譯的目標檔案,如果核心從未編譯過,此步可跳過)
# make bzImage(開始編譯)
如果發生以下錯誤:
這裡如果發生simples的錯誤遇到上面的錯誤直接更換標頭檔。參考地址是:http://ju.outofmemory.cn/entry/6447
命令是:
[root@wangguan linux-3.9.6]# makeheaders_install
[root@wangguan linux-3.9.6]# cd /usr/include/
[root@wangguan include]# mv asm asm_orig
[root@wangguan include]# mv linux linux_orig
[root@wangguan include]# mv asm-genericasm-generic_orig
[root@wangguan include]# cd/usr/src/linux-3.9.6
[root@wangguan linux-3.9.6]# cp -rusr/include/asm /usr/include/
[root@wangguan linux-3.9.6]# cp -r usr/include/asm-generic/ /usr/include/
[root@wangguan linux-3.9.6]# cp -rusr/include/linux /usr/include/
核心編譯成功後,會在/usr/src/linux/arch/i386/boot目錄中產生一個新核心的映像檔案bzImage.如果用makezImage編譯,核心很大的話,系統會提示你用make bzImage命令來編譯make
# make modules(編譯可載入模組)
這裡可能發生的錯誤是:
fs/gfs2/rgrp.c: In function ‘rg_mblk_search’:
fs/gfs2/rgrp.c:1398: 編譯器內部錯誤:段錯誤
請提交一份完整的錯誤報表,
如有可能請附上經預先處理後的源檔案。
具體步驟請參見<URL:http://bugzilla.redhat.com/bugzilla>。
Preprocessed source stored into /tmp/ccOsYE5A.out file, pleaseattach this to your bugreport.
make[2]: *** [fs/gfs2/rgrp.o] 錯誤 1
make[1]: *** [fs/gfs2] 錯誤 2
make: *** [fs] 錯誤 2
原因是在rgrp.c類中對有些構造體方法的變數賦值,初始化的錯誤。修改為:
雙斜杠是注釋掉原來的申明的方式,將賦值寫出來。將涉及到struct gfs2_rbm rbm的申明賦值的方式都修改了(後面有好幾個類似的錯誤)。(這個錯誤其實在更新完gcc版本後是不會出現的。由於太多人看文章不發言我就不詳細說明了。)
# make modules_install(安裝可載入模組)
安裝成功後,系統會在/lib/modules目錄下產生一個2.6.18子目錄,裡面存放著新核心的所有可載入模組.
# make install(安裝新核心)
注意:make install的時候可能會出現如下錯誤資訊
No module BusLogic found for kernel 2.4.12
mkinitrd failed
此問題一般只出現在SCSI硬碟+VMWARE+REDHAT架構中,因為BusLogic被編譯進了核心而不是一個module的形式(2.4核心的Buslogic模組即使靜態編譯進核心也不行).解決方式是直接將BusLogic.o檔案複製過去:
# cp/usr/src/linux-2.6.18/drivers/scsi/BusLogic.o/lib/modules/2.6.18/kernel/drivers/scsi
複製過後再執行一下make install,這一步若卡住了,下面的都無法進行。
開機啟動的時候如果發生以下錯誤:
insmod: error inserting '/lib/dm-region-hash.ko': -1 File exists
解決方案是:
1,解壓initrd檔案
[root@bogon ~]# cp /boot/initrd-3.9.6.img /tmp/
[root@bogon ~]# cd /tmp/
[root@bogon tmp]# ls
initrd-2.6.30.4.img
[root@bogon tmp]# mkdir newinitrd
[root@bogon tmp]# cd newinitrd/
[root@bogon newinitrd]# zcat ../ initrd-3.9.6.img |cpio -i
11537 blocks
釋放之後看到如下內容
[root@bogon newinitrd]# ls
bin dev etc init lib proc sbin sys sysroot
2下邊就是編輯init,刪掉其中重複的四行中的兩行
echo "Loading dm-region-hash.ko module"
insmod /lib/dm-region-hash.ko
echo "Loading dm-region-hash.ko module"
insmod /lib/dm-region-hash.ko
3,重新打包initrd
[root@bogon newinitrd]# find .|cpio -c -o > ../initrd
11538 blocks
[root@bogon newinitrd]# cd ..
[root@bogon tmp]# gzip -9 < initrd > initrd.img
[root@bogon tmp]# ls
initrd-2.6.30.4.img initrd initrd.img newinitrd
好了,initrd.img就是重新打包的initrd了,然後把initrd.img拷貝到/boot,更改grub.conf裡邊的initrd-2.6.30.4.img為initrd.img就可以了,
這樣“insmod: error inserting '/lib/dm-region-hash.ko' : -1 File exists” 就不會有了
Can’t open HIDP control……錯誤:
在配置的時候 make menuconfig 將藍芽的裝置加上:
Bluetooth subsystem support--->
iptables錯誤 這個錯我找了很多的網站,包括翻牆。總算被解決了。
iptables -restore 不能初始化
ip6tables -restore 不能初始化 (這裡字太多不想打)
解決的方式說出來太多了 不想打字了,都沒人回複。