【手把手教你玩 Linux Kernel】如何編譯 Linux Kernel

原始碼下載

可以從 www.kernel.org 下載最新的 kernel ( 我是下載 5.0.9 的 )

1
2
wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.0.9.tar.xz
x linux-5.0.9.tar.xz

設置編譯參數

1
make menuconfig

有選單可以客製化,選完之後會產生 .config

編譯

1
make -j$(nproc)

-j 多個程序並行編譯

make help

可以用 make help 看看有哪些參數可以用

安裝

1
make -j$(nproc) modules_install

安裝內核模塊 ( kernel module )
會裝到 /lib/modules/

1
make -j$(nproc) install

安裝內核本體
會裝到 /boot
並且會自動更新 grub
下次重啟系統就會是新的內核

安裝到其他目錄

1
export INSTALL_PATH=/path/to/install


  1. https://www.cyberciti.biz/tips/compiling-linux-kernel-26.html
  2. https://stackoverflow.com/questions/35931157/change-linux-kernel-installation-directory

【手把手教你玩 Linux Kernel】如何編譯 Linux Kernel

http://oalieno.github.io/2019/04/23/compile-kernel/

Author

oalieno

Posted on

2019-04-23

Updated on

2023-11-15

Licensed under

Comments