內核編譯實際操作效果演示
環境:CentOS7.2,自帶內核版本為3.10.0-327.el7.x86_64,下載3.18.41版本進行編譯
步驟1:確保開發工具包組已安裝
[root@localhost ~]# yum grouplist 已加載插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile 已安裝環境分組: GNOME 桌面 可用的環境分組: 最小安裝 基礎設施服務器 計算節點 文件及打印服務器 基本網頁服務器 虛擬化主機 帶 GUI 的服務器 KDE Plasma Workspaces 開發及生成工作站 已安裝的組: 開發工具 可用組: 傳統 UNIX 兼容性 兼容性程序庫 圖形管理工具 安全性工具 控制臺互聯網工具 智能卡支持 科學記數法支持 系統管理 系統管理工具 完成 [root@localhost ~]#
步驟2:下載內核源碼包,解壓到某個路徑下
[root@localhost ~]# ls anaconda-ks.cfg initial-setup-ks.cfg linux-3.18.41.tar.xz [root@localhost ~]# tar xf linux-3.18.41.tar.xz -C /usr/src/ [root@localhost ~]# ls /usr/src/ debug kernels linux-3.18.41 [root@localhost ~]# cd /usr/src/linux-3.18.41/ [root@localhost linux-3.18.41]# ls arch COPYING crypto drivers fs init Kbuild kernel MAINTAINERS mm README samples security tools virt block CREDITS Documentation firmware include ipc Kconfig lib Makefile net REPORTING-BUGS scripts sound usr [root@localhost linux-3.18.41]#
步驟3:提供一個config配置文件(本實驗中以當前系統的安裝時內核的模塊選項進行進一步的選擇,然后編譯),在此文件基礎上進行進一步的選擇內核的功能模塊,安裝ncurses工具,該工具能幫助我們使用make menuconfig基于圖形化窗口的界面,完成內核模塊的選擇
[root@localhost linux-3.18.41]# yum install ncurses 已加載插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile 軟件包 ncurses-5.9-13.20130511.el7.x86_64 已安裝并且是最新版本 無須任何處理 [root@localhost linux-3.18.41]# yum list all|grep ncurses ncurses.x86_64 5.9-13.20130511.el7 @anaconda ncurses-base.noarch 5.9-13.20130511.el7 @anaconda ncurses-libs.x86_64 5.9-13.20130511.el7 @anaconda ncurses-devel.i686 5.9-13.20130511.el7 cdrepo ncurses-devel.x86_64 5.9-13.20130511.el7 cdrepo ncurses-libs.i686 5.9-13.20130511.el7 cdrepo ncurses-static.i686 5.9-13.20130511.el7 cdrepo ncurses-static.x86_64 5.9-13.20130511.el7 cdrepo ncurses-term.noarch 5.9-13.20130511.el7 cdrepo [root@localhost linux-3.18.41]# yum install "ncurses-devel.x86_64" 已加載插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile 正在解決依賴關系 --> 正在檢查事務 ---> 軟件包 ncurses-devel.x86_64.0.5.9-13.20130511.el7 將被 安裝 --> 解決依賴關系完成 依賴關系解決 ============================================================================================================================================================= Package 架構 版本 源 大小 ============================================================================================================================================================= 正在安裝: ncurses-devel x86_64 5.9-13.20130511.el7 cdrepo 713 k 事務概要 ============================================================================================================================================================= 安裝 1 軟件包 總下載量:713 k 安裝大?。?.1 M Is this ok [y/d/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction 正在安裝 : ncurses-devel-5.9-13.20130511.el7.x86_64 1/1 驗證中 : ncurses-devel-5.9-13.20130511.el7.x86_64 1/1 已安裝: ncurses-devel.x86_64 0:5.9-13.20130511.el7 完畢! [root@localhost linux-3.18.41]# [root@localhost linux-3.18.41]# cp /boot/config-3.10.0-327.el7.x86_64 /usr/src/linux-3.18.41/.config [root@localhost linux-3.18.41]# make menuconfig //注意make動作都需要cd到源碼包的解壓目錄
步驟4:選擇好相應的模塊后,進行make,可用-j指定用多少線程同時進行編譯
步驟5:安裝模塊
步驟6:make install
步驟7:驗證是否成功
原創文章,作者:M20-1倪文超,如若轉載,請注明出處:http://www.www58058.com/46139