如何编译和安装自定义主线内核
我在一台新笔记本电脑上运行Ubuntu 15.10,但为了获得对该硬件的适当全面支持,我显然需要4.4内核+自定义补丁。 如果您对细节感兴趣,请在此处查看。
我知道主线内核PPA,但我的理解是它们没有来源。 如果是这种情况,这似乎消除了使用主线内核PPA的可能性,因为我无法修补它。 所以我一直试图检查git源并构建它但无法找到最新的相关说明。
有人可以帮助解决在15.10上构建4.4内核的问题吗?
获取并编译主线内核,git方法:
另见: https : //wiki.ubuntu.com/KernelTeam/GitKernelBuild我做的事情有点不同(还有什么是新的?)。
先决条件(必须):
第1步是apt-get update
和apt-get dist-upgrade
(即确保一切都是最新的)
第2步
sudo apt-get install fakeroot build-essential crash kexec-tools makedumpfile kernel-wedge
第3步
sudo apt-get build-dep linux
第4步
sudo apt-get install git-core libncurses5 libncurses5-dev libelf-dev asciidoc binutils-dev
从内核4.3开始的先决条件:
sudo apt-get install libssl-dev
先决条件(可选):
sudo apt-get install git-email git-doc
git部分:
mkdir temp-k-git cd temp-k-git git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git cd linux
永远不要在默认主分支中执行操作。 总是做一些工作区。
git checkout -b k44rc8_stock v4.4-rc8
窃取Ubuntu内核配置文件(已安装):
ls -l /boot cp /boot/config-4.4.0-040400rc8-generic .config
Ubuntu配置文件已完全调试。 制作一个庞大的内核并且需要两倍的编译时间
scripts/config --disable DEBUG_INFO
关于内核4.4的特别说明以及如果使用Ubuntu 14.04进行编译(我不知道15.10),使用旧版本的c编译器:它无法使用CONFIG_CC_STACKPROTECTOR_STRONG进行编译。
scripts/config --disable CC_STACKPROTECTOR_STRONG
编译内核:
time make -j9 bindeb-pkg <<< Suggest use number of CPUs + 1. Use less for some responsiveness to be left for other uses <<< I always time the kernel build.
要么
time make -j9 bindeb-pkg LOCALVERSION=-stock <<< For a localized verion name append
要么
time make -j9 olddefconfig bindeb-pkg LOCALVERSION=-stock <<< To automatically use defaults for any new config stuff (particuarly useful when bisecting the kernel).
构建完成后,安装它:
sudo dpkg -i ../linux-headers-4.4.0-rc8-stock_4.4.0-rc8-stock-144_amd64.deb sudo dpkg -i ../linux-image-4.4.0-rc8-stock_4.4.0-rc8-stock-144_amd64.deb
所以,此时我们知道主线内核编译好了,所以转到自定义内核。 创建一个新分支,应用补丁并编译:
$ git checkout -b k44rc8_custom v4.4-rc8 Switched to a new branch 'k44rc8_custom' $ git am plv6_1_3.patch Applying: cpufreq: intel_pstate: configurable algorithm to get target pstate $ git am plv6_2_3.patch Applying: cpufreq: intel_pstate: account for non C0 time $ git am plv6_3_3.patch Applying: cpufreq: intel_pstate: Account for IO wait time $ time make -j9 olddefconfig bindeb-pkg LOCALVERSION=-custom
请注意,我的目的是不进行make clean
,因为希望通过增量构建来节省大量时间。 第一次编译需要21分26秒,但下一次自定义编译只用了4分43秒。
如果你去http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.4-rc8-wily页面,你会发现一个自述文件,说明如何获取4.4rc8的源文件
构建说明有点令人困惑。 我已经看到了几个构建内核的方法,都有点不同。 有几个先决条件:4.4内核可能还需要其他一些
sudo apt-get build-dep linux-image-$(uname -r) sudo apt-get install libncurses5-dev
然后我为一个成功的构建发出的命令是:
chmod a+x debian/scripts/* chmod a+x debian/scripts/misc/* nano debian.master/changelog fakeroot debian/rules clean fakeroot debian/rules editconfigs fakeroot debian/rules binary-headers binary-generic skipabis=true
修改changelog文件以指示我正在创建自己的内核,方法是在显示的第一个版本号的末尾添加一些内容。