CentOS核心定製

來源:互聯網
上載者:User

出於工作需要,定製CentOS核心,以改進TCP的傳輸效率,如何改進這裡暫且不提,下面重點講解如何擷取源碼,編譯。

1. 編譯前的準備以【root】使用者安裝下列組件:
su root
yum -y groupinstall "Development Tools"
yum -y install ncurses-devel qt-devel
yum -y install rpm-build redhat-rpm-config asciidoc hmaccalc perl-ExtUtils-Embed xmlto
yum -y install audit-libs-devel binutils-devel elfutils-devel elfutils-libelf-devel
yum -y install newt-devel python-devel zlib-devel


2. 安裝核心的原始碼組件【注】必須使用【非root】使用者執行命令
rpm -i http://vault.centos.org/6.5/updates/Source/SPackages/kernel-2.6.32-431.11.2.el6.src.rpm 2>&1 | grep -v mock

附:kernel-2.6.32-431.11.2.el6.src.rpm 源在國外,下載速度可能會比較慢,可以藉助BGP機房或VPN加速。

附原始碼地址:
http://vault.centos.org/6.5/os/Source/SPackages/
http://vault.centos.org/6.5/updates/Source/SPackages/


3. 解壓及預備原始碼檔案【注】必須使用【非root】使用者執行命令
cd ~/rpmbuild/SPECS
rpmbuild -bp --target=$(uname -m) kernel.spec

附:現在核心的原始碼分類樹可以在 ~/rpmbuild/BUILD/kernel*/linux*/ 這個目錄內找得到。


4. 編譯新核心【注】必須使用【非root】使用者執行命令
cd ~/rpmbuild/SPECS
rpmbuild -bb --with baseonly --without debug --without debuginfo --target=`uname -m` kernel.spec 2> build-err.log | tee build-out.log

附:此過程可能需要花費90分鐘左右,請耐心等待。

附:現在自訂核心的 rpm 檔案可以在 ~/rpmbuild/RPMS/`uname -m`/ 目錄內找到。


5. 安裝新核心【注】必須使用【root】使用者執行命令
su root
rpm -ivh kernel-*.rpm


6. 驗證重啟,查看核心版本
uname -a


參考資料:
[1]CentOS Wiki http://wiki.centos.org/zh/HowTos/Custom_Kernel#head-981e27f326384c58516d3b2051b225526bb0a50a

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.