• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • 編譯linux 2.6內核

    發表于:2007-07-04來源:作者:點擊數: 標簽:
    內核升級最好升級到2.6.8以后,之前的kernel好象有offset漏洞.偶就是按這篇文檔升級成功的,不過rpm與聲卡好象還有點問題! 一 編譯前準備 1)下載一份內核源代碼,我下的是linux-2.6.7.tar.bz2,你可在如下地址下載它或者是更新的版本. http://kernel.org/pub/l
    內核升級最好升級到2.6.8以后,之前的kernel好象有offset漏洞.偶就是按這篇文檔升級成功的,不過rpm與聲卡好象還有點問題!

    一 編譯前準備
    1)下載一份內核源代碼,我下的是linux-2.6.7.tar.bz2,你可在如下地址下載它或者是更新的版本.
    http://kernel.org/pub/linux/kernel/v2.6/
    2) 下載最新版本的module-init-tools( "module-init-tools-3.0.tar.gz" and "modutils-2.4.21-23.src.rpm")
    http://www.kernel.org/pub/linux/kernel/people/rusty/modules/module-init-tools-3.0.tar.gz
    http://www.kernel.org/pub/linux/kernel/people/rusty/modules/modutils-2.4.21-23.src.rpm
    3)安裝module-init-tools. 它會替代depmod [/sbin/depmod]和其他工具.
    tar -zxvf module-init-tools-3.0.tar.gz
    cd module-init-tools-3.0
    ./configure --prefix=/sbin
    make
    make install
    ./generate-modprobe.conf /etc/modprobe.conf
    4)安裝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.21-23.src.rpm
    rpmbuild -bb /usr/src/redhat/SPECS/modutils.spec
    rpm -Fi /usr/src/redhat/RPMS/i386/modutils-2.4.21-23.i386.rpm
    5)解壓縮內核源代碼.把下載的源代碼包放到目錄/usr/src下,然后
    cd /usr/src
    tar xvfj linux-2.6.7.tar.bz2
    cd linux-2.6.7
    二 編譯配置
    在這一部分涉及幾個重要模塊的配置請,特別注意.一般用"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)
    以上三項配置關系到新內核能否正常運行,請備加注意.其他的配置如果不是很了解,大可以按默認的選擇.
    三 編譯過程
    按如下命令編譯,大概需要一個多小時,大可以好好放松一下javascript:window.open(this.src);" style="CURSOR: pointer" onload="return imgzoom(this,550)">
    make bzImage
    make modules
    make modules_install
    make install
    運行新內核之前,請檢查一下/boot/grub/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/hdc3
    # initrd /initrd-version.img
    #boot=/dev/hdc
    default=1
    timeout=10
    splashimage=(hd0,0)/grub/splash.xpm.gz
    title Red Hat Linux (2.6.7)
    root (hd0,0)
    kernel /vmlinuz-2.6.7 ro root=LABEL=/
    initrd /initrd-2.6.7.img
    title Red Hat Linux (2.4.20-
    root (hd0,0)
    kernel /vmlinuz-2.4.20-8 ro root=LABEL=/
    initrd /initrd-2.4.20-8.img

    四 運行內核的常見問題
    1)RPM問題

    進入編譯好的內核后,與RPM相關的命令有些不能使用,并出現下列錯誤:

    rpmdb: unable to join the environment
    error: db4 error(11) from dbenv->open: Resource temporarily unavailable
    error: cannot open Packages index using db3 - Resource temporarily unavailable (11)
    error: cannot open Packages database in /var/lib/rpm
    no packages



    解決方法是執行“export LD_ASSUME_KERNEL =2.2.25”命令,也可以將其寫入/etc/bashrc。
    2)Sound問題

    聲音部分的模塊名也改變了。我的筆記本原來的聲卡驅動是i810_audio,現在已改為snd-intel8x0。因此需要把下面的內容添加到/etc/modprobe.conf中:

    alias char-major-14 soundcore
    alias sound snd-intel8x0
    alias sound-slot-0 snd-intel8x0
    alias snd-card-0 snd-intel8x0
    alias sound-service-0-0 snd-mixer-oss
    alias sound-service-0-1 snd-seq-oss
    alias sound-service-0-3 snd-pcm-oss
    alias sound-service-0-8 snd-seq-oss
    alias sound-service-0-12 snd-pcm-oss
    install snd-intel8x0 /sbin/modprobe --ignore-install sound-slot-0 &&
    { /bin/aumix-minimal -f /etc/.aumixrc -L >/dev/null 2>&1; /bin/true; }
    remove snd-intel8x0
    { /bin/aumix-minimal -f /etc/.aumixrc -S >/dev/null 2>&1; /bin/true; };
    /sbin/modprobe -r --ignore-remove sound-slot-0



    然后執行“modprobe sound”加載聲音模塊,并使用下列命令檢驗聲卡驅動:

    #cat /proc/asound/cards



    顯示結果如下:

    0 [SI7012]: ICH - SiS SI7012
    SiS SI7012 at 0xdc00, irq 11


    3)VMware問題

    解決方法是:

    ◆ 將/usr/bin/vmware-config.pl中所有的“/proc/ksyms”替換為“/proc/kallsyms”。使用“sed”命令可以達到這個目的。

    ◆ 重新運行該腳本,使用內核頭文件編譯新的內核模塊。在編譯過程中如發生錯誤,應該進入/usr/lib/vmware/modules/source,使用下面的命令將vmnet.tar解包:

    #tar xvf vmnet.tar



    ◆ 進入vmnet-only目錄修改bridge.c文件。將“atomic_add(skb->truesize, &sk->wmem_alloc);”修改為“atomic_add(skb->truesize, &sk->sk_wmem_alloc);”,并用類似的方式將“protinfo”改為“sk_protinfo”。

    ◆ 再次把vmnet-only目錄用下面的命令重新打包為vmmon.tar:

    #tar cvf vmmon.tar vmnet-only。



    如果按照上面的操作依舊失敗,另一解決方法是到http://ftp.cvut.cz/vmware/下載vmware-any-any-updateXX.tar.gz,將其解壓到任何目錄下,執行其中的runme.pl。

    4)USB問題

    新的2.6.0內核中使用的USB模塊大多數已經改名,因此需要修改/etc/rc.sysinit中對USB子系統初始化的代碼。將該文件中所有的“keybdev”改為“usbkbd”、“mousedev”改為“usbmouse”、“/proc/bus/usb”改為“/sys/bus/usb”,并在/etc/init.d/halt中進行同樣的修改。此外,還要在/etc/rc.sysinit中找到“needusbstorage”,做如下修改:

    needusbstorage=
    if [ $usb = "1" ]; then
    needusbstorage=`LC_ALL=C grep -e "^I.*Cls=08" /sys/bus/usb/devices 2>/dev/null`
    action $"Initializing USB 1.1 host controller: " modprobe ohci-hcd 2> /dev/null
    action $"Initializing USB HID interface: " modprobe hid 2> /dev/null
    action $"Initializing USB keyboard: " modprobe usbkbd 2> /dev/null
    action $"Initializing USB mouse: " modprobe usbmouse 2> /dev/null
    fi



    如果USB總線是2.0的,還需將“ohci-hcd”改為“ehci-hcd”。

    5)Sysfs問題

    解決方法是:

    ◆ 建立目錄/sys:#mkdir /sys

    ◆ 在/etc/rc.d/rc.sysinit文件中找到“mount -f /proc”,在其下一行加入“mount -f /sys”。

    ◆ 同樣在/etc/rc.d/rc.sysinit文件中找到“action $"Mounting proc filesystem: " mount -n -t proc /proc /proc”,在其下一行加入“action $"Mounting sysfs filesystem: " mount -n -t sysfs /sys /sys”。

    ◆ 在/etc/fstab文件中加入“none /sys sysfs defaults 0 0”。

    ◆ 在/etc/init.d/halt的halt_get_remaining函數中找到“awk ' ~ /^\/$|^\/proc|^\/dev/”,改為“awk ' ~ /^\/$|^\/proc|^\/sys|^\/dev/”。

    6)Hotplug(熱插拔)問題

    內核對熱插拔功能的支持與KMOD內核線程有關。

    解決方法是將/etc/rc.sysinit中所有的/proc/ksyms替換為/proc/kallsyms。執行如下命令:

    #mv /etc/rc.d/rc.sysinit /etc/rc.d/rc.sysinit.bak
    #sed -e 's/\/proc\/ksyms/\/proc\/kallsyms/g' /etc/rc.d/rc.sysinit.bak > /etc/rc.d/rc.sysinit

    7)Glibc問題

    用戶可以升級Glibc標準庫的軟件包來解決該問題。因為有些發行版,例如Red Hat 9.0上默認安裝的Glibc可能是被Red Hat內核小組修改過的。軟件包的下載地址是:

    ftp://ftp.rpmfind.net/linux/redhat/updates/9/en/os/i386/glibc-2.3.2-27.9.i386.rpm。

    可以連同以下幾個軟件包一起升級:

    ftp://ftp.rpmfind.net/linux/redhat/updates/9/en/os/i386/glibc-common-2.3.2-27.9.i386.rpm

    ftp://ftp.rpmfind.net/linux/redhat/updates/9/en/os/i386/glibc-devel-2.3.2-27.9.i386.rpm

    ftp://ftp.rpmfind.net/linux/redhat/updates/9/en/os/i386/glibc-utils-2.3.2-27.9.i386.rpm

    如果使用“rpm -Uvh glibc*”失敗,請用命令“rpm -e”先刪除舊的Glibc,然后用命令“rpm -Uvh --force glibc*”強制安裝。

    其它問題

    大家也許還會遇到其它問題,但是無論遇上什么問題都可以依照下列步驟嘗試解決:

    1.內核組件盡可能編譯為模塊。執行如下命令可以快速重建內核:

    #make all modules_install install



    2.軟件失敗的大多數情況是由于模塊名已被更改,而/etc/rc.d/rc.sysinit和/etc/rcX.d/*下的腳本卻沒有修改這些值而導致的。因此,依次修改相關條目可以改進,但是這也需要相當多的背景知識。如果覺得麻煩,可以把所有加載模塊的命令集中在/etc/rc.d/rc.local中。例如:

    modprobe eth0
    modprobe isofs
    modprobe loop
    modprobe vfat



    同時修改/etc/modoribe.conf文件。具體可參見“man modoribe.conf”獲得更多的幫助信息。

    3.如果想知道某模塊變更后的名字,可以首先在“make menuconfig”時找到該選項,選擇Help找到它的配置名稱(CONFIG_*),然后到源代碼相關目錄下的makefile中尋找CONFIG_*。一般可以找到obj-$(CONFIG_*)一項,其值就是該模塊的名字。

    附:本文參考文章:http://tech.ccidnet.com/pub/article/c309_a103129_p1.html

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>