內核編譯
環境配置
本文以16.04 Ubuntu版本為例
安裝好Ubuntu系統,首先第一步進行源的更新
sudo vi /etc/apt/sources.list
替換阿里云的源
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
更新源
apt-get update
預裝內核編譯所需要的工具鏈
sudo apt-get install ncurses-dev
sudo apt-get install libssl-dev
~~問題提示~~
> 出現這個或者fatal error: openssl/名單.h: No such file or directory。都是沒有安裝libssl-dev~ libssl-dev包含libraries, header files and manpages,他是openssl的一部分,而openssl對ssl進行了實現~?
解決方案: 使用sudo apt-get install libssl-dev來安裝libssl-dev即可
> make menuconfig' requires the ncurses libraries.
git clone 最新的內核源碼(速度快)
git clone https://github.com/torvalds/linux.git
下載時間比較慢,所以需要等待多點時間。注意這個源碼的地址是在變更的,如果過了時間,建議是重新查找內核源碼的下載地址
GitHub上面的linux內核的地址如下:
https://github.com/torvalds/linux
Linux編譯命令的四大金剛:
make -j8 menuconfig
make -j8
make modules_install
make install
中間過程基本是漫長的等待,編譯的速度和宿主機的運行速度有關。注意上面命令的-j8 表示的編譯時候并發的線程數目。如果電腦配置好,可以適當的把數字變大。編譯時間可以大大縮短。
注意:在menuconfig 用戶可以自己選擇自己需要的模塊(module),可以選擇編譯模塊的時候是編譯進入內核(build-in)還是編譯成那種可以自動加載模式(M)或者是不包含(N)。
下面分享幾個簡單工具
uname -sr
lsmod
這個命令可以查看當前系統的源碼內核
交流可以直接回復評論