內核編譯
程序包的編譯安裝
./configure,make,make install
./configure檢查編譯環境依賴關系,并設定參數
make 執行編譯操作
make install 安裝
二進制
庫文件
幫助文檔
配置文件
前提:開發環境(開發工具,開發庫),頭文件:/usr/include
開源:源代碼
發行版,就是把源代碼拿過來,組織成程序。 以“通用”的目標 前提: 1、準備好開發環境 2、獲取目標主機上硬件設備的相關信息 3、獲取到目標主機系統功能的相關信息,例如要啟用的文件系統 4、獲取內核源代碼包:www.kernel.org 準備開發環境: centos6 包組 development tools server platform development centos7 包組 development tools server platform development
獲取硬件信息
cpu
lscpu cat /proc/cpuinfo [root@centos7 home]# yum -y install x86info [root@centos7 home]# x86info -a
pci
lspci -v -vv
usb
lsusb -v -vv
lsblk
硬盤
了解全部硬件設備信息
hal-device
內核編譯過程
獲取內核源代碼包
-rw-r–r– 1 root root 90398912 Aug 19 21:28 linux-4.7.1.tar.x
建議放到/usr/src/目錄下
再創為其創建名為linux的軟連接。(一般針對當前系統編譯驅動時,會去找這個linux目錄)
多內核時,支持回滾。
[root@centos7 ~]# tar -xf linux-4.7.1.tar.xz -C /usr/src/[root@centos7 src]# ln -s linux-4.7.1/ linux
[root@centos7 src]# ll
total 4
drwxr-xr-x. 2 root root 6 Aug 12 2015 debug
drwxr-xr-x. 3 root root 34 Aug 23 16:38 kernels
lrwxrwxrwx 1 root root 12 Sep 11 14:45 linux -linux-4.7.1/
drwxrwxr-x 24 root root 4096 Aug 16 15:35 linux-4.7.1進入linux目錄下
make help
可以查看幫助。
yum install ncruses-devel
步驟
tar -xf linux-4.7.1.tar.xz -C /usr/src/
ln -s linux-4.7.1/ linux
cd linux
make menuconfig 配置內核選項
make -j # 啟用幾個內核 編譯內核,可使用-j
make moudules_install 安裝內核模塊
make install 安裝內核
screen
一個終端上打開多個屏幕
打開 screen
拆除 ctrl + a,d
列出 screen -ls
連接至 screen -r SCREEN_ID
關閉screen 連接至,而后執行exit
紅帽系列發行版都把內核的配置模板放在/boot/config-3.10.0-327.el7.x86_64
并不是所有發行版都有的
內核自帶功能,/proc/cofig.gz 展開也是模板。
復制到/usr/src/linux/目錄下改名為.config
1、配置內核選項
支持“更新”模式進行配置,在已有.config文件的基礎上進行“修改”配置
make config 基于命令以遍歷的方式去配置內核中可配置的每個選項。
make menuconfig基于ncureses的文本配置窗口
make gconfig 基于GTK開發環境的窗口界面,包租“桌面開發平臺”
make xconfig 基于QT開發環境的窗口界面
支持“全新配置”模式進行配置
make defconfig 基于內核為目標平臺提供的默認配置為模板進行配置
make allnoconfig 所有選項均為no
2、編譯
多線程編譯 make -j # 編譯內核中的部分代碼 只編譯某子目錄中的相關代碼 pwd目錄必須為 /usr/src/linux make path/to/dir 只編譯一個特定的模塊 make path/to/file.ko
原創文章,作者:yyw,如若轉載,請注明出處:http://www.www58058.com/47816
寫的不錯,內核編譯多我們來說作為我們基本了解即可,