Linux, 工作, 生活, 家人

Ubuntu, ARM

Ubuntu Build Original Linux Kernel

最好的方式應該是這一篇文章

不要再用什麼 fakeroot 去編了, 失敗率超高, 尤其是在 ARM 平台

https://wiki.ubuntu.com/KernelTeam/GitKernelBuild

Install necessary ubuntu packages.

sudo apt-get install git build-essential kernel-package fakeroot libncurses5-dev libssl-dev ccache bison flex libelf-dev dwarves

來個範例, 在 ARM64 上編了 4.10~4.17 其中幾個版本, 每次都成功

git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
cd linux
git checkout -b 4.17 v4.17
cp /boot/config-`uname -r` .config
scripts/config --disable SYSTEM_REVOCATION_KEYS
make olddefconfig
make -j `getconf _NPROCESSORS_ONLN` deb-pkg LOCALVERSION=-custom

不知道為什麼,Ubuntu 22.04 Linux kernel 5.19 上這個方法又不行了,可能是因為取用 vanilla Linux kernel git source 的關係

copy /boot/config-5.19 到 Linux 時要注意要移掉認證的 .pem ,要不然會編不過,命令如下,記得還是要 make olddefconfig 讓新設定生效[ref]

scripts/config --disable SYSTEM_REVOCATION_KEYS
scripts/config --disable SYSTEM_TRUSTED_KEYS

接下來下面這一段就可以編了,在我的系統上沒問題

fakeroot debian/rules clean
cp /boot/config-`uname -r` .config
scripts/config --disable SYSTEM_REVOCATION_KEYS
make olddefconfig
make clean
#remove the non git files
git clean -f
rm vmlinux-gdb.py
#make sure there is no linux*.tar too
rm ../linux*.gz

# cherry pick RC6 hack (or necessary command), if don't have it can by pass it.
git cherry-pick 0c6b6fa52c6ad54332eed64acb6aebc59f75e0b2

#
make -j `getconf _NPROCESSORS_ONLN` deb-pkg LOCALVERSION=-custom
cd ..

不過這是包成 package ,如果只是單純的要改參數開發時開機用,那就直接 make install 就好了,但是抄 ubutnu 的 kernel configure file 檔案會太大,應該是包了 debug info,這時要 strip modules ,以免 ramdisk 太大

make -j `nproc` && make INSTALL_MOD_STRIP=1 modules_install && make install 

ref. ubuntu build kernel from git with a source change, how to ignore ‘unrepresentable changes to source’ error
Why is my initial ramdisk so big?

發佈留言