我使用的是64位的redhat 5.4 版本是2.6.18系統(tǒng)一 準(zhǔn)備工作(下載內(nèi)核升級工具及內(nèi)核源碼)1.下載linux-3.9.6源碼。地址是:http://www./pub/linux/mips/kernel/v3.x/ 2.下載module-init-tools。(我使用的是module-init-tools-3.10.tar.bz2,下載地址:https://www./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.將下載好的內(nèi)核源代碼和工具都放到/usr/src文件夾下。 2.拷貝完畢,開始解壓新內(nèi)核,具體操作請依次執(zhí)行以下命令; # cd /usr/src(進(jìn)入/usr/src目錄,如果已經(jīng)在/usr/src目錄,可不執(zhí)行該命令) # rm –rf linux(刪除linux文件夾,如果內(nèi)核以前從未編譯過,則沒有這個文件夾,可不執(zhí)行該命令) # tar jvxf linux-3.9.6.tar.bz2(解壓新內(nèi)核) # ln -s linux-3.9.6linux(重新生成linux文件夾) 3.安裝module-init-tools工具,在/usr/src目錄下,依次執(zhí)行下列命令; # tar jvxf module-init-tools-3.10.tar.bz2(解壓module-init-tools) # cd module-init-tools-3.10(由/usr/src目錄進(jìn)入module-init-tools目錄) #./configure--prefix=/ # make moveold # make allinstall #./generate-modprobe.conf/etc/modprobe.conf
4.安裝另外三個升級工具,回到/usr/src目錄下,依次執(zhí)行下列命令; # 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 如果不更新以上幾個升級包,后面編譯內(nèi)核時會提示以下錯誤; mkinitrd failed make[1]; *** [install] Error 1 make; *** [install] Error 2 5. 配置內(nèi)核選項 # cdlinux-2.6.18(進(jìn)入/usr/src/linux-2.6.18目錄) # makemrproper(確保源代碼目錄下沒有不正確的.o文件) #make menuconfig(配置內(nèi)核選項,這里我使用的是以前的配置文件,命令是 :
cp/boot/config-2.6.18-164.el5 ./.config,然后輸入命令makemenuconfig選擇load文件:.config) 此時會出現(xiàn)一個圖形界面,列出了所有的內(nèi)核配置選項,有的選項下還有子選項,可以用方向鍵選擇,用Y鍵確定,大多數(shù)選項默認(rèn)就行,以下幾個選項必須選擇(這里必須認(rèn)真選擇不然會出錯。編譯也就不能成功) (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"(先將該項依賴項設(shè)為y,如果是在實(shí)環(huán)境中,想要更多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下編譯內(nèi)核,硬盤用的是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文件系統(tǒng)配置很重要,也是必需的,如果對Ext3、Ext2文件的支持直接編譯進(jìn)內(nèi)核,在你reboot時機(jī)器就會當(dāng)?shù)?出現(xiàn)如下錯誤信息: 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目錄下,執(zhí)行以下命令: # make dep(建立編譯時所需的從屬文件,如果內(nèi)核從未編譯過,此步可跳過) # make clean(清除內(nèi)核編譯的目標(biāo)文件,如果內(nèi)核從未編譯過,此步可跳過) # make bzImage(開始編譯) 如果發(fā)生以下錯誤:
這里如果發(fā)生simples的錯誤遇到上面的錯誤直接更換頭文件。參考地址是:http://ju./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/
內(nèi)核編譯成功后,會在/usr/src/linux/arch/i386/boot目錄中生成一個新內(nèi)核的映像文件bzImage.如果用makezImage編譯,內(nèi)核很大的話,系統(tǒng)會提示你用make bzImage命令來編譯make # make modules(編譯可加載模塊) 這里可能發(fā)生的錯誤是:
fs/gfs2/rgrp.c: In function ‘rg_mblk_search’: fs/gfs2/rgrp.c:1398: 編譯器內(nèi)部錯誤:段錯誤 請?zhí)峤灰环萃暾腻e誤報告, 如有可能請附上經(jīng)預(yù)處理后的源文件。 具體步驟請參見<URL:http://bugzilla./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類中對有些構(gòu)造體方法的變量賦值,初始化的錯誤。修改為: ------------------------------------------------------------------- 1395 static void rg_mblk_search(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip, 1396 unsigned requested) 1397 { 1398 //struct gfs2_rbm rbm = { .rgd = rgd, }; 1399 struct gfs2_rbm rbm; 1400 rbm.rgd = rgd; 1642 //struct gfs2_rbm rbm = { .rgd = rgd, .bi = rgd->rd_bits, .offset = 0 }; 1643 struct gfs2_rbm rbm; 1644 rbm.rgd = rgd; 1645 rbm.bi = rgd->rd_bits; 1646 rbm.offset = 0; 1943 static unsigned char gfs2_get_block_type(struct gfs2_rgrpd *rgd, u64 block) 1944 { 1945 //struct gfs2_rbm rbm = { .rgd = rgd, }; 1946 struct gfs2_rbm rbm; 1947 rbm.rgd = rgd 1967 static void gfs2_alloc_extent(const struct gfs2_rbm *rbm, bool dinode, 1968 unsigned int *n) 1969 { 1970 //struct gfs2_rbm pos = { .rgd = rbm->rgd, }; 1971 struct gfs2_rbm pos; 1972 pos.rgd = rbm->rgd; 2125 //struct gfs2_rbm rbm = { .rgd = ip->i_rgd, }; 2126 struct gfs2_rbm rbm; 2127 rbm.rgd = ip->i_rgd; ----------------------------------------------------------------------
雙斜杠是注釋掉原來的申明的方式,將賦值寫出來。將涉及到struct gfs2_rbm rbm的申明賦值的方式都修改了(后面有好幾個類似的錯誤)。(這個錯誤其實(shí)在更新完gcc版本后是不會出現(xiàn)的。由于太多人看帖子不發(fā)言我就不詳細(xì)說明了。)
# make modules_install(安裝可加載模塊) 安裝成功后,系統(tǒng)會在/lib/modules目錄下生成一個2.6.18子目錄,里面存放著新內(nèi)核的所有可加載模塊. # make install(安裝新內(nèi)核) 注意:make install的時候可能會出現(xiàn)如下錯誤信息 No module BusLogic found for kernel 2.4.12 mkinitrd failed 此問題一般只出現(xiàn)在SCSI硬盤+VMWARE+REDHAT架構(gòu)中,因為BusLogic被編譯進(jìn)了內(nèi)核而不是一個module的形式(2.4內(nèi)核的Buslogic模塊即使靜態(tài)編譯進(jìn)內(nèi)核也不行).解決方式是直接將BusLogic.o文件復(fù)制過去: # cp/usr/src/linux-2.6.18/drivers/scsi/BusLogic.o/lib/modules/2.6.18/kernel/drivers/scsi 復(fù)制過后再執(zhí)行一下make install,這一步若卡住了,下面的都無法進(jìn)行。 開機(jī)啟動的時候如果發(fā)生以下錯誤:
insmod: error inserting '/lib/dm-region-hash.ko': -1 File exists 解決方法是:
Can’t open HIDP control……錯誤:
在配置的時候 make menuconfig 將藍(lán)牙的設(shè)備加上: Bluetooth subsystem support--->
iptables錯誤 這個錯我找了很多的網(wǎng)站,包括翻墻??偹惚唤鉀Q了。
iptables -restore 不能初始化 ip6tables -restore 不能初始化 (這里字太多不想打)
|
|
|